metric_catalog — metrics.yaml catalog + spec-field accessors
Purpose
The config/catalog owner for the analysis pipeline: loads the
metrics.yamlcatalog and exposes
every spec-field accessor (units, labels, summary/log flags, the{variable: spec}index).
Strictly not math — the layer that turns a spec object into report-facing fields.
Role in the system
- Split out of data_analyzer (Jun 18) so the math layer (data_analyzer
Reductions/Deltas/SignalAnalysis)
only ever reads fields off a spec object and never touches the YAML loaders. - Re-exported from data_analyzer for back-compat, so metric_alignment and lazy-load sites keep
importing these names unchanged. - Catalog itself is loaded via
pre_run_loader.MetricSpecLoader.load_metric_catalog(). metrics.yamlis the variable catalog (what is measured); judgment semantics (reduction, direction,
gate) live inscoreboard.yamlinstead — see orchestrator / the analysis pipeline contract.
Inputs / Outputs
- In: a metric
spec(Mapping,dataclass,Package, orRecursiveNamespace— all duck-typed),
or acatalog, or a loader. - Out: scalar spec fields (units, labels, bool flags), the catalog
specstuple, and the cached
{variable: spec}index.
Key functions
spec_field— read one field off a spec, duck-typed viaobject_fields—analysis/metric_catalog.py:24spec_units/spec_group_label/spec_summary_label— display units + report labels —:39/:44/:52spec_include_summary/spec_logged— bool flags with legacy-key fallbacks —:29/:34summary_group_for_spec— wrench/torque path routing for report grouping —:57catalog_specs— specs as a tuple (dict / namespace /specsfield) —:66catalog_by_key— lazily build + cache the{variable: spec}index —:76loaded_metric_catalog— load via a loader and attach the index —:86metric_catalog_smoke— zero-arg smoke (python -m analysis.metric_catalog) —:93
Footguns
Hardcoded path-segment routing in
summary_group_for_specThe wrench/torque grouping is decided by literal
"control_wrench"/"torque"checks against
spec.path, not by anything inmetrics.yaml. Fragile if the path structure changes.
(analysis/INSIGHTS.md[config] + Open questions)
Legacy-key fallbacks are silent
spec_include_summaryfalls back toinclude,spec_loggedtolog_desired,spec_unitsto
unit— older catalog specs keep working, but a typo’d new key silently takes the fallback rather
than failing loud. (analysis/INSIGHTS.md[config])
catalog_by_keymutates the catalogFirst call builds and caches
catalog.by_keyon the catalog object itself. One canonical builder
path keeps the index from being constructed inconsistently elsewhere. (analysis/INSIGHTS.md[config])
Related
data_analyzer · metric_alignment · statistics · orchestrator · terminology