CodeEntropy.levels.execution.policy module

Internal policy for hierarchy-level frame map-reduce execution.

Users provide compute resources. CodeEntropy keeps scheduling choices such as chunk size and in-flight task limits internal so the public configuration remains stable and simple.

class CodeEntropy.levels.execution.policy.ExecutionPolicy(target_frame_chunks_per_worker: int = 2, min_frame_chunk_size: int = 1, max_frame_chunk_size: int = 32, max_frame_in_flight_multiplier: int = 1)[source]

Bases: object

Internal policy for scalable, deterministic frame execution.

frame_chunk_size(shared_data: dict[str, Any], *, n_frames: int) int[source]

Choose a deterministic frame chunk size.

Parameters:
  • shared_data – Shared workflow data used to infer requested worker count.

  • n_frames – Number of selected frames for the current run.

Returns:

The frame chunk size clamped between the policy minimum and maximum.

max_frame_chunk_size: int = 32
max_frame_in_flight_multiplier: int = 1
max_frame_in_flight_tasks(shared_data: dict[str, Any], *, n_chunks: int) int[source]

Choose the maximum number of active frame-chunk tasks.

Parameters:
  • shared_data – Shared workflow data used to infer requested worker count.

  • n_chunks – Number of frame chunks available for submission.

Returns:

The number of frame-chunk tasks allowed to be active at once.

min_frame_chunk_size: int = 1
requested_worker_count(shared_data: dict[str, Any]) int[source]

Return the requested worker-process count.

Parameters:

shared_data – Shared workflow data that may contain args with local Dask or HPC worker settings.

Returns:

The requested worker count, clamped to at least one.

target_frame_chunks_per_worker: int = 2