Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
17115412
Commit
17115412
authored
Jul 08, 2021
by
Juste Raimbault
Browse files
[Plugin] JuliaTask again
parent
330d9837
Changes
1
Hide whitespace changes
Inline
Side-by-side
openmole/plugins/org.openmole.plugin.task.julia/src/main/scala/org/openmole/plugin/task/julia/JuliaTask.scala
View file @
17115412
...
...
@@ -33,7 +33,7 @@ object JuliaTask {
implicit
def
isMapped
=
MappedInputOutputBuilder
(
JuliaTask
.
mapped
)
def
installCommands
(
install
:
Seq
[
String
],
libraries
:
Seq
[
String
])
:
Vector
[
String
]
=
{
(
install
++
Seq
(
"""
sh -c "
julia -e 'using Pkg; Pkg.add.([ """
+
libraries
.
map
{
l
⇒
"\
\\
""
+
l
+
"\
\\
""
}.
mkString
(
","
)+
"""])'"""
"
)).
toVector
(
install
++
Seq
(
"""
pwd;
julia -e 'using Pkg; Pkg.add.([ """
+
libraries
.
map
{
l
⇒
"\""
+
l
+
"\""
}.
mkString
(
","
)+
"""])'"""
)).
toVector
}
def
apply
(
...
...
@@ -96,8 +96,8 @@ object JuliaTask {
import
Mapped.noFile
def
writeInputsJSON
(
file
:
File
)
:
Unit
=
{
def
values
=
noFile
(
mapped
.
inputs
).
map
{
m
=>
p
.
context
(
m
.
v
)
}
file
.
content
=
compact
(
render
(
toJSONValue
(
value
s
.
toArray
)))
def
values
=
noFile
(
mapped
.
inputs
).
map
{
m
=>
(
m
.
name
,
p
.
context
(
m
.
v
)
)
}
file
.
content
=
"{"
+
values
.
map
{
case
(
name
,
value
)
=>
"\""
+
name
+
"\": "
+
compact
(
render
(
toJSONValue
(
value
)))}.
mkString
(
","
)+
"}"
}
def
readOutputJSON
(
file
:
File
)
=
{
...
...
@@ -108,12 +108,12 @@ object JuliaTask {
}
def
inputMapping
(
dicoName
:
String
)
:
String
=
noFile
(
mapped
.
inputs
).
map
{
case
m
⇒
s
"${m.name} = $dicoName[\"${m.name}\"]"
noFile
(
mapped
.
inputs
).
zipWithIndex
.
map
{
case
(
m
,
i
)
⇒
s
"${m.name} = $dicoName[\"${m.name}\"]
\n println(${m.name})
"
}.
mkString
(
"\n"
)
def
outputMapping
:
String
=
s
"""Dict(${noFile(mapped.outputs).map { m ⇒ "\""+m.name+"\" => "+m.
v
}.mkString(",")})"""
s
"""Dict(${noFile(mapped.outputs).map { m ⇒ "\""+m.name+"\" => "+m.
name
}.mkString(",")})"""
val
resultContext
:
Context
=
p
.
newFile
.
withTmpFile
(
"script"
,
".jl"
)
{
scriptFile
⇒
p
.
newFile
.
withTmpFile
(
"inputs"
,
".json"
)
{
jsonInputs
⇒
...
...
@@ -141,7 +141,7 @@ object JuliaTask {
ContainerTask
(
containerSystem
=
containerSystem
,
image
=
image
,
command
=
s
"
sh -c \"
julia $scriptName"
+
argumentsValue
+
"\""
,
command
=
s
"
cat $scriptName;
julia $scriptName"
+
argumentsValue
,
workDirectory
=
None
,
relativePathRoot
=
None
,
errorOnReturnValue
=
errorOnReturnValue
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment