coco_pipe.decoding.persistence#

Resumable decoding-run artifact utilities.

Attributes#

Functions#

resolve_primary_metric_name(available[, metrics])

Pick the primary metric name from available <metric>_mean columns.

stamp_primary_metric(record[, metrics])

Add primary_metric_name + primary_metric to a summary record in place.

redact_sensitive(value)

Recursively redact credentials before persisting configs or reports.

config_hash(config)

Return a stable short hash for a run configuration.

data_digest(*values)

Short SHA-256 over array-likes: dtype, shape and contents (None allowed).

make_serializable(obj)

Recursively convert NumPy types to JSON-safe Python primitives.

write_run_manifest(output_dir, manifest)

Write a unit's manifest in one step, so it is never seen half-written.

read_run_manifest(output_dir)

Return a unit's manifest, or None if the unit has not finished.

completed_for_config(output_dir, config)

Return whether output_dir contains a successful matching run.

load_completed_result_records(output_dir, context, *)

Rehydrate aggregate rows for a safely resumed experiment.

write_run_status(root, status)

Write exactly one run-level success, partial, or failure marker.

Module Contents#

coco_pipe.decoding.persistence.resolve_primary_metric_name(available, metrics=None)#

Pick the primary metric name from available <metric>_mean columns.

Preference order: balanced_accuracy (the group-robust default), then the first configured metric that has a _mean column, then the first available *_mean column. Returns None when no scalar metric column is present.

Parameters:
Return type:

str | None

coco_pipe.decoding.persistence.stamp_primary_metric(record, metrics=None)#

Add primary_metric_name + primary_metric to a summary record in place.

Keeps every downstream consumer (leaderboards, head-to-head, reports) on one metric contract instead of re-deriving it. No-op when the record carries no scalar *_mean metric column.

Parameters:
Return type:

dict[str, Any]

coco_pipe.decoding.persistence.redact_sensitive(value)#

Recursively redact credentials before persisting configs or reports.

Parameters:

value (Any)

Return type:

Any

coco_pipe.decoding.persistence.config_hash(config)#

Return a stable short hash for a run configuration.

Parameters:

config (collections.abc.Mapping[str, Any])

Return type:

str

coco_pipe.decoding.persistence.data_digest(*values)#

Short SHA-256 over array-likes: dtype, shape and contents (None allowed).

The decoding runner uses it for a unit’s input-data fingerprint (part of the resume hash) and for the sample-set signature paired comparisons must share.

Parameters:

values (Any)

Return type:

str

coco_pipe.decoding.persistence.RUN_MANIFEST_FILENAME = 'run_manifest.json'#
coco_pipe.decoding.persistence.make_serializable(obj)#

Recursively convert NumPy types to JSON-safe Python primitives.

Parameters:

obj (Any)

Return type:

Any

coco_pipe.decoding.persistence.write_run_manifest(output_dir, manifest)#

Write a unit’s manifest in one step, so it is never seen half-written.

Parameters:
Return type:

pathlib.Path

coco_pipe.decoding.persistence.read_run_manifest(output_dir)#

Return a unit’s manifest, or None if the unit has not finished.

Parameters:

output_dir (str | pathlib.Path)

Return type:

dict[str, Any] | None

coco_pipe.decoding.persistence.completed_for_config(output_dir, config)#

Return whether output_dir contains a successful matching run.

Parameters:
Return type:

bool

coco_pipe.decoding.persistence.load_completed_result_records(output_dir, context, *, metrics=None)#

Rehydrate aggregate rows for a safely resumed experiment.

Parameters:
Return type:

list[dict[str, Any]]

coco_pipe.decoding.persistence.write_run_status(root, status)#

Write exactly one run-level success, partial, or failure marker.

Parameters:
Return type:

pathlib.Path