- Notion d'algorithme interchangeable
- Limitation
- algo_recipe.json format
- algo_recipe.json format
- Command field and variables expansion
This is the documentation on how to create a switchable algorithm for the Lola platform.
Notion d'algorithme interchangeable
A switchable algorithm is an algorithm that can be used in one or more scenarios.
Above is an example of the use of switchable algorithms in a typical scenario. The switchable algorithms on the right can be used or not on the scenario.
A switchable algorithm must be hosted on an accessible git repository. The repository must contain at least one algo_recipe.json file in the correct format.
The algorithm and its dependencies are to be deposited on the platform as a docker image. The image is placed on the harbor platform.
Note: An algorithm is dependent on the scenario to which it is attached. It is therefore necessary to take into account the inputs/outputs of the scenario before writing the algorithm.
Limitation
On the platform, algorithms will be runned in a docker container without network access. All dependencies must be in the container at runtime.
algo_recipe.json format
filename: algo_recipe.json
type: File
required: YES
Path: Root of the algorithm project
The algo_recipe.json
file must be located at the root of the git repository. It contains the global information of the algorithm. It is in JSON format and is easily editable.
algo_recipe.json format
There is an example of algo_recipe.json:
{
"name": "SuperModel",
"description": "Algorithm to build a super model",
"command": "super_model.py --number-factors {{ n_factors }} --input-xapi {{ INPUT_DATA }} --output-model {{ OUTPUT_DATA }}",
"harbor_url": "lola.lhs.loria.fr:4443/foo/super_model:latest",
"parameters": [
{
"name": "input data file",
"description": "input data file",
"variable_name": "INPUT_DATA",
"type": "input_file_1",
"editable": false
},
{
"name": "output data file",
"description": "output data file",
"variable_name": "OUTPUT_DATA",
"type": "output_file_1",
"editable": false
},
{
"name": "n factors",
"description": "n factors",
"variable_name": "n_factors",
"type": "float",
"editable": true,
"default": "20"
},
{
"name": "Color picker",
"description": "Choose a color in the list",
"variable_name": "color_picker",
"type": "choices",
"choices": ["red", "blue", "black", "green"]
"editable": true,
"default": "green"
}
]
}
- name : Name of the algorithm
- description : Short description on what the algorithm does.
- harbor_url : URL of the docker image used to run the algorithm.
-
command : Command to run the program. This field can contain variable in the format of jinja2 template. Variable interpolations must match
variable_name
used in parameters section. See Command field and variable expansion -
parameters: This is a list of parameters that can be used and tuned during the scenario launch. Theses variables will be used in the
command
field for expansion.- name : Name of the parameter
- description : Short description of the parameter
- variable_name : Used for variable interpolation in the command and during the generation of nextflow files.
-
type : Type of the variable. Can be:
-
classic parameters
-
integer
: integer value -
float
: float value -
string
: string value -
bool
: boolean value. true/false -
choices
: special type. Used with choices field (see below)
-
-
special parameters
-
input_file_XX
: To indicate the parameter is an input file. It will be used in the generation of nextflow file. Replace XX by a number (started by 1). -
output_file_XX
: Indicate the parameter is an output file. It will be used in the generation of nextflow file. Replace XX by a number (started by 1). -
input_nf_XX
: Indicate the parameter is an input file managed by scenario builder and not by the user. It will be used in the generation of nextflow file. Replace XX by a number (started by 1).
-
-
classic parameters
Command field and variables expansion
The command field is a jinja2 template field containing the command to be used to run the algorithm in its docker image. The command should not contain docker parameters but only information about the algorithm. The variables to be extended are to be put between {{
and }}
. There are two different types of variables:
-
The classic parameters manipulated by the user (strings, numbers, floats, ...). These parameters are defined in the
parameters
parts of the algo_recipe.json file. -
The input/output parameters. These parameters should be with option
"editable": false
. The user cannot edit these options. Thetype
to use is the one provided in the scenario template that the algorithm is to replace. For example, with the followinguser_model.nf.j2
template:#!/usr/bin/env nextflow process userModel { container = "{{ docker_image }}" input: path input_file_1 output: path output_file_1, emit: user_model """ {{ command }} """ }
The variable to user for the input file is `input_file_1` and the variable for output file is `output_file_1` comme sur l'exemple présenté [algo_recipe.json](#algo_recipe.json-format).