nipoppy.config.container¶
Container (i.e., Singularity/Apptainer) configuration model and utility functions.
Module Contents¶
- class nipoppy.config.container.ContainerConfig(/, **data)¶
Bases:
pydantic.BaseModelSchema for container configuration.
Does not include information about the container image.
- Parameters:
data (Any)
- model_config¶
- add_bind_path(path_local, path_inside_container=None, mode='rw')¶
Add a bind path.
- Parameters:
path_local (nipoppy.env.StrOrPathLike)
path_inside_container (Optional[nipoppy.env.StrOrPathLike])
mode (str)
- merge(other, overwrite_command=False)¶
Combine with another ContainerConfig instance.
By default this only changes arguments and environment variables, and no information is overwritten: - Arguments from other are appended to arguments of the current instance - Environment variables from other do not overwrite those of the current instance
If overwrite_command is True, the command of the current instance is replaced with that of the other instance.
- Parameters:
other (Any)
- class nipoppy.config.container.ContainerInfo(/, **data)¶
Bases:
pydantic.BaseModelSchema for container image (i.e., file) information.
- Parameters:
data (Any)
- FILE: pathlib.Path | None¶
- model_config¶
- class nipoppy.config.container.SchemaWithContainerConfig(/, **data)¶
Bases:
pydantic.BaseModelTo be inherited by configs that have a ContainerConfig sub-config.
- Parameters:
data (Any)
- CONTAINER_CONFIG: ContainerConfig¶
- get_container_config()¶
Return the pipeline’s ContainerConfig object.
- Return type:
- 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:
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:
- nipoppy.config.container.check_container_args(args, logger=None)¶
Check/fix bind flags in args.
- Parameters:
logger (Optional[logging.Logger])
- Return type:
- nipoppy.config.container.check_container_command(command)¶
Check that the command is available (i.e. in PATH).
- 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:
- nipoppy.config.container.set_container_env_vars(env_vars, logger=None)¶
Set environment variables for the container.
- Parameters:
logger (Optional[logging.Logger])
- Return type:
None
- nipoppy.config.container.APPTAINER_BIND_FLAG = '--bind'¶
- nipoppy.config.container.APPTAINER_BIND_SEP = ':'¶
- nipoppy.config.container.APPTAINER_ENVVAR_PREFIXES = ['APPTAINERENV_', 'SINGULARITYENV_']¶