Plug your Julia model

Suggest edits
Documentation > Plug

Content:

1 - JuliaTask syntax
2 - Embedding a Julia script


JuliaTask syntax 🔗

Preliminary remarks 🔗

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 supports files and directories, in and out. Get some help on how to handle it by reading this page.
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.
  • prepare Sequence of strings, optional (default = empty). System commands to be executed just before to the execution of Julia on the execution node.

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 env = LocalEnvironment(2)

DirectSampling(
  evaluation = juliaTask,
  sampling = (arg in (0 to 10)) x (arg2 is 2.0)
) hook (workDirectory / "result") 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.