nipoppy.config.container

Container (i.e., Singularity/Apptainer) configuration model and utility functions.

Classes

ContainerConfig

Schema for container configuration.

ContainerInfo

Schema for container image (i.e., file) information.

Module Contents

nipoppy.config.container.add_bind_path_to_args(args, path_local, path_inside_container=None, mode='rw')

Add a bind path to the container arguments.

Parameters:
  • args (list[str]) – Existing arguments

  • path_local (nipoppy.env.StrOrPathLike) – Path on disk. If this is a relative path or contains symlinks, it will be resolved

  • path_inside_container (Optional[nipoppy.env.StrOrPathLike], optional) – Path inside the container (if None, will be the same as the local path), by default None

  • mode (str, optional) – Read/write permissions. Only used if path_inside_container is given, by default “rw”

Returns:

The updated argument list

Return type:

list[str]

nipoppy.config.container.check_container_args(args, logger=None)

Check/fix bind flags in args.

Parameters:
Return type:

list[str]

nipoppy.config.container.check_container_command(command)

Check that the command is available (i.e. in PATH).

Parameters:

command (str)

Return type:

str

nipoppy.config.container.prepare_container(container_config, subcommand='run', check=True, logger=None)

Build the command for container and set environment variables.

Parameters:
  • container_config (ContainerConfig) – Config object

  • check (bool, optional) – Whether to validate config components and modify them if needed, by default True

  • logger (Optional[logging.Logger], optional) – Logger, by default None

  • subcommand (str)

Returns:

The command string

Return type:

str

nipoppy.config.container.set_container_env_vars(env_vars, logger=None)

Set environment variables for the container.

Parameters:
Return type:

None

nipoppy.config.container.APPTAINER_BIND_FLAG = '--bind'
nipoppy.config.container.APPTAINER_BIND_SEP = ':'
nipoppy.config.container.APPTAINER_ENVVAR_PREFIXES = ['APPTAINERENV_', 'SINGULARITYENV_']