cotainr.cli module#

cotainr - a user space Apptainer/Singularity container builder.

Copyright DeiC, deic.dk Licensed under the European Union Public License (EUPL) 1.2 - see the LICENSE file for details.

This module implements the command line main command and subcommands.

Classes#

CotainrSubcommand(ABC)

Abstract base class for CotainrCLI subcommands.

Build(CotainrSubcommand)

Build a container. (The “build” subcommand.)

CotainrCLI

Build Apptainer/Singularity containers for HPC systems in user space. (The main CLI command.)

Info(CotainrSubcommand)

Obtain info about the state of all required dependencies for building a container. (The “info” subcommand.)

Functions#

main(*args, **kwargs)

Main CLI entrypoint.

API reference#

class cotainr.cli.Build(*, image_path, base_image=None, conda_env=None, system=None, accept_licenses=False, verbosity=0, log_to_file=False, no_color=False)#

Bases: CotainrSubcommand

Build a container.

The “build” subcommand.

Parameters:
image_pathos.PathLike

Path to the built container image.

base_imagestr

Base image to use for the container which may be any valid Apptainer/Singularity <BUILD SPEC>.

conda_envos.PathLike, optional

Path to a Conda environment.yml file to install and activate in the container. When installing a Conda environment, you must accept the Miniforge license terms, as specified during the build process.

systemstr

Which system/partition you will be running the container on. This sets base image and other parameters for a simpler container creation. Running the info command will tell you more about the system and what is available.

accept_licensesbool, default=False

Accept all license terms (if any) needed for completing the container build process.

verbosityint, optional

The verbosity of the output from cotainr: -1 for only CRITICAL, 0 (the default) for cotainr INFO and subprocess WARNING, 1 for subprocess output as well, 2 for subprocess INFO, 3 for DEBUG, and 4 for TRACE.

log_to_filebool

Create files containing all logging information shown on stdout/stderr.

no_colorbool

Do not use colored console output.

Methods

add_arguments(*, parser)

Add arguments to the "build" subcommand subparser.

execute()

Execute the "build" subcommand.

classmethod add_arguments(*, parser)#

Add arguments to the “build” subcommand subparser.

execute()#

Execute the “build” subcommand.

class cotainr.cli.CotainrCLI(*, args=None)#

Bases: object

Build Apptainer/Singularity containers for HPC systems in user space.

The main cotainr CLI command.

Parameters:
argslist of str, optional

The input arguments to the CLI (the default is None, which implies that the input arguments are taken from sys.argv).

Attributes:
argstypes.SimpleNamespace

The namespace holding the converted arguments parsed to the CLI.

subcommandCotainrSubcommand

The subcommand to run.

class cotainr.cli.CotainrSubcommand#

Bases: ABC

Abstract base class for CotainrCLI subcommands.

Methods

add_arguments(*, parser)

Add command line arguments to arguments parser.

execute()

Execute the subcommand.

classmethod add_arguments(*, parser)#

Add command line arguments to arguments parser.

Parameters:
parserargparse.ArgumentParser

The argument parser to add arguments to.

abstract execute()#

Execute the subcommand.

class cotainr.cli.Info#

Bases: CotainrSubcommand

Obtain info about the state of all required dependencies for building a container.

The “info” subcommand.

Methods

add_arguments(*, parser)

Add command line arguments to arguments parser.

execute()

Execute the "info" subcommand.

execute()#

Execute the “info” subcommand.

cotainr.cli.main(*args, **kwargs)#

Construct the main CLI entrypoint.