feat(core): add kind, reference_id and typed presentation attrs to metric values#772
Conversation
…tric values
Establish the core metric-value contract that later work builds on, without
changing any provider output.
- Add a first-class `kind` ("model"/"reference") field to the core
`SeriesMetricValue` and `ScalarMetricValue` models, registered as a
controlled-vocabulary dimension so it becomes a faceted column.
- Add a `reference_id` content hash to series, computed and stored at ingest
for reference values, so identical observations deduplicate deterministically.
- Add typed, optional presentation fields (`value_units`, `value_long_name`,
`index_units`, `calendar`) on series, falling back to `attributes` when absent.
- Reject an unknown `kind` hard at ingest rather than warning.
- Add a migration for the `reference_id` column (`kind` auto-adds via the
existing CV dimension mechanism).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesMetricValueKind and reference_id
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 940a820e-5da4-4810-9387-f3eaefd387db
📒 Files selected for processing (9)
changelog/772.feature.mdpackages/climate-ref-core/src/climate_ref_core/metric_values/__init__.pypackages/climate-ref-core/src/climate_ref_core/metric_values/typing.pypackages/climate-ref-core/src/climate_ref_core/pycmec/cv_cmip7_aft.yamlpackages/climate-ref-core/tests/unit/metric_values/test_typing.pypackages/climate-ref/src/climate_ref/executor/result_handling.pypackages/climate-ref/src/climate_ref/migrations/versions/2026-06-30T0000_e5f6a7b8c9d0_add_reference_id.pypackages/climate-ref/src/climate_ref/models/metric_value.pypackages/climate-ref/tests/unit/executor/test_result_handling.py
…mn type - Omit the newly added series fields (`kind`, `reference_id`, and the typed presentation fields) from the serialised series.json when they are at their default, so a value that does not set them serialises identically to one from before the fields existed. This keeps the committed regression baselines valid without a re-mint (replay drift), while still serialising the fields when set. - Include `kind` in the deterministic series sort key, since it now identifies a value outside `dimensions`. - Declare the `reference_id` migration column as String to match the model, so the migrations-up-to-date check no longer reports a spurious type diff.
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Description
This establishes a way of distinguishing model and reference values and for carrying typed presentation metadata.
This PR adds:
kind("model"/"reference") field on theSeriesMetricValueandScalarMetricValue. It defaults to"model", so existing producers are unaffected.reference_idcontent hash on series, computed and stored at ingest for reference values, so an identical observation ingested by different executions deduplicates to the same id.value_units,value_long_name,index_units,calendar) that fall back to the existingattributesdict when absent. These stay optional until every provider emits them.kindat ingest.Adds a DB migration.
Checklist
Please confirm that this pull request has done the following:
changelog/Summary by CodeRabbit
New Features
Bug Fixes