src.environment_manager module

Classes which setup software dependencies for the PODs and which execute the PODs’ code.

class src.environment_manager.AbstractEnvironmentManager(log=<Logger>)[source]

Bases: abc.ABC

Abstract interface for EnvironmentManagers.

setup()[source]
abstract create_environment(env_name)[source]
abstract get_pod_env(pod)[source]
abstract activate_env_commands(env_name)[source]
abstract deactivate_env_commands(env_name)[source]
abstract destroy_environment(env_name)[source]
tear_down()[source]
class src.environment_manager.NullEnvironmentManager(log=<Logger>)[source]

Bases: src.environment_manager.AbstractEnvironmentManager

EnvironmentManager which performs no environment switching. Useful only as a dummy setting for building framework test harnesses.

create_environment(env_name)[source]
destroy_environment(env_name)[source]
get_pod_env(pod)[source]
activate_env_commands(env_name)[source]
deactivate_env_commands(env_name)[source]
setup()
tear_down()
class src.environment_manager.VirtualenvEnvironmentManager(log=<Logger>)[source]

Bases: src.environment_manager.AbstractEnvironmentManager

AbstractEnvironmentManager that manages dependencies assuming that current versions of the scripting language executables are already available on $PATH. For python-based PODs, it uses pip and virtualenvs to install needed libraries. For R-based PODs, it attempts to install needed libraries into the current user’s $PATH. For other scripting languages, no library management is performed.

create_environment(env_key)[source]
destroy_environment(env_key)[source]
get_pod_env(pod)[source]
activate_env_commands(env_key)[source]
deactivate_env_commands(env_key)[source]
setup()
tear_down()
class src.environment_manager.CondaEnvironmentManager(log=<Logger>)[source]

Bases: src.environment_manager.AbstractEnvironmentManager

AbstractEnvironmentManager that uses the conda package manager to define and switch runtime environments.

env_name_prefix = '_MDTF_'
create_environment(env_name)[source]
create_all_environments()[source]
destroy_environment(env_name)[source]
get_pod_env(pod)[source]
activate_env_commands(env_name)[source]

Source conda_init.sh to set things that aren’t set b/c we aren’t in an interactive shell.

deactivate_env_commands(env_name)[source]
setup()
tear_down()
class src.environment_manager.AbstractRuntimeManager[source]

Bases: abc.ABC

Interface for RuntimeManagers.

abstract setup()[source]
abstract run()[source]
abstract tear_down()[source]
__init__()

Initialize self. See help(type(self)) for accurate signature.

class src.environment_manager.SubprocessRuntimePODWrapper(pod: Any = sentinel.Mandatory, env: Any = None, env_vars: dict = <factory>)[source]

Bases: object

Wrapper for diagnostic.Diagnostic that adds fields and methods used by SubprocessRuntimeManager.

pod: Any = sentinel.Mandatory
env: Any = None
env_vars: dict
process: Any = None
pre_run_setup()[source]
setup_env_vars()[source]
setup_exception_handler(exc)[source]
run_commands()[source]

Produces the shell command(s) to run the POD.

run_msg()[source]

Log message when execution starts.

validate_commands()[source]

Produces the shell command(s) to validate the POD’s runtime environment (ie, check for all requested third-party module dependencies.) Dependencies are passed as arguments to the shell script src/validate_environment.sh, which is invoked in the POD’s subprocess before the POD is run.

Returns

Command-line invocation to validate the POD’s

runtime environment.

Return type

(str)

runtime_exception_handler(exc)[source]
tear_down(retcode=None)[source]
__init__(pod: Any = sentinel.Mandatory, env: Any = None, env_vars: dict = <factory>)None

Initialize self. See help(type(self)) for accurate signature.

__post_init__(*args, **kwargs)
class src.environment_manager.SubprocessRuntimeManager(case, EnvMgrClass)[source]

Bases: src.environment_manager.AbstractRuntimeManager

RuntimeManager that spawns a separate system subprocess for each POD.

iter_active_pods()[source]

Generator iterating over all wrapped pods which haven’t been skipped due to requirement errors.

setup()[source]
spawn_subprocess(p, env_vars_base)[source]
run()[source]
tear_down()[source]
runtime_terminate(signum=None, frame=None)[source]