Commit c7f87ec1 authored by Romain Reuillon's avatar Romain Reuillon

[Plugin] enh: add go parameter to netlogo task

parent aa3efa86
...@@ -300,7 +300,8 @@ trait NetLogoTask extends Task with ValidateTask { ...@@ -300,7 +300,8 @@ trait NetLogoTask extends Task with ValidateTask {
* Commands to run * Commands to run
* @return * @return
*/ */
def launchingCommands: Seq[FromContext[String]] def go: Seq[FromContext[String]]
def setup: Seq[FromContext[String]]
/** /**
* Mapping of prototypes * Mapping of prototypes
...@@ -320,7 +321,7 @@ trait NetLogoTask extends Task with ValidateTask { ...@@ -320,7 +321,7 @@ trait NetLogoTask extends Task with ValidateTask {
override def validate = Validate { p override def validate = Validate { p
import p._ import p._
val allInputs = External.PWD :: inputs.toList val allInputs = External.PWD :: inputs.toList
launchingCommands.flatMap(_.validate(allInputs)) ++ go.flatMap(_.validate(allInputs)) ++
External.validate(external)(allInputs).apply ++ External.validate(external)(allInputs).apply ++
NetLogoTask.validateNetLogoInputTypes(mapped.inputs.map(_.v)) NetLogoTask.validateNetLogoInputTypes(mapped.inputs.map(_.v))
} }
...@@ -338,6 +339,8 @@ trait NetLogoTask extends Task with ValidateTask { ...@@ -338,6 +339,8 @@ trait NetLogoTask extends Task with ValidateTask {
NetLogoTask.executeNetLogo(instance.netLogo, "clear-all") NetLogoTask.executeNetLogo(instance.netLogo, "clear-all")
for (cmd setup.map(_.from(context))) NetLogoTask.executeNetLogo(instance.netLogo, cmd, ignoreError)
seed.foreach { s NetLogoTask.executeNetLogo(instance.netLogo, s"random-seed ${context(s)}") } seed.foreach { s NetLogoTask.executeNetLogo(instance.netLogo, s"random-seed ${context(s)}") }
for (inBinding mapped.inputs) { for (inBinding mapped.inputs) {
...@@ -345,7 +348,7 @@ trait NetLogoTask extends Task with ValidateTask { ...@@ -345,7 +348,7 @@ trait NetLogoTask extends Task with ValidateTask {
NetLogoTask.setGlobal(instance.netLogo, inBinding.name, v) NetLogoTask.setGlobal(instance.netLogo, inBinding.name, v)
} }
for (cmd launchingCommands.map(_.from(context))) NetLogoTask.executeNetLogo(instance.netLogo, cmd, ignoreError) for (cmd go.map(_.from(context))) NetLogoTask.executeNetLogo(instance.netLogo, cmd, ignoreError)
val contextResult = val contextResult =
External.fetchOutputFiles(external, outputs, preparedContext, resolver, Seq(instance.workspaceDirectory)) ++ mapped.outputs.map { External.fetchOutputFiles(external, outputs, preparedContext, resolver, Seq(instance.workspaceDirectory)) ++ mapped.outputs.map {
......
...@@ -43,7 +43,8 @@ object NetLogo5Task { ...@@ -43,7 +43,8 @@ object NetLogo5Task {
def workspace( def workspace(
workspace: File, workspace: File,
script: String, script: String,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: OptionalArgument[Val[Int]], seed: OptionalArgument[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -52,7 +53,8 @@ object NetLogo5Task { ...@@ -52,7 +53,8 @@ object NetLogo5Task {
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task =
withDefaultArgs( withDefaultArgs(
workspace = Workspace.Directory(directory = workspace, script = script, name = workspace.getName), workspace = Workspace.Directory(directory = workspace, script = script, name = workspace.getName),
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -64,7 +66,8 @@ object NetLogo5Task { ...@@ -64,7 +66,8 @@ object NetLogo5Task {
def file( def file(
script: File, script: File,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: OptionalArgument[Val[Int]], seed: OptionalArgument[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -73,7 +76,8 @@ object NetLogo5Task { ...@@ -73,7 +76,8 @@ object NetLogo5Task {
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task =
withDefaultArgs( withDefaultArgs(
workspace = Workspace.Script(script = script, name = script.getName), workspace = Workspace.Script(script = script, name = script.getName),
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -85,7 +89,8 @@ object NetLogo5Task { ...@@ -85,7 +89,8 @@ object NetLogo5Task {
def apply( def apply(
script: File, script: File,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]] = Seq(),
embedWorkspace: Boolean = false, embedWorkspace: Boolean = false,
seed: OptionalArgument[Val[Int]] = None, seed: OptionalArgument[Val[Int]] = None,
ignoreError: Boolean = false, ignoreError: Boolean = false,
...@@ -93,12 +98,13 @@ object NetLogo5Task { ...@@ -93,12 +98,13 @@ object NetLogo5Task {
ignoreErrorOnDispose: Boolean = false, ignoreErrorOnDispose: Boolean = false,
switch3d: Boolean = false switch3d: Boolean = false
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo5Task =
if (embedWorkspace) workspace(script.getCanonicalFile.getParentFile, script.getName, launchingCommands, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d) if (embedWorkspace) workspace(script.getCanonicalFile.getParentFile, script.getName, go = go, setup = setup, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d)
else file(script, launchingCommands, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d) else file(script, go = go, setup = setup, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d)
private def withDefaultArgs( private def withDefaultArgs(
workspace: NetLogoTask.Workspace, workspace: NetLogoTask.Workspace,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: Option[Val[Int]], seed: Option[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -111,7 +117,8 @@ object NetLogo5Task { ...@@ -111,7 +117,8 @@ object NetLogo5Task {
info = InfoConfig(), info = InfoConfig(),
mapped = MappedInputOutputConfig(), mapped = MappedInputOutputConfig(),
workspace = workspace, workspace = workspace,
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -127,7 +134,8 @@ object NetLogo5Task { ...@@ -127,7 +134,8 @@ object NetLogo5Task {
info: InfoConfig, info: InfoConfig,
mapped: MappedInputOutputConfig, mapped: MappedInputOutputConfig,
workspace: NetLogoTask.Workspace, workspace: NetLogoTask.Workspace,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: Option[Val[Int]], seed: Option[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
......
...@@ -43,7 +43,8 @@ object NetLogo6Task { ...@@ -43,7 +43,8 @@ object NetLogo6Task {
def workspace( def workspace(
workspace: File, workspace: File,
script: String, script: String,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: OptionalArgument[Val[Int]], seed: OptionalArgument[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -52,7 +53,8 @@ object NetLogo6Task { ...@@ -52,7 +53,8 @@ object NetLogo6Task {
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task =
withDefaultArgs( withDefaultArgs(
workspace = Workspace.Directory(directory = workspace, script = script, name = workspace.getName), workspace = Workspace.Directory(directory = workspace, script = script, name = workspace.getName),
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -64,7 +66,8 @@ object NetLogo6Task { ...@@ -64,7 +66,8 @@ object NetLogo6Task {
def file( def file(
script: File, script: File,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: OptionalArgument[Val[Int]], seed: OptionalArgument[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -73,7 +76,8 @@ object NetLogo6Task { ...@@ -73,7 +76,8 @@ object NetLogo6Task {
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task =
withDefaultArgs( withDefaultArgs(
workspace = Workspace.Script(script = script, name = script.getName), workspace = Workspace.Script(script = script, name = script.getName),
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -85,7 +89,8 @@ object NetLogo6Task { ...@@ -85,7 +89,8 @@ object NetLogo6Task {
def apply( def apply(
script: File, script: File,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]] = Seq(),
embedWorkspace: Boolean = false, embedWorkspace: Boolean = false,
seed: OptionalArgument[Val[Int]] = None, seed: OptionalArgument[Val[Int]] = None,
ignoreError: Boolean = false, ignoreError: Boolean = false,
...@@ -93,12 +98,13 @@ object NetLogo6Task { ...@@ -93,12 +98,13 @@ object NetLogo6Task {
ignoreErrorOnDispose: Boolean = false, ignoreErrorOnDispose: Boolean = false,
switch3d: Boolean = false switch3d: Boolean = false
)(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task = )(implicit name: sourcecode.Name, definitionScope: DefinitionScope): NetLogo6Task =
if (embedWorkspace) workspace(script.getCanonicalFile.getParentFile, script.getName, launchingCommands, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d) if (embedWorkspace) workspace(script.getCanonicalFile.getParentFile, script.getName, go = go, setup = setup, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d)
else file(script, launchingCommands, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d) else file(script, go = go, setup = setup, seed = seed, ignoreError = ignoreError, reuseWorkspace = reuseWorkspace, ignoreErrorOnDispose = ignoreErrorOnDispose, switch3d = switch3d)
private def withDefaultArgs( private def withDefaultArgs(
workspace: NetLogoTask.Workspace, workspace: NetLogoTask.Workspace,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: Option[Val[Int]], seed: Option[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
...@@ -111,7 +117,8 @@ object NetLogo6Task { ...@@ -111,7 +117,8 @@ object NetLogo6Task {
info = InfoConfig(), info = InfoConfig(),
mapped = MappedInputOutputConfig(), mapped = MappedInputOutputConfig(),
workspace = workspace, workspace = workspace,
launchingCommands = launchingCommands, go = go,
setup = setup,
seed = seed, seed = seed,
ignoreError = ignoreError, ignoreError = ignoreError,
reuseWorkspace = reuseWorkspace, reuseWorkspace = reuseWorkspace,
...@@ -127,7 +134,8 @@ object NetLogo6Task { ...@@ -127,7 +134,8 @@ object NetLogo6Task {
info: InfoConfig, info: InfoConfig,
mapped: MappedInputOutputConfig, mapped: MappedInputOutputConfig,
workspace: NetLogoTask.Workspace, workspace: NetLogoTask.Workspace,
launchingCommands: Seq[FromContext[String]], go: Seq[FromContext[String]],
setup: Seq[FromContext[String]],
seed: Option[Val[Int]], seed: Option[Val[Int]],
ignoreError: Boolean, ignoreError: Boolean,
reuseWorkspace: Boolean, reuseWorkspace: Boolean,
......
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