Testing tools locally

Having the QMENTA SDK installed on images allows them to be launched locally without having to communicate with the platform. This is can useful to ease the development and debugging of new tools.

In order to do so, you can use this helper python script to test and debug basic tools in your local machine with a single command:

python test_sdk_tool.py my_namespace/my_image_name:v1.0 ./inputs_folder/ ./outputs_folder/

Note

The inputs folder expects one directory per input container. By default, since the input container is called “input”, files should go to ./inputs_folder/input/…

Advanced testing

In case you need to test tool parameters (see Parameters and Input Files), arbitrarily complex file structures or file properties (including modalities and tags) , you will need to enter two additional JSON files to the test script:

  • The settings file itself (the Settings configuration that is written when you add a new tool in the platform).

  • The values that the settings will have, following the JSON syntax shown below: where file containers are lists of files, and files are dictionaries with the mandatory field path, and the optional fields modality, tags, file_info.

Here you can see an example of a settings values file, with two input containers and two analysis parameters:

{
  "input_container_1": [
    {
      "path": "T1.zip",
      "modality": "T1"
    },
    {
      "path": "DICOM_FILES.zip",
      "file_info": {
        "metadata_field_1": 123,
        "metadata_field_2": "some_text"
      }
    },
    {
      "path": "some_other_file.txt",
      "tags": ["tag_1", "tag_2"],
    }
  ],
  "input_container_2": [
    {
      "path": "T1.zip",
      "modality": "T1"
    }
  ],
  "param_1": "abc",
  "param_2": 1.234
}

These files can be added to the configuration of the test by running instead:

python test_sdk_tool.py my_namespace/my_image_name:v1.0 ./inputs_folder/ ./outputs_folder/ \
     --settings /path/to/settings.json --values /path/to/values.json

Additionally, you can add more volumes or specify a different name for the tool script (that is, the Python module or file with the run method) with the following parameters:

python test_sdk_tool.py my_namespace/my_image_name:v1.0 ./inputs_folder/ ./outputs_folder/ \
    --settings /path/to/settings.json --values /path/to/values.json \
    --tool my_package.my_module -v /host/path:/container/path

Tip

If you wish to manually set a different entrypoint (other than /root/entrypoint.sh) you can do it by adding the argument –entrypoint and the path of the script inside the the tool image.