Commit b298709a authored by Hélène Arduin's avatar Hélène Arduin
Browse files

Merge branch 'dev' of ssh://gitlab.openmole.org:10000/openmole/openmole into dev

parents 0bf0a113 e94d7c23
Pipeline #1200 failed with stages
in 7 minutes and 52 seconds
......@@ -330,7 +330,7 @@ def corePlugins =
allDomain ++
allTools
def allTools = Seq(netLogoAPI, netLogo5API, netLogo6API, pattern, json)
def allTools = Seq(netLogoAPI, netLogo5API, netLogo6API, pattern, json, methodData)
lazy val defaultActivator = OsgiKeys.bundleActivator := Some(name.value + ".Activator")
......@@ -377,6 +377,11 @@ lazy val json = OsgiProject(pluginDir, "org.openmole.plugin.tool.json", imports
libraryDependencies += Libraries.shapeless)
lazy val methodData = OsgiProject(pluginDir, "org.openmole.plugin.tool.methoddata", imports = Seq("*")) settings (toolsSettings: _*) settings (
OsgiKeys.bundleActivator := None,
libraryDependencies += Libraries.circe
) enablePlugins(ScalaJSPlugin) dependsOn(openmoleDSL)
/* Domain */
def allDomain = Seq(collectionDomain, distributionDomain, fileDomain, modifierDomain, rangeDomain, boundsDomain)
......@@ -477,13 +482,13 @@ lazy val evolution = OsgiProject(pluginDir, "org.openmole.plugin.method.evolutio
lazy val evolutionData = OsgiProject(pluginDir, "org.openmole.plugin.method.evolution.data", imports = Seq("*")) settings (pluginSettings: _*) settings (
OsgiKeys.bundleActivator := None,
libraryDependencies += Libraries.circe
) enablePlugins(ScalaJSPlugin) dependsOn(omrHook)
) enablePlugins(ScalaJSPlugin) dependsOn(omrHook, methodData)
lazy val abc = OsgiProject(pluginDir, "org.openmole.plugin.method.abc", imports = Seq("*")) dependsOn(openmoleDSL, toolsTask, pattern, boundsDomain % "test") settings(
libraryDependencies += Libraries.mgo, libraryDependencies += Libraries.shapeless) settings (pluginSettings: _*)
lazy val directSampling = OsgiProject(pluginDir, "org.openmole.plugin.method.directsampling", imports = Seq("*")) dependsOn(openmoleDSL, distributionDomain, pattern, modifierDomain, fileHook, combineSampling, omrHook) settings (pluginSettings: _*)
lazy val directSampling = OsgiProject(pluginDir, "org.openmole.plugin.method.directsampling", imports = Seq("*")) dependsOn(openmoleDSL, distributionDomain, pattern, modifierDomain, fileHook, combineSampling, omrHook, methodData) settings (pluginSettings: _*)
lazy val sensitivity = OsgiProject(pluginDir, "org.openmole.plugin.method.sensitivity", imports = Seq("*")) dependsOn(exception, workflow, workspace, openmoleDSL, lhsSampling, quasirandomSampling, directSampling, collectionDomain % "test", boundsDomain % "test") settings (pluginSettings: _*)
......@@ -516,7 +521,7 @@ lazy val fileSource = OsgiProject(pluginDir, "org.openmole.plugin.source.file",
/* Task */
def allTask = Seq(toolsTask, external, netLogo, netLogo5, netLogo6, jvm, scala, template, systemexec, container, r, scilab, python, gama, cormas, spatial, timing)
def allTask = Seq(toolsTask, external, netLogo, netLogo5, netLogo6, jvm, scala, template, systemexec, container, r, scilab, python, julia, gama, cormas, spatial, timing)
lazy val toolsTask = OsgiProject(pluginDir, "org.openmole.plugin.task.tools", imports = Seq("*")) dependsOn (openmoleDSL) settings (pluginSettings: _*)
......@@ -547,6 +552,8 @@ lazy val scilab = OsgiProject(pluginDir, "org.openmole.plugin.task.scilab", impo
lazy val python = OsgiProject(pluginDir, "org.openmole.plugin.task.python", imports = Seq("*")) dependsOn(container, json) settings (pluginSettings: _*)
lazy val julia = OsgiProject(pluginDir, "org.openmole.plugin.task.julia", imports = Seq("*")) dependsOn(container, json) settings (pluginSettings: _*)
lazy val gama = OsgiProject(pluginDir, "org.openmole.plugin.task.gama", imports = Seq("*")) dependsOn (container) settings (pluginSettings: _*)
lazy val cormas = OsgiProject(pluginDir, "org.openmole.plugin.task.cormas", imports = Seq("*")) dependsOn (container, json) settings (pluginSettings: _*) settings(
......
......@@ -11,7 +11,7 @@ import ScriptContext.{ ENGINE_SCOPE, GLOBAL_SCOPE }
import java.io.{ Closeable, Reader }
import org.openmole.core.compiler.ScalaREPL.OMIMain
import org.openmole.tool.types.ClassUtils
import org.openmole.tool.types.TypeTool
import scala.tools.nsc.Settings
......@@ -168,7 +168,7 @@ class OMScripted(val factory: ScriptEngineFactory, val omIMain: IMain)
val newline = (defines map (s s"val ${s.name} = $$INSTANCE${req.accessPath}.${s.name}")).mkString(instance, ";", ";")
//val newreq = intp.requestFromLine(newline).right.get
val newreq = ClassUtils.callByName[IMain, Either[Result, intp.Request]](intp, "requestFromLine", Vector(newline)).right.get
val newreq = TypeTool.callByName[IMain, Either[Result, intp.Request]](intp, "requestFromLine", Vector(newline)).right.get
val ok = newreq.compile
......
......@@ -18,8 +18,8 @@
package org.openmole.core.context
import org.openmole.core.exception.UserBadDataError
import org.openmole.tool.types.ClassUtils._
import org.openmole.tool.types.{ ClassUtils, Id }
import org.openmole.tool.types.TypeTool._
import org.openmole.tool.types.{ TypeTool, Id }
import shapeless.{ TypeCase, Typeable }
import scala.annotation.tailrec
......@@ -110,6 +110,19 @@ object ValType {
*/
def unsecure(c: Manifest[_]): ValType[Any] = apply(c.asInstanceOf[Manifest[Any]])
def toNativeType(t: ValType[_]): ValType[_] = {
def native = {
val (contentType, level) = ValType.unArrayify(t)
for {
m classEquivalence(contentType.runtimeClass).map(_.manifest)
} yield (0 until level).foldLeft(ValType.unsecure(m)) {
(c, _) c.toArray.asInstanceOf[ValType[Any]]
}
}
native getOrElse t
}
def toTypeString(t: ValType[_]): String = TypeTool.toString(toNativeType(t).manifest)
}
/**
......@@ -261,11 +274,11 @@ class Val[T](val simpleName: String, val `type`: ValType[T], val namespace: Name
* @param p the prototype to test
* @return true if the prototype is assignable from the given prototype
*/
def isAssignableFrom(p: Val[_]): Boolean = ClassUtils.assignable(p.`type`.manifest, `type`.manifest)
def isAssignableFrom(p: Val[_]): Boolean = TypeTool.assignable(p.`type`.manifest, `type`.manifest)
/**
* Test if a given object can be accepted by the prototype
* (compares runtime classes using [[ClassUtils.classAssignable]])
* (compares runtime classes using [[TypeTool.classAssignable]])
*
* @param obj
* @return
......
......@@ -24,7 +24,7 @@ import org.openmole.core.context._
import org.openmole.core.exception._
import org.openmole.core.fileservice.FileService
import org.openmole.core.pluginmanager._
import org.openmole.tool.types.ClassUtils._
import org.openmole.tool.types.TypeTool._
import org.openmole.core.workspace.TmpDirectory
import org.openmole.tool.cache._
import org.openmole.tool.random._
......@@ -112,24 +112,6 @@ object ScalaCompilation {
}
}
def toScalaNativeType(t: ValType[_]): ValType[_] = {
def native = {
val (contentType, level) = ValType.unArrayify(t)
for {
m classEquivalence(contentType.runtimeClass).map(_.manifest)
} yield (0 until level).foldLeft(ValType.unsecure(m)) {
(c, _) c.toArray.asInstanceOf[ValType[Any]]
}
}
native getOrElse t
}
def toTypeString(t: ValType[_]): String = {
toScalaNativeType(t).manifest.toString.
replace(".package$", ".").
replace("$", ".")
}
def function[RETURN](inputs: Seq[Val[_]], source: String, plugins: Seq[File], libraries: Seq[File], wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN])(implicit newFile: TmpDirectory, fileService: FileService) = {
val s = script(inputs, source, wrapping, returnType)
compile[CompilationClosure[RETURN]](s, plugins, libraries)
......@@ -162,10 +144,10 @@ object ScalaCompilation {
*/
def script[RETURN](inputs: Seq[Val[_]], source: String, wrapping: OutputWrapping[RETURN], returnType: ValType[_ <: RETURN]) = {
val header =
s"""new ${classOf[CompilationClosure[_]].getName}[${toTypeString(returnType)}] {
s"""new ${classOf[CompilationClosure[_]].getName}[${ValType.toTypeString(returnType)}] {
| def apply(${prefix}context: ${manifest[Context].toString}, ${prefix}RNG: ${manifest[RandomProvider].toString}, ${prefix}NewFile: ${manifest[TmpDirectory].toString}) = {
| object $inputObject {
| ${inputs.toSeq.map(i ⇒ s"""var ${i.name} = ${prefix}context("${i.name}").asInstanceOf[${toTypeString(i.`type`)}]""").mkString("; ")}
| ${inputs.toSeq.map(i ⇒ s"""var ${i.name} = ${prefix}context("${i.name}").asInstanceOf[${ValType.toTypeString(i.`type`)}]""").mkString("; ")}
| }
| import ${inputObject}._
| implicit def ${Val.name(Variable.openMOLENameSpace, "RNGProvider")} = ${prefix}RNG
......@@ -176,7 +158,7 @@ object ScalaCompilation {
s"""$header
| $source
| ${wrapping.wrapOutput}
| }: ${toTypeString(returnType)}
| }: ${ValType.toTypeString(returnType)}
|}""".stripMargin
Script(code, source, header.split("\n").size + 1)
......@@ -258,7 +240,7 @@ object ScalaCompilation {
def wrapOutput =
s"""
|scala.jdk.CollectionConverters.MapHasAsJava(Map[String, Any]( ${outputs.toSeq.map(p ⇒ s""" "${p.name}" -> (${p.name}: ${toTypeString(p.`type`)})""").mkString(",")} )).asJava
|scala.jdk.CollectionConverters.MapHasAsJava(Map[String, Any]( ${outputs.toSeq.map(p ⇒ s""" "${p.name}" -> (${p.name}: ${ValType.toTypeString(p.`type`)})""").mkString(",")} )).asJava
|""".stripMargin
}
......
......@@ -18,7 +18,7 @@ package org.openmole.core.outputmanager
import java.io.{ OutputStream, PrintStream }
import org.openmole.tool.types.ClassUtils
import org.openmole.tool.types.TypeTool
import scala.collection.mutable
import org.openmole.tool.stream._
......@@ -82,12 +82,12 @@ object OutputManager {
def redirectSystemOutput(ps: PrintStream) = {
System.setOut(ps)
ClassUtils.call(Console, "setOutDirect", Seq(classOf[PrintStream]), Seq(ps))
TypeTool.call(Console, "setOutDirect", Seq(classOf[PrintStream]), Seq(ps))
}
def redirectSystemError(ps: PrintStream) = {
System.setErr(ps)
ClassUtils.call(Console, "setErrDirect", Seq(classOf[PrintStream]), Seq(ps))
TypeTool.call(Console, "setErrDirect", Seq(classOf[PrintStream]), Seq(ps))
}
private def unregister(thread: ThreadGroup) = {
......
......@@ -531,7 +531,7 @@ package composition {
implicit def on[T, C](implicit toDSLContainer: ExplorationMethod[T, C]): ExplorationMethod[On[T, EnvironmentProvider], C] = t toDSLContainer(t.value).copy(environment = Some(t.on))
implicit def hooked[T, C](implicit toDSLContainer: ExplorationMethod[T, C]): ExplorationMethod[Hooked[T], C] = t {
val container = toDSLContainer(t.value)
container.copy(hooks = container.hooks ++ Seq(t.hook))
container.copy(hooks = container.hooks ++ Seq(t.h))
}
}
......@@ -567,7 +567,7 @@ package composition {
def apply(t: T, h: P): T
}
case class Hooked[+T](value: T, hook: Hook)
case class Hooked[+T](value: T, h: Hook)
trait CompositionPackage {
......
......@@ -25,6 +25,7 @@ import org.openmole.plugin.domain.modifier._
import org.openmole.plugin.tool.pattern._
import org.openmole.plugin.hook.file._
import org.openmole.plugin.hook.omr._
import org.openmole.plugin.tool.methoddata._
package object directsampling {
......@@ -41,12 +42,12 @@ package object directsampling {
implicit def metadataEncoder: Encoder[DirectSamplingMetadata] = deriveConfiguredEncoder[DirectSamplingMetadata]
implicit def metadataDecoder: Decoder[DirectSamplingMetadata] = deriveConfiguredDecoder[DirectSamplingMetadata]
case class DirectSampling(sampled: Seq[String], aggregation: Seq[Aggregation]) extends DirectSamplingMetadata
case class Replication(seed: String, sample: Int, aggregation: Seq[Aggregation]) extends DirectSamplingMetadata
case class DirectSampling(sampled: Seq[ValData], aggregation: Option[Seq[Aggregation]], output: Seq[ValData]) extends DirectSamplingMetadata
case class Replication(seed: ValData, sample: Int, aggregation: Option[Seq[Aggregation]]) extends DirectSamplingMetadata
def aggregation(ag: directsampling.Aggregation) = Aggregation(ag.value.name, ag.outputVal.name)
def aggregation(ag: directsampling.Aggregation) = Aggregation(ValData(ag.value), ValData(ag.outputVal))
case class Aggregation(output: String, aggregated: String)
case class Aggregation(output: ValData, aggregated: ValData)
}
sealed trait DirectSamplingMetadata
......@@ -114,13 +115,14 @@ package object directsampling {
val dsl = method(t)
implicit val defScope = dsl.scope
val exclude = if (!includeSeed) Seq(dsl.method.seed) else Seq()
val metadata = DirectSamplingMetadata.Replication(seed = dsl.method.seed.name, dsl.method.sample, dsl.method.aggregation.map(DirectSamplingMetadata.aggregation))
val aggregation = if (dsl.method.aggregation.isEmpty) None else Some(dsl.method.aggregation.map(DirectSamplingMetadata.aggregation))
val metadata = DirectSamplingMetadata.Replication(seed = ValData(dsl.method.seed), dsl.method.sample, aggregation)
Hooked(t, FormattedFileHook(output = output, values = values, exclude = exclude, format = format, metadata = metadata))
}
}
object DirectSampling {
case class Method(sampled: Seq[Val[_]], aggregation: Seq[Aggregation])
case class Method(sampled: Seq[Val[_]], aggregation: Seq[Aggregation], output: Seq[Val[_]])
implicit def method[S]: ExplorationMethod[DirectSampling[S], Method] = m {
implicit def defScope = m.scope
......@@ -145,7 +147,8 @@ package object directsampling {
method =
Method(
sampled = m.sampled,
aggregation = m.aggregation
aggregation = m.aggregation,
output = s.outputs
)
)
......@@ -175,7 +178,9 @@ package object directsampling {
format: F = CSVOutputFormat(append = true))(implicit outputFormat: OutputFormat[F, DirectSamplingMetadata]): Hooked[M] = {
val dsl = method(t)
implicit val defScope = dsl.scope
val metadata = DirectSamplingMetadata.DirectSampling(dsl.method.sampled.map(_.name), dsl.method.aggregation.map(DirectSamplingMetadata.aggregation))
val aggregation = if (dsl.method.aggregation.isEmpty) None else Some(dsl.method.aggregation.map(DirectSamplingMetadata.aggregation))
val metadata = DirectSamplingMetadata.DirectSampling(dsl.method.sampled.map(v ValData(v)), aggregation, dsl.method.output.map(v ValData(v)))
def fileName = if (outputFormat.appendable(format)) None else Some("experiment${" + FormattedFileHook.experiment.name + "}")
Hooked(t, FormattedFileHook(output = output, values = values, format = format, metadata = metadata, fileName = fileName))
}
......
......@@ -253,10 +253,14 @@ class DirectSamplingSpec extends FlatSpec with Matchers {
val model = EmptyTask() set (inputs += l)
DirectSampling(
model,
ExplicitSampling(l, Seq(1.0, 2.0))
) hook display
val ds =
DirectSampling(
model,
ExplicitSampling(l, Seq(1.0, 2.0))
)
(ds hook display): DSL
(ds hook display hook "/tmp/test.csv"): DSL
}
}
\ No newline at end of file
......@@ -17,19 +17,25 @@ object EvolutionMetadata {
implicit def evolutionMetadataDecoder: Decoder[EvolutionMetadata] = deriveConfiguredDecoder[EvolutionMetadata]
object GenomeBoundData {
case class DoubleBound(name: String, low: Double, high: Double) extends GenomeBoundData
case class IntBound(name: String, low: Int, high: Int, continuous: Boolean = false) extends GenomeBoundData
case class DoubleSequenceBound(name: String, low: Array[Double], high: Array[Double]) extends GenomeBoundData
case class IntSequenceBound(name: String, low: Array[Int], high: Array[Int]) extends GenomeBoundData
case class Enumeration(name: String, values: Seq[String]) extends GenomeBoundData
import org.openmole.plugin.tool.methoddata._
sealed trait IntervalType
object Discrete extends IntervalType
object Continuous extends IntervalType
case class IntBound(value: ValData, low: Int, high: Int, intervalType: IntervalType) extends GenomeBoundData
case class DoubleBound(value: ValData, low: Double, high: Double, intervalType: IntervalType) extends GenomeBoundData
case class IntSequenceBound(value: ValData, low: Seq[Int], high: Seq[Int], intervalType: IntervalType) extends GenomeBoundData
case class DoubleSequenceBound(value: ValData, low: Seq[Double], high: Seq[Double], intervalType: IntervalType) extends GenomeBoundData
case class Enumeration(value: ValData, values: Seq[String]) extends GenomeBoundData
def name(data: GenomeBoundData) =
data match {
case d: DoubleBound d.name
case d: IntBound d.name
case d: DoubleSequenceBound d.name
case d: IntSequenceBound d.name
case d: Enumeration d.name
case d: DoubleBound d.value.name
case d: IntBound d.value.name
case d: DoubleSequenceBound d.value.name
case d: IntSequenceBound d.value.name
case d: Enumeration d.value.name
}
}
......
......@@ -11,6 +11,7 @@ import org.openmole.core.exception.InternalProcessingError
import org.openmole.core.tools.io.Prettifier._
import Genome.GenomeBound
import org.openmole.plugin.hook.omr.MethodData
import org.openmole.tool.types.TypeTool
object MetadataGeneration {
......@@ -18,15 +19,16 @@ object MetadataGeneration {
def boundData(b: GenomeBound) = {
import EvolutionMetadata._
import org.openmole.plugin.tool.methoddata._
b match {
case b: GenomeBound.ScalarDouble GenomeBoundData.DoubleBound(b.v.name, b.low, b.high)
case b: GenomeBound.ScalarInt GenomeBoundData.IntBound(b.v.name, b.low, b.high)
case b: GenomeBound.ContinuousInt GenomeBoundData.IntBound(b.v.name, b.low, b.high, continuous = true)
case b: GenomeBound.SequenceOfDouble GenomeBoundData.DoubleSequenceBound(b.v.name, b.low, b.high)
case b: GenomeBound.SequenceOfInt GenomeBoundData.IntSequenceBound(b.v.name, b.low, b.high)
case b: GenomeBound.Enumeration[_] GenomeBoundData.Enumeration(b.v.name, b.values.map(_.prettify()))
case b: GenomeBound.SequenceOfEnumeration[_] GenomeBoundData.Enumeration(b.v.name, b.values.map(_.prettify()))
case b: GenomeBound.ScalarDouble GenomeBoundData.DoubleBound(ValData(b.v), low = b.low, high = b.high, intervalType = GenomeBoundData.Continuous)
case b: GenomeBound.ScalarInt GenomeBoundData.IntBound(ValData(b.v), low = b.low, high = b.high, intervalType = GenomeBoundData.Discrete)
case b: GenomeBound.ContinuousInt GenomeBoundData.IntBound(ValData(b.v), low = b.low, high = b.high, intervalType = GenomeBoundData.Continuous)
case b: GenomeBound.SequenceOfDouble GenomeBoundData.DoubleSequenceBound(ValData(b.v), low = b.low, high = b.high, intervalType = GenomeBoundData.Continuous)
case b: GenomeBound.SequenceOfInt GenomeBoundData.IntSequenceBound(ValData(b.v), low = b.low, high = b.high, intervalType = GenomeBoundData.Discrete)
case b: GenomeBound.Enumeration[_] GenomeBoundData.Enumeration(ValData(b.v), b.values.map(_.prettify()))
case b: GenomeBound.SequenceOfEnumeration[_] GenomeBoundData.Enumeration(ValData(b.v), b.values.map(_.prettify()))
}
}
......
......@@ -331,7 +331,7 @@ object NichedNSGA2 {
import p._
(i: CDGenome.NoisyIndividual.Individual[Phenotype]) {
import org.openmole.tool.types.ClassUtils._
import org.openmole.tool.types.TypeTool._
val values = i.phenotypeHistory.map(Phenotype.outputs(phenotypeContent, _)).transpose
val context =
(phenotypeContent.outputs zip values).map {
......
package org.openmole.plugin.task.julia
import org.openmole.core.highlight.HighLight
import org.openmole.core.pluginregistry.PluginRegistry
import org.osgi.framework.{ BundleActivator, BundleContext }
class Activator extends BundleActivator {
override def stop(context: BundleContext): Unit =
PluginRegistry.unregister(this)
override def start(context: BundleContext): Unit = {
import org.openmole.core.highlight.HighLight._
val keyWords: Vector[HighLight] =
Vector(
TaskHighLight(objectName(JuliaTask))
)
PluginRegistry.register(this, Vector(this.getClass.getPackage), highLight = keyWords)
}
}
\ No newline at end of file
package org.openmole.plugin.task.julia
import monocle.macros._
import org.openmole.core.dsl._
import org.openmole.core.dsl.extension._
import org.openmole.core.fileservice.FileService
import org.openmole.core.networkservice.NetworkService
import org.openmole.core.preference.Preference
import org.openmole.core.serializer.SerializerService
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workflow.builder._
import org.openmole.core.workflow.task.TaskExecutionContext
import org.openmole.core.workflow.tools.OptionalArgument
import org.openmole.core.workflow.validation.ValidateTask
import org.openmole.core.workspace.{TmpDirectory, Workspace}
import org.openmole.plugin.task.container._
import org.openmole.plugin.task.external._
import org.openmole.plugin.tool.json._
import org.openmole.tool.outputredirection.OutputRedirection
import org.openmole.plugin.task.container
/**
* https://docs.julialang.org/en/v1/
*/
object JuliaTask {
implicit def isTask: InputOutputBuilder[JuliaTask] = InputOutputBuilder(JuliaTask.config)
implicit def isExternal: ExternalBuilder[JuliaTask] = ExternalBuilder(JuliaTask.external)
implicit def isInfo = InfoBuilder(info)
implicit def isMapped = MappedInputOutputBuilder(JuliaTask.mapped)
def installCommands(install: Seq[String], libraries: Seq[String]): Vector[String] = {
(install ++ Seq("""julia -e 'using Pkg; Pkg.add.([ """ + libraries.map { l "\""+l+"\"" }.mkString(",")+"""])'""" )).toVector
}
def apply(
script: RunnableScript,
arguments: OptionalArgument[String] = None,
libraries: Seq[String] = Seq.empty,
install: Seq[String] = Seq.empty,
workDirectory: OptionalArgument[String] = None,
hostFiles: Seq[HostFile] = Vector.empty,
environmentVariables: Seq[EnvironmentVariable] = Vector.empty,
errorOnReturnValue: Boolean = true,
returnValue: OptionalArgument[Val[Int]] = None,
stdOut: OptionalArgument[Val[String]] = None,
stdErr: OptionalArgument[Val[String]] = None,
containerSystem: ContainerSystem = ContainerSystem.default,
installContainerSystem: ContainerSystem = ContainerSystem.default)(implicit name: sourcecode.Name, definitionScope: DefinitionScope, newFile: TmpDirectory, workspace: Workspace, preference: Preference, fileService: FileService, threadProvider: ThreadProvider, outputRedirection: OutputRedirection, networkService: NetworkService, serializerService: SerializerService) = {
new JuliaTask(
script = script,
arguments = arguments.option,
image = ContainerTask.prepare(installContainerSystem, DockerImage("julia"), installCommands(install, Seq("JSON")++libraries)),
errorOnReturnValue = errorOnReturnValue,
returnValue = returnValue,
stdOut = stdOut,
stdErr = stdErr,
hostFiles = hostFiles,
environmentVariables = environmentVariables,
containerSystem = containerSystem,
config = InputOutputConfig(),
external = External(),
info = InfoConfig(),
mapped = MappedInputOutputConfig()
) set (outputs += (Seq(returnValue.option, stdOut.option, stdErr.option).flatten: _*))
}
}
@Lenses case class JuliaTask(
script: RunnableScript,
image: PreparedImage,
arguments: Option[String],
errorOnReturnValue: Boolean,
returnValue: Option[Val[Int]],
stdOut: Option[Val[String]],
stdErr: Option[Val[String]],
hostFiles: Seq[HostFile],
environmentVariables: Seq[EnvironmentVariable],
containerSystem: ContainerSystem,
config: InputOutputConfig,
external: External,
info: InfoConfig,
mapped: MappedInputOutputConfig) extends Task with ValidateTask {
lazy val containerPoolKey = ContainerTask.newCacheKey
override def validate = container.validateContainer(Vector(), environmentVariables, external)
override def process(executionContext: TaskExecutionContext) = FromContext { p
import org.json4s.jackson.JsonMethods._
import p._
import Mapped.noFile
def writeInputsJSON(file: File): Unit = {
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) = {
import org.json4s._
import org.json4s.jackson.JsonMethods._
val outputValues = parse(file.content)
(outputValues.asInstanceOf[JArray].arr zip noFile(mapped.outputs).map(_.v)).map { case (jvalue, v) jValueToVariable(jvalue, v) }
}
def inputMapping(dicoName: String): String =
noFile(mapped.inputs).zipWithIndex.map {
case (m,i) s"${m.name} = $dicoName[\"${m.name}\"]"
}.mkString("\n")
def outputMapping: String =