Preview for "Inspect" (in python) for Singularity

by vs
GNU/Linux ◆ xterm-256color ◆ bash 1421 views

More notes can be found in the README for the python API:

Inspect

Inspect will return (print to the screen, or stdout) a json data structure with the fields asked for by the user, specifically which can be in the set defined in inspect.help.

-l/--labels      Show the labels associated with the image (default)
-d/--deffile     Show the bootstrap definition file which was used
                 to generate this image
-r/--runscript   Show the runscript for this image
-t/--test        Show the test script for this image
-e/--environment Show the environment settings for this container

The bash client handles parsing these command line arguments into the following environment variables that are exported, and found by python:

SINGULARITY_MOUNTPOINT
SINGULARITY_INSPECT_LABELS
SINGULARITY_INSPECT_DEFFILE
SINGULARITY_INSPECT_RUNSCRIPT
SINGULARITY_INSPECT_TEST
SINGULARITY_INSPECT_ENVIRONMENT

Essentially, if any of the above for SINGULARITY_INSPECT_* are found to be defined, this is interpreted as “yes/True.” Otherwise, if the environment variable is not defined, python finds it as None and doesn’t do anything. In this manner, we can call the executable as follows (e.g., from inspect.sh).

eval_abort "$SINGULARITY_libexecdir/singularity/python/helpers/json/inspect.py"

and the python will look for the environmental variables specified above. This is different from the other json functions (below) that expect different parameters to be passed into the script call.

More by vs

See all