Using environment variables

Execution environment

Tasks sent on Qarnot's platform have several environment variables defined to adapt their behavior. Below is a list of the most useful ones.

Instance variables

These variables allow you to know how many instances are in the task and which instance number you are in.

For example, for a task with several instances, you can select the data to work with depending on the instance number. E.g. if you want to run a computation with 10 different values of a parameter, you can launch a task with 10 instances and the list of values as a constant. Then, the instance number can be used to retrieve the value of the parameter.

Path variables

These variables let you know some paths that can be useful.

Constants

In addition to the above-mentioned variables set by the API, all the constants specified in the task (whether they are defined in the profile or not) end up as environment variables. Learn more on this topic in the Choosing the right profile and Parameterizing a profile with constants pages.

If you want to use variables in your command, it is recommended to explicitly run a shell. For instance, DOCKER_CMD = "echo $INSTANCE_ID" might not work as expected while DOCKER_CMD = 'sh -c "echo $INSTANCE_ID"' will do as intended.

Qarnot API variables

Those variables might be useful if you want your task to query the Qarnot API, for example to start new tasks:

Related Article

For more information on launching tasks please consult the following articles