cloudos_cli.utils.environment_variables

Parsing and validation of Nextflow runtime environment variables (e.g. NXF_SYNTAX_PARSER).

Functions

merge_environment_variables(original, overrides)

Merge environment variable overrides into the ones of an existing job.

parse_environment_variables(environment_variable)

Parse 'NAME=VALUE' strings into the job payload format.

validate_environment_variables(...[, ...])

Check environment variables against the supported allowlist before submitting a job.

cloudos_cli.utils.environment_variables.merge_environment_variables(original, overrides)[source]

Merge environment variable overrides into the ones of an existing job.

A variable in overrides replaces the one with the same name in original; new names are added at the end. Both arguments are lists of {‘name’, ‘value’} dicts.

cloudos_cli.utils.environment_variables.parse_environment_variables(environment_variable)[source]

Parse ‘NAME=VALUE’ strings into the job payload format.

Parameters:

environment_variable (tuple, list or str) – Environment variables in the form (‘NXF_SYNTAX_PARSER=v2’, …). A single string is accepted as one variable.

Returns:

A list of {‘name’: NAME, ‘value’: VALUE} dicts, in the given order.

Return type:

list

Raises:

ValueError – If a variable is not in the form NAME=VALUE, a name is repeated or there are more than MAX_NEXTFLOW_ENVIRONMENT_VARIABLES variables.

cloudos_cli.utils.environment_variables.validate_environment_variables(environment_variables, nextflow_version, workflow_type='nextflow', execution_platform='aws', version_note=None, is_module=False)[source]

Check environment variables against the supported allowlist before submitting a job.

Mirrors the api-server validation: only Nextflow jobs, only allowlisted names, only allowed values and only on Nextflow versions that support the variable.

Parameters:
  • environment_variables (list) – A list of {‘name’: NAME, ‘value’: VALUE} dicts, as returned by parse_environment_variables.

  • nextflow_version (str) – The Nextflow version of the job. ‘latest’ is resolved for the execution platform.

  • workflow_type (str) – The workflow type: ‘nextflow’, ‘wdl’ or ‘docker’.

  • execution_platform (str) – The execution platform: ‘aws’, ‘azure’ or ‘hpc’.

  • version_note (str, optional) – Extra sentence added to the error when the Nextflow version is too old, e.g. to explain that the version is a default.

  • is_module (bool) – Whether the workflow is a Lifebit Platform Workflow. Platform Workflows always run with a fixed Nextflow version, so environment variables can’t be used with them.

Raises:

ValueError – With a message explaining what is wrong and how to fix it.