Tasks sent on Qarnot's platform have several environment variables defined to adapt their behavior. Below is a list of the most useful ones.
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.
$INSTANCE_COUNT: the total number of instances in the task.$INSTANCE_ID: the ID of the current instance. E.g. for a task with N instances, it will range from 0 to N-1. IDs can also be controlled more precisely through ranges.These variables let you know some paths that can be useful.
$TASK_PATH: the working directory the command is started in.$QARNOT_RESOURCES_DIRECTORY: the path where all your resource data (i.e. the content of the resource buckets) will be available, by default /job.$QARNOT_RESULTS_DIRECTORY: all the files created in this directory will be uploaded to your result bucket, by default /job.$TMP_RAMFS_PATH: a path to a directory aimed at storing small temporary files in RAM. This is RAM cache, so it is very fast, however every file stored here will use some RAM that will not be available to your application.$TMP_PATH: a directory aimed at storing bigger temporary files. Contrary to $TMP_RAMFS_PATH, this is a network volume, so it will be slower, but you can store bigger files without impacting the amount of memory available to your application.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 whileDOCKER_CMD = 'sh -c "echo $INSTANCE_ID"'will do as intended.
Those variables might be useful if you want your task to query the Qarnot API, for example to start new tasks:
$QARNOT_TASK_UUID: the UUID of the Qarnot task.$QARNOT_COMPUTE_API_URL: the URL of the compute API the task was sent on.$QARNOT_STORAGE_API_URL: the URL of the storage API the task used.For more information on launching tasks please consult the following articles