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