ska_sdp_e2e_batch_continuum_imaging.pipelines.environment module

class ska_sdp_e2e_batch_continuum_imaging.pipelines.environment.EnvironmentContext[source]

Bases: object

Class deals with environment context detection for the pipeline.

static is_multinode()[source]

Determine if the current execution environment is multinode.

Return type:

bool

Returns:

True if running in a multinode environment, False otherwise.

static slurm_job_id()[source]

Return job id of the slurm job if running inside a slurm resource allocation, else return None.

Return type:

str | None

static slurm_nodes()[source]

Return total number of nodes in a slurm resource allocation, else return 1.

Return type:

int

ska_sdp_e2e_batch_continuum_imaging.pipelines.environment.use_env_vars(env)[source]

Temporarily updates the environment variables within a context.

This function is intended to be used as a context manager. It updates the current process's environment variables with the provided dictionary for the duration of the context, and restores the original environment afterwards.

Parameters:

env (dict) -- A dictionary of environment variables to set temporarily.

Yields:

None -- Control is yielded to the context block.

Examples

>>> with use_env_vars({'MY_VAR': 'value'}):
...     # 'MY_VAR' is set within this block
...     pass
# 'MY_VAR' is removed/restored to its previous value after the block
ska_sdp_e2e_batch_continuum_imaging.pipelines.environment.filter_invalid(env_vars)[source]

Filter out environment variables with None values.

Parameters:

env_vars (dict) -- A dictionary of environment variables.

Returns:

A filtered dictionary with only valid environment variables.

Return type:

dict