Commit e94d7c23 authored by Juste Raimbault's avatar Juste Raimbault
Browse files

[Plugin] JuliaTask working

parents 17115412 a712c31d
Pipeline #1199 failed with stages
in 32 minutes and 15 seconds
...@@ -21,9 +21,7 @@ import org.openmole.tool.outputredirection.OutputRedirection ...@@ -21,9 +21,7 @@ import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.plugin.task.container import org.openmole.plugin.task.container
/** /**
* https://docs.julialang.org/en/v1/base/numbers/#Base.isone * https://docs.julialang.org/en/v1/
*
* https://gist.github.com/silgon/0ba43e00e0749cdf4f8d244e67cd9d6a
*/ */
object JuliaTask { object JuliaTask {
...@@ -33,7 +31,7 @@ object JuliaTask { ...@@ -33,7 +31,7 @@ object JuliaTask {
implicit def isMapped = MappedInputOutputBuilder(JuliaTask.mapped) implicit def isMapped = MappedInputOutputBuilder(JuliaTask.mapped)
def installCommands(install: Seq[String], libraries: Seq[String]): Vector[String] = { def installCommands(install: Seq[String], libraries: Seq[String]): Vector[String] = {
(install ++ Seq("""pwd;julia -e 'using Pkg; Pkg.add.([ """ + libraries.map { l "\""+l+"\"" }.mkString(",")+"""])'""" )).toVector (install ++ Seq("""julia -e 'using Pkg; Pkg.add.([ """ + libraries.map { l "\""+l+"\"" }.mkString(",")+"""])'""" )).toVector
} }
def apply( def apply(
...@@ -109,11 +107,11 @@ object JuliaTask { ...@@ -109,11 +107,11 @@ object JuliaTask {
def inputMapping(dicoName: String): String = def inputMapping(dicoName: String): String =
noFile(mapped.inputs).zipWithIndex.map { noFile(mapped.inputs).zipWithIndex.map {
case (m,i) s"${m.name} = $dicoName[\"${m.name}\"]\n println(${m.name})" case (m,i) s"${m.name} = $dicoName[\"${m.name}\"]"
}.mkString("\n") }.mkString("\n")
def outputMapping: String = def outputMapping: String =
s"""Dict(${noFile(mapped.outputs).map { m ⇒ "\""+m.name+"\" => "+m.name }.mkString(",")})""" s"""[${noFile(mapped.outputs).map { m ⇒ m.name }.mkString(",")}]"""
val resultContext: Context = p.newFile.withTmpFile("script", ".jl") { scriptFile val resultContext: Context = p.newFile.withTmpFile("script", ".jl") { scriptFile
p.newFile.withTmpFile("inputs", ".json") { jsonInputs p.newFile.withTmpFile("inputs", ".json") { jsonInputs
...@@ -141,7 +139,7 @@ object JuliaTask { ...@@ -141,7 +139,7 @@ object JuliaTask {
ContainerTask( ContainerTask(
containerSystem = containerSystem, containerSystem = containerSystem,
image = image, image = image,
command = s"cat $scriptName; julia $scriptName" + argumentsValue, command = s"julia $scriptName" + argumentsValue,
workDirectory = None, workDirectory = None,
relativePathRoot = None, relativePathRoot = None,
errorOnReturnValue = errorOnReturnValue, errorOnReturnValue = errorOnReturnValue,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment