CodeEntropy.levels.execution.tasks module

Task and worker-side helpers for frame-chunk execution.

class CodeEntropy.levels.execution.tasks.CovarianceChunkPartial(force: dict[str, dict[~typing.Any, ~typing.Any]]=<factory>, torque: dict[str, dict[~typing.Any, ~typing.Any]]=<factory>, frame_counts: dict[str, dict[~typing.Any, int]]=<factory>, forcetorque: dict[str, dict[~typing.Any, ~typing.Any]]=<factory>, forcetorque_counts: dict[str, dict[~typing.Any, int]]=<factory>)[source]

Bases: object

Compact, mergeable covariance partial for one frame chunk.

force: dict[str, dict[Any, Any]]
forcetorque: dict[str, dict[Any, Any]]
forcetorque_counts: dict[str, dict[Any, int]]
frame_counts: dict[str, dict[Any, int]]
torque: dict[str, dict[Any, Any]]
class CodeEntropy.levels.execution.tasks.FrameChunkResult(chunk_index: int, covariance_partial: CovarianceChunkPartial, neighbor_totals: dict[int, int], neighbor_samples: dict[int, int], frame_indices: tuple[int, ...])[source]

Bases: object

MAP-stage output for a completed frame chunk.

chunk_index: int
covariance_partial: CovarianceChunkPartial
frame_indices: tuple[int, ...]
neighbor_samples: dict[int, int]
neighbor_totals: dict[int, int]
class CodeEntropy.levels.execution.tasks.FrameChunkTask(chunk_index: int, frame_indices: tuple[int, ...])[source]

Bases: object

MAP-stage input for a chunk of selected trajectory frames.

chunk_index: int
frame_indices: tuple[int, ...]
CodeEntropy.levels.execution.tasks.execute_frame_chunk_worker(task: FrameChunkTask, worker_shared_data: dict[str, Any], universe_operations: Any | None = None) FrameChunkResult[source]

Execute one frame chunk and return compact mergeable partials.

Parameters:
  • task – Frame chunk descriptor containing chunk index and selected frames.

  • worker_shared_data – Worker-visible shared workflow data.

  • universe_operations – Optional universe-operation adapter used to build the worker-local frame graph.

Returns:

A FrameChunkResult containing covariance partials, neighbour totals, neighbour sample counts, and processed frame indices.

Raises:

KeyError – If required worker shared-data keys are missing.

CodeEntropy.levels.execution.tasks.execute_frame_map_output(*, shared_data: dict[str, Any], frame_index: int, frame_dag: FrameGraph, neighbor_helper: Neighbors | None = None) dict[str, Any][source]

Execute all MAP operations for one frame in serial mode.

Parameters:
  • shared_data – Shared workflow data required by frame covariance and neighbour calculations.

  • frame_index – Frame index to execute.

  • frame_dag – Frame-local DAG used to compute covariance outputs.

  • neighbor_helper – Optional neighbour helper. A default Neighbors instance is created when omitted.

Returns:

A MAP output containing covariance and neighbors entries.

Raises:

KeyError – If required shared workflow keys are missing.

CodeEntropy.levels.execution.tasks.get_worker_frame_universe(worker_shared_data: dict[str, Any]) Any[source]

Return the universe object that should be used for frame-local work.

Parameters:

worker_shared_data – Worker-visible shared workflow data.

Returns:

The universe object to use for frame-local neighbour calculations.

Raises:

KeyError – If no usable universe is available.

CodeEntropy.levels.execution.tasks.incremental_mean_value(old: Any, new: Any, n: int) Any[source]

Update a worker-local running mean.

Parameters:
  • old – Existing running mean, or None for the first sample.

  • new – New sample to incorporate.

  • n – One-based sample count after adding new.

Returns:

The updated running mean value.

CodeEntropy.levels.execution.tasks.make_frame_worker_shared_data(shared_data: dict[str, Any]) dict[str, Any][source]

Build the worker-visible subset of shared workflow data.

Parameters:

shared_data – Full parent-side shared workflow data.

Returns:

A shallow copy excluding parent-owned accumulators, reporting objects, and Dask client state.

CodeEntropy.levels.execution.tasks.reduce_frame_covariance_into_partial(partial: CovarianceChunkPartial, frame_out: dict[str, Any]) None[source]

Reduce one frame covariance payload into a chunk partial.

Parameters:
  • partial – Worker-local covariance partial mutated in place.

  • frame_out – Frame covariance payload with force, torque, and optional force-torque sections.

Raises:

KeyError – If required force or torque sections are missing.