hpcflow.sdk.core.loop_cache.LoopCache#

class hpcflow.sdk.core.loop_cache.LoopCache(element_dependents, elements, zeroth_iters, data_idx, iterations, task_iterations, run_meta, task_element_IDs, element_iteration_IDs, iteration_run_IDs, run_data_idx, run_pending, param_EAR_ID)#

Bases: object

Class to store a cache for use in Workflow.add_empty_loop() and WorkflowLoop.add_iterations(). Use build() to get a new instance.

Parameters:
  • element_dependents (dict[int, dict[int, DependentDescriptor]]) – Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element’s element set.

  • elements (dict[int, ElementDescriptor]) – Keys are element IDs, values are dicts with keys: input_statuses, input_sources, and task_insert_ID.

  • zeroth_iters (dict[int, tuple[int, DataIndex]]) – Keys are element IDs, values are data associated with the zeroth iteration of that element, namely a tuple of iteration ID and ElementIteration.data_idx.

  • data_idx (dict[int, dict[LoopIndex[str, int], DataIndex]]) – Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().

  • iterations (dict[int, tuple[int, int]]) – Keys are iteration IDs, values are tuples of element ID and iteration index within that element.

  • task_iterations (dict[int, list[int]]) – Keys are task insert IDs, values are list of all iteration IDs associated with that task.

  • run_meta (dict[int, tuple[int, int]]) – Keys are run IDs, values are tuples of the task insert ID and element ID of that run.

  • task_element_IDs (dict[int, list[int]])

  • element_iteration_IDs (dict[int, list[int]])

  • iteration_run_IDs (dict[int, list[int]])

  • run_data_idx (dict[int, DataIndex])

  • run_pending (dict[int, bool])

  • param_EAR_ID (dict[int, int])

Methods

add_iteration

Update the cache to include a newly added iteration.

build

Build a cache of data for use in adding loops and iterations.

get_iter_IDs

Retrieve a list of iteration IDs belonging to a given loop.

get_iter_loop_indices

Retrieve the mapping from element to loop index for each given iteration.

get_latest_data_idx

Get the data index of the most recently added iteration of an element.

update_loop_indices

Set the loop indices for a named loop to the given list of iteration IDs.

Attributes

element_dependents

Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element's element set.

elements

input_statuses, input_sources, and task_insert_ID.

zeroth_iters

Keys are element IDs, values are data associated with the zeroth iteration of that element, namely a tuple of iteration ID and ElementIteration.data_idx.

data_idx

Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().

iterations

Keys are iteration IDs, values are tuples of element ID and iteration index within that element.

task_iterations

Keys are task insert IDs, values are list of all iteration IDs associated with that task.

run_meta

Keys are run IDs, values are tuples of the task insert ID and element ID of that run.

task_element_IDs

Keys are task ID, values are element IDs.

element_iteration_IDs

Keys are element IDs, values are iteration IDs.

iteration_run_IDs

run_data_idx

run_pending

param_EAR_ID

add_iteration(iter_ID, task_insert_ID, element_ID, loop_idx, data_idx)#

Update the cache to include a newly added iteration.

Parameters:
classmethod build(workflow, loops=None)#

Build a cache of data for use in adding loops and iterations.

Parameters:
Return type:

Self

data_idx: dict[int, dict[LoopIndex[str, int], DataIndex]]#

Keys are element IDs, values are data associated with all iterations of that element, namely a dict whose keys are the iteration loop index as a tuple, and whose values are data indices via ElementIteration.get_data_idx().

element_dependents: dict[int, dict[int, DependentDescriptor]]#

Keys are element IDs, values are dicts whose keys are element IDs that depend on the key element ID (via Element.get_dependent_elements_recursively), and whose values are dicts with keys: group_names, which is a tuple of the string group names associated with the dependent element’s element set.

element_iteration_IDs: dict[int, list[int]]#

Keys are element IDs, values are iteration IDs.

elements: dict[int, ElementDescriptor]#

input_statuses, input_sources, and task_insert_ID.

Type:

Keys are element IDs, values are dicts with keys

get_iter_IDs(loop)#

Retrieve a list of iteration IDs belonging to a given loop.

Parameters:

loop (Loop)

Return type:

list[int]

get_iter_loop_indices(iter_IDs)#

Retrieve the mapping from element to loop index for each given iteration.

Parameters:

iter_IDs (list[int])

Return type:

Sequence[Mapping[str, int]]

get_latest_data_idx(element_ID)#

Get the data index of the most recently added iteration of an element.

Parameters:

element_ID (int)

Return type:

DataIndex

iteration_run_IDs: dict[int, list[int]]#
iterations: dict[int, tuple[int, int]]#

Keys are iteration IDs, values are tuples of element ID and iteration index within that element.

param_EAR_ID: dict[int, int]#
run_data_idx: dict[int, DataIndex]#
run_meta: dict[int, tuple[int, int]]#

Keys are run IDs, values are tuples of the task insert ID and element ID of that run. Only immutable data is stored here, because run objects retrieved at cache build time would hold stale parent elements/iterations once new iterations are added.

run_pending: dict[int, bool]#
task_element_IDs: dict[int, list[int]]#

Keys are task ID, values are element IDs.

task_iterations: dict[int, list[int]]#

Keys are task insert IDs, values are list of all iteration IDs associated with that task.

update_loop_indices(new_loop_name, iter_IDs)#

Set the loop indices for a named loop to the given list of iteration IDs.

Parameters:
Return type:

None

zeroth_iters: dict[int, tuple[int, DataIndex]]#

Keys are element IDs, values are data associated with the zeroth iteration of that element, namely a tuple of iteration ID and ElementIteration.data_idx.