cwltool.singularity

Support for executing Docker format containers using Singularity {2,3}.x or Apptainer 1.x.

Module Contents

Classes

SingularityCommandLineJob

Commandline job using containers.

Functions

get_version()

Parse the output of 'singularity --version' to determine the flavor and version.

is_apptainer_1_or_newer()

Check if apptainer singularity distribution is version 1.0 or higher.

is_version_2_6()

Check if this singularity version is exactly version 2.6.

is_version_3_or_newer()

Check if this version is singularity version 3 or newer or equivalent.

is_version_3_1_or_newer()

Check if this version is singularity version 3.1 or newer or equivalent.

is_version_3_4_or_newer()

Detect if Singularity v3.4+ is available.

is_version_3_9_or_newer()

Detect if Singularity v3.9+ is available.

cwltool.singularity.get_version()

Parse the output of ‘singularity –version’ to determine the flavor and version.

Both pieces of information will be cached.

Returns:

A tuple containing: - A tuple with major and minor version numbers as integer. - A string with the name of the singularity flavor.

Return type:

Tuple[List[int], str]

cwltool.singularity.is_apptainer_1_or_newer()

Check if apptainer singularity distribution is version 1.0 or higher.

Apptainer v1.0.0 is compatible with SingularityCE 3.9.5. See: https://github.com/apptainer/apptainer/releases

Return type:

bool

cwltool.singularity.is_version_2_6()

Check if this singularity version is exactly version 2.6.

Also returns False if the flavor is not singularity or singularity-ce.

Return type:

bool

cwltool.singularity.is_version_3_or_newer()

Check if this version is singularity version 3 or newer or equivalent.

Return type:

bool

cwltool.singularity.is_version_3_1_or_newer()

Check if this version is singularity version 3.1 or newer or equivalent.

Return type:

bool

cwltool.singularity.is_version_3_4_or_newer()

Detect if Singularity v3.4+ is available.

Return type:

bool

cwltool.singularity.is_version_3_9_or_newer()

Detect if Singularity v3.9+ is available.

Return type:

bool

class cwltool.singularity.SingularityCommandLineJob(builder, joborder, make_path_mapper, requirements, hints, name)

Bases: cwltool.job.ContainerCommandLineJob

Inheritance diagram of cwltool.singularity.SingularityCommandLineJob

Commandline job using containers.

Parameters:
static get_image(dockerRequirement, pull_image, tmp_outdir_prefix, force_pull=False)

Acquire the software container image in the specified dockerRequirement.

Uses Singularity and returns the success as a bool. Updates the provided dockerRequirement with the specific dockerImageId to the full path of the local image, if found. Likewise the dockerRequirement[‘dockerPull’] is updated to a docker:// URI if needed.

Parameters:
  • dockerRequirement (Dict[str, str]) –

  • pull_image (bool) –

  • tmp_outdir_prefix (str) –

  • force_pull (bool) –

Return type:

bool

get_from_requirements(r, pull_image, force_pull, tmp_outdir_prefix)

Return the filename of the Singularity image.

(e.g. hello-world-latest.{img,sif}).

Parameters:
  • r (cwltool.utils.CWLObjectType) –

  • pull_image (bool) –

  • force_pull (bool) –

  • tmp_outdir_prefix (str) –

Return type:

Optional[str]

static append_volume(runtime, source, target, writable=False)

Add binding arguments to the runtime list.

Parameters:
  • runtime (List[str]) –

  • source (str) –

  • target (str) –

  • writable (bool) –

Return type:

None

add_file_or_directory_volume(runtime, volume, host_outdir_tgt)

Append volume a file/dir mapping to the runtime option list.

Parameters:
  • runtime (List[str]) –

  • volume (cwltool.pathmapper.MapperEnt) –

  • host_outdir_tgt (Optional[str]) –

Return type:

None

add_writable_file_volume(runtime, volume, host_outdir_tgt, tmpdir_prefix)

Append a writable file mapping to the runtime option list.

Parameters:
  • runtime (List[str]) –

  • volume (cwltool.pathmapper.MapperEnt) –

  • host_outdir_tgt (Optional[str]) –

  • tmpdir_prefix (str) –

Return type:

None

add_writable_directory_volume(runtime, volume, host_outdir_tgt, tmpdir_prefix)

Append a writable directory mapping to the runtime option list.

Parameters:
  • runtime (List[str]) –

  • volume (cwltool.pathmapper.MapperEnt) –

  • host_outdir_tgt (Optional[str]) –

  • tmpdir_prefix (str) –

Return type:

None

create_runtime(env, runtime_context)

Return the Singularity runtime list of commands and options.

Parameters:
Return type:

Tuple[List[str], Optional[str]]