Skip to content

Profiling types

cutana.profiling_types

Shared, dependency-free dataclasses for profiling / per-worker introspection.

These types live in their own module (with no other cutana imports) so any component -- orchestrator, workers, benchmark scripts -- can depend on them without risking an import cycle (issue #312).

Stage

Canonical names of the profiled pipeline stages.

These are the step keys PerformanceProfiler records and the labels ContextProfiler is given. Defining them here -- in the dependency-free shared module -- means workers, the profiler and the benchmark scripts all agree on one set of names instead of each repeating string literals (#312). Add a stage here (and to :data:COMPUTE_STAGES if a source passes through it) whenever a new ContextProfiler block is introduced.

WorkerInfo(process_id, batch_index, n_sources, pool_slot, start_time, end_time=None, sources_per_fits_set=None, performance=None) dataclass

Per-worker detail surfaced by StreamingOrchestrator.get_worker_info (#354).

Spawn-time fields are set when the worker is started; the remaining fields are filled in from the worker's complete message. Defining every field here means all consumers know up front what they can read and write.

Attributes:

Name Type Description
process_id str

Worker process identifier.

batch_index int

Index into the orchestrator's internal batch ranges.

n_sources int

Number of sources assigned to this worker.

pool_slot int

Shared-memory pool slot index assigned to the worker.

start_time float

Spawn time (epoch seconds).

end_time Optional[float]

Completion time (epoch seconds); None while still running.

sources_per_fits_set Optional[Dict[str, int]]

Source count keyed by FITS-set signature (a string, since this crosses the worker→parent JSON boundary), e.g. {"VIS.fits, NIR-H.fits": 30}. None until completion. Both the distinct-set count (len) and the per-set distribution (.values()) derive from this, and keying by the set lets callers spot several workers hitting the same FITS sets.

performance Optional[Dict[str, Any]]

Per-stage PerformanceProfiler.get_statistics() output (None until completion, or if the worker raised before reporting).

merge_completion(batch_info)

Fill completion-time fields from a worker's batch_info dict.

Only keys actually present are copied, so a worker that raised before its performance summary was assembled still merges whatever it did report.

Parameters:

Name Type Description Default
batch_info Dict[str, Any]

The batch_info payload from the worker's complete message.

required