Plug your Julia model

Suggest edits
Documentation > Plug


JuliaTask syntax 🔗

Preliminary remark 🔗

The JuliaTask uses the Singularity container system. You should install Singularity on your system otherwise you won't be able to use it. The JuliaTask relies on an underlying ContainerTask.

Arguments of the JuliaTask 🔗

It takes the following arguments :
  • script String or File, mandatory. The Python script to be executed.
  • version String, optional. The version of Julia to run.
  • install Sequence of strings, optional (default = empty). The commands to be executed prior to any Julia packages installation and script execution (to install libraries on the system).
  • libraries Sequence of strings, optional (default = empty). The name of Julia libraries that need to be installed before the script execution (note: as detailed below, installations are only achieved during the first execution of the script, and then stored in a docker image in cache. To force an update, use the forceUpdate argument).
  • forceUpdate Boolean, optional (default = false). Should the libraries installation be forced (to ensure an update for example). If true, the task will perform the installation (and thus the update) even if the library was already installed.

Embedding a Julia script 🔗

The toy Julia script for this test case is:
numericaloutput = arg * 2

write(open("output.txt","w"),string("Hello world from Julia #",arg))
We save this to hello.jl and upload it in your OpenMOLE workspace. You can then use the following script:
// Declare the variable
val arg = Val[Int]
val arg2 = Val[Double]
val numericaloutput = Val[Int]
val fileoutput = Val[File]

// julia task
val juliaTask =
  JuliaTask(workDirectory / "hello.jl") set (
    inputs += arg.mapped,
    inputs += arg2.mapped,
    outputs += arg,
    outputs += numericaloutput.mapped,
    outputs += fileoutput mapped "output.txt"

val copy = CopyFileHook(fileoutput, workDirectory / "result/hello${arg}.txt")
val env = LocalEnvironment(2)

  evaluation = juliaTask,
  sampling = (arg in (0 to 10)) x (arg2 is 2.0)
) hook copy on env
Notions from OpenMOLE are reused in this example. If you're not too familiar with Environments, Groupings, Hooks or Samplings, check the relevant sections of the documentation.