hpcflow.sdk.core.actions.ElementActionRun#

class hpcflow.sdk.core.actions.ElementActionRun(id_, is_pending, element_action, index, data_idx, commands_idx, start_time, end_time, snapshot_start, snapshot_end, submission_idx, success, skip, exit_code, metadata, run_hostname)#

Bases: AppAware

The Element Action Run (EAR) is an atomic unit of an enacted workflow, representing one unit of work (e.g., particular submitted job to run a program) within that overall workflow. With looping over, say, parameter spaces, there may be many EARs per element.

Parameters:
  • id (int) – The ID of the EAR.

  • is_pending (bool) – Whether this EAR is pending.

  • element_action (ElementAction) – The particular element action that this is a run of.

  • index (int:) – The index of the run within the collection of runs.

  • data_idx (dict) – Used for looking up input data to the EAR.

  • commands_idx (list[int]) – Indices of commands to apply.

  • start_time (datetime) – Time of start of run, if the run has ever been started.

  • end_time (datetime) – Time of end of run, if the run has ever ended.

  • snapshot_start (dict) – Parameters for taking a snapshot of the data directory before the run. If unspecified, no snapshot will be taken.

  • snapshot_end (dict) – Parameters for taking a snapshot of the data directory after the run. If unspecified, no snapshot will be taken.

  • submission_idx (int) – What submission was this (if it has been submitted)?

  • success (bool) – Whether this EAR succeeded (if it has run).

  • skip (bool) – Whether this EAR was skipped.

  • exit_code (int) – The exit code, if known.

  • metadata (dict) – Metadata about the EAR.

  • run_hostname (str) – Where to run the EAR (if not locally).

  • id_ (int) –

Methods

compose_commands

Write the EAR's enactment to disk in preparation for submission.

get

Get a value (parameter, input, output, etc.) from the most recent iteration.

get_EAR_dependencies

Get EARs that this EAR depends on, or just their IDs.

get_IFG_input_values

Get a dict of input values that are to be passed via an input file generator.

get_OFP_inputs

Get a dict of input values that are to be passed to output file parsers.

get_OFP_output_files

Get a dict of output files that are going to be parsed to generate one or more outputs.

get_OFP_outputs

Get the outputs obtained by parsing an output file.

get_all_previous_iteration_runs

Get a list of run over all iterations that correspond to this run, optionally including this run.

get_data_idx

Get the data index of a value in the most recent iteration.

get_dependent_EARs

Get downstream EARs that depend on this EAR.

get_environment

What environment to run in?

get_environment_spec

What environment to run in?

get_input_dependencies

Get information about locally defined input, sequence, and schema-default values that this EAR depends on.

get_input_values

Get a dict of (optionally a subset of) inputs values for this run.

get_input_values_direct

Get a dict of input values that are to be passed directly to a Python script function.

get_parameter_names

Get parameter types associated with a given prefix.

get_parameter_sources

Get the source or sources of a parameter in the most recent iteration.

get_resources

Resolve specific resources for this EAR, considering all applicable scopes and template-level resources.

write_source

Write values to files in standard formats.

Attributes

action

The action this is a run of.

commands_idx

Indices of commands to apply.

data_idx

Used for looking up input data to the EAR.

dir_diff

The changes to the EAR working directory due to the execution of this EAR.

element

The element this is a run of.

element_action

The particular element action that this is a run of.

element_iteration

The iteration information of this run.

end_time

When the EAR finished.

env_spec

Environment details.

exit_code

The exit code of the underlying program run by the EAR, if known.

id_

The ID of the EAR.

index

Run index.

input_files

The input files to the controlled program.

inputs

The inputs to this EAR.

is_pending

Whether this EAR is pending.

metadata

Metadata about the EAR.

output_files

The output files from the controlled program.

outputs

The outputs from this EAR.

resources

The resources to use with (or used by) this EAR.

run_hostname

Where to run the EAR, if known/specified.

skip

Was the EAR skipped?

snapshot_end

The snapshot of the data directory at the end of the run.

snapshot_start

The snapshot of the data directory at the start of the run.

start_time

When the EAR started.

status

The state of this EAR.

submission_idx

What actual submission index was this?

success

Did the EAR succeed?

task

The task that this EAR is part of the implementation of.

workflow

The workflow this is a run of.

property action: Action#

The action this is a run of.

property commands_idx: Sequence[int]#

Indices of commands to apply.

compose_commands(jobscript, JS_action_idx)#

Write the EAR’s enactment to disk in preparation for submission.

Returns:

  • commands – List of argument words for the command that enacts the EAR. Converted to a string.

  • shell_vars – Dict whose keys are command indices, and whose values are lists of tuples, where each tuple contains: (parameter name, shell variable name, “stdout”/”stderr”).

Parameters:
Return type:

tuple[str, Mapping[int, Sequence[tuple[str, …]]]]

property data_idx: DataIndex#

Used for looking up input data to the EAR.

property dir_diff: DirectorySnapshotDiff | None#

The changes to the EAR working directory due to the execution of this EAR.

property element: Element#

The element this is a run of.

property element_action: ElementAction#

The particular element action that this is a run of.

property element_iteration: ElementIteration#

The iteration information of this run.

property end_time: datetime | None#

When the EAR finished.

property env_spec: Mapping[str, Any]#

Environment details.

property exit_code: int | None#

The exit code of the underlying program run by the EAR, if known.

get(path=None, default=None, raise_on_missing=False, raise_on_unset=False)#

Get a value (parameter, input, output, etc.) from the most recent iteration.

Parameters:
  • path (str | None) – Path to the value.

  • default (Any | None) – Default value to provide if value absent.

  • raise_on_missing (bool) – Whether to raise an exception on an absent value. If not, the default is returned.

  • raise_on_unset (bool) – Whether to raise an exception on an explicitly unset value. If not, the default is returned.

Return type:

Any

get_EAR_dependencies(as_objects: Literal[False] = False) set[int]#
get_EAR_dependencies(as_objects: Literal[True]) list[ElementActionRun]

Get EARs that this EAR depends on, or just their IDs.

get_IFG_input_values()#

Get a dict of input values that are to be passed via an input file generator.

Return type:

Mapping[str, Any]

get_OFP_inputs()#

Get a dict of input values that are to be passed to output file parsers.

Return type:

Mapping[str, str | list[str] | Mapping[str, Any]]

get_OFP_output_files()#

Get a dict of output files that are going to be parsed to generate one or more outputs.

Return type:

Mapping[str, Path]

get_OFP_outputs()#

Get the outputs obtained by parsing an output file.

Return type:

Mapping[str, str | list[str]]

get_all_previous_iteration_runs(include_self=True)#

Get a list of run over all iterations that correspond to this run, optionally including this run.

Parameters:

include_self (bool) –

Return type:

list[hpcflow.sdk.core.actions.ElementActionRun]

get_data_idx(path=None)#

Get the data index of a value in the most recent iteration.

Parameters:

path (str | None) – Path to the parameter.

Return type:

DataIndex

get_dependent_EARs(as_objects: Literal[False] = False) set[int]#
get_dependent_EARs(as_objects: Literal[True]) list[ElementActionRun]

Get downstream EARs that depend on this EAR.

get_environment()#

What environment to run in?

Return type:

Environment

get_environment_spec()#

What environment to run in?

Return type:

Mapping[str, Any]

get_input_dependencies()#

Get information about locally defined input, sequence, and schema-default values that this EAR depends on. Note this does not get values from this EAR’s task/schema, because the aim of this method is to help determine which upstream tasks this EAR depends on.

Return type:

Mapping[str, ParamSource]

get_input_values(inputs=None, label_dict=True)#

Get a dict of (optionally a subset of) inputs values for this run.

Parameters:
  • inputs (Sequence[str] | Mapping[str, Mapping[str, Any]] | None) – If specified, a list of input parameter types to include, or a dict whose keys are input parameter types to include. For schema inputs that have multiple=True, the input type should be labelled. If a dict is passed, and the key “all_iterations` is present and True, the return for that input will be structured to include values for all previous iterations.

  • label_dict (bool) – If True, arrange the values of schema inputs with multiple=True as a dict whose keys are the labels. If False, labels will be included in the top level keys.

Return type:

Mapping[str, Mapping[str, Any]]

get_input_values_direct(label_dict=True)#

Get a dict of input values that are to be passed directly to a Python script function.

Parameters:

label_dict (bool) –

Return type:

Mapping[str, Mapping[str, Any]]

get_parameter_names(prefix)#

Get parameter types associated with a given prefix.

For inputs, labels are ignored. See Action.get_parameter_names for more information.

Parameters:

prefix (str) – One of “inputs”, “outputs”, “input_files”, “output_files”.

Return type:

Sequence[str]

get_parameter_sources(*, path: str | None = None, typ: str | None = None, as_strings: Literal[False] = False, use_task_index: bool = False) Mapping[str, ParamSource | list[ParamSource]]#
get_parameter_sources(*, path: str | None = None, typ: str | None = None, as_strings: Literal[True], use_task_index: bool = False) Mapping[str, str]

Get the source or sources of a parameter in the most recent iteration.

Parameters:
  • path – Path to the parameter.

  • typ – The parameter type.

  • as_strings – Whether to return the result as human-readable strings.

  • use_task_index – Whether to use the task index.

get_resources()#

Resolve specific resources for this EAR, considering all applicable scopes and template-level resources.

Return type:

Mapping[str, Any]

property id_: int#

The ID of the EAR.

property index: int#

Run index.

property input_files: ElementInputFiles#

The input files to the controlled program.

property inputs: ElementInputs#

The inputs to this EAR.

property is_pending: bool#

Whether this EAR is pending.

property metadata: Mapping[str, Any]#

Metadata about the EAR.

property output_files: ElementOutputFiles#

The output files from the controlled program.

property outputs: ElementOutputs#

The outputs from this EAR.

property resources: ElementResources#

The resources to use with (or used by) this EAR.

property run_hostname: str | None#

Where to run the EAR, if known/specified.

property skip: bool#

Was the EAR skipped?

property snapshot_end: JSONLikeDirSnapShot | None#

The snapshot of the data directory at the end of the run.

property snapshot_start: JSONLikeDirSnapShot | None#

The snapshot of the data directory at the start of the run.

property start_time: datetime | None#

When the EAR started.

property status: EARStatus#

The state of this EAR.

property submission_idx: int | None#

What actual submission index was this?

property success: bool | None#

Did the EAR succeed?

property task: WorkflowTask#

The task that this EAR is part of the implementation of.

property workflow: Workflow#

The workflow this is a run of.

write_source(js_idx, js_act_idx)#

Write values to files in standard formats.

Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

Return type:

None