Skip to content

feat: Add CMIP7 lazy loading and finalisation support#571

Merged
lewisjared merged 11 commits into
mainfrom
cmip7-finalised
Mar 1, 2026
Merged

feat: Add CMIP7 lazy loading and finalisation support#571
lewisjared merged 11 commits into
mainfrom
cmip7-finalised

Conversation

@lewisjared

@lewisjared lewisjared commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Description

Add lazy loading (DRS + complete parser) and finalisation support for CMIP7 datasets, mirroring the existing CMIP6 pattern via the shared FinaliseableDatasetAdapterMixin.

Key changes

Source:

  • Add cmip7_parsers.py with DRS and complete parsing functions for CMIP7 files
  • Extract shared finalisation logic into FinaliseableDatasetAdapterMixin in mixins.py, used by both CMIP6 and CMIP7 adapters
  • Refactor cmip6.py and cmip6_parsers.py to use the shared mixin, removing duplicated code
  • Rework cmip7.py to use the shared mixin for lazy loading and finalisation
  • Add cmip7_parser config option and version filtering support
  • Add utility functions in datasets/utils.py and datasets/netcdf_utils.py
  • Remove realm from diagnostic data requirement filtering

Tests:

  • Add shared parameterised test suite (test_cmip_adapters.py) covering adapter basics, parser dispatch, finalisation edge cases, and persist logic for both CMIP6 and CMIP7
  • Add integration test suite (test_adapter_integration.py) covering local dataset discovery, round-trip database persistence, and end-to-end finalisation for both adapters
  • Refactor test_cmip6.py and test_cmip7.py to remove duplicated tests now covered by shared suites

Other:

  • Fix version filtering in regression analysis
  • Update regression test outputs

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

@codecov

codecov Bot commented Feb 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ges/climate-ref/src/climate_ref/datasets/mixins.py 95.58% 1 Missing and 2 partials ⚠️
...ages/climate-ref/src/climate_ref/datasets/cmip7.py 90.90% 0 Missing and 2 partials ⚠️
...mate-ref/src/climate_ref/datasets/cmip7_parsers.py 96.22% 2 Missing ⚠️
...ages/climate-ref/src/climate_ref/datasets/utils.py 93.10% 1 Missing and 1 partial ⚠️
...kages/climate-ref/src/climate_ref/datasets/base.py 90.90% 0 Missing and 1 partial ⚠️
Flag Coverage Δ
core 93.26% <95.12%> (+0.03%) ⬆️
providers 89.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ol/diagnostics/climate_at_global_warming_levels.py 94.23% <ø> (ø)
...esmvaltool/diagnostics/climate_drivers_for_fire.py 85.36% <ø> (ø)
..._esmvaltool/diagnostics/cloud_radiative_effects.py 100.00% <ø> (ø)
...e_ref_esmvaltool/diagnostics/cloud_scatterplots.py 92.55% <ø> (ø)
...tool/src/climate_ref_esmvaltool/diagnostics/ecs.py 82.69% <ø> (ø)
...ool/src/climate_ref_esmvaltool/diagnostics/enso.py 100.00% <ø> (ø)
...valtool/diagnostics/regional_historical_changes.py 95.53% <ø> (ø)
...e_ref_esmvaltool/diagnostics/sea_ice_area_basic.py 100.00% <ø> (ø)
..._ref_esmvaltool/diagnostics/sea_ice_sensitivity.py 81.96% <ø> (ø)
...tool/src/climate_ref_esmvaltool/diagnostics/tcr.py 100.00% <ø> (ø)
... and 14 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CMIP7 two-phase parsing (DRS bootstrap + complete finalisation) and consolidates shared finalisation logic so CMIP6 and CMIP7 follow the same lazy-loading/finalisation pattern via FinaliseableDatasetAdapterMixin.

Changes:

  • Introduces CMIP7 DRS and complete parsers and wires CMIP7 adapter to support lazy finalisation.
  • Extracts shared finalisation + DB persistence logic into FinaliseableDatasetAdapterMixin, refactoring CMIP6/CMIP7 adapters to use it.
  • Expands dataset utilities (version extraction, DRS daterange parsing, time metadata reads) and adds shared/unit + integration tests for both adapters.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/climate-ref/tests/unit/test_config.py Adds cmip7_parser to default-config expectations.
packages/climate-ref/tests/unit/datasets/test_utils.py Adds tests for new utils (extract_version_from_path, parse_drs_daterange, parse_datetime).
packages/climate-ref/tests/unit/datasets/test_netcdf_utils.py Adds coverage for new read_time_metadata().
packages/climate-ref/tests/unit/datasets/test_cmip_adapters.py New shared parameterised unit tests for CMIP6/CMIP7 adapters + mixin finalisation behavior.
packages/climate-ref/tests/unit/datasets/test_cmip7.py Refactors CMIP7 unit tests to use new parser functions and shared coverage.
packages/climate-ref/tests/unit/datasets/test_cmip6.py Removes duplicated CMIP6 tests now covered by shared suites; keeps CMIP6-specific tests.
packages/climate-ref/tests/unit/datasets/conftest.py Removes CMIP6-only cached catalog fixture (now covered elsewhere).
packages/climate-ref/tests/integration/datasets/test_adapter_integration.py New integration tests for discovery, DB round-trips, and finalisation for both adapters.
packages/climate-ref/tests/integration/datasets/conftest.py Integration fixtures to parameterise over adapters and parsers.
packages/climate-ref/src/climate_ref/datasets/utils.py Adds extract_version_from_path() and parse_drs_daterange() utilities.
packages/climate-ref/src/climate_ref/datasets/netcdf_utils.py Adds read_time_metadata() helper.
packages/climate-ref/src/climate_ref/datasets/mixins.py Introduces FinaliseableDatasetAdapterMixin implementation incl. DB persistence.
packages/climate-ref/src/climate_ref/datasets/cmip7_parsers.py New CMIP7 DRS + complete parsing implementations.
packages/climate-ref/src/climate_ref/datasets/cmip7.py Refactors CMIP7 adapter to use mixin and parser dispatch (cmip7_parser).
packages/climate-ref/src/climate_ref/datasets/cmip6_parsers.py Reuses shared version/date-range utilities; removes duplicated daterange parsing.
packages/climate-ref/src/climate_ref/datasets/cmip6.py Refactors CMIP6 adapter to use mixin for finalisation.
packages/climate-ref/src/climate_ref/config.py Adds cmip7_parser configuration option.
packages/climate-ref/conftest.py Adds CMIP7 converted-file fixture and shared adapter test configuration/fixtures.
packages/climate-ref-pmp/src/climate_ref_pmp/diagnostics/variability_modes.py Removes realm facet from requirements.
packages/climate-ref-pmp/src/climate_ref_pmp/diagnostics/enso.py Removes realm facet from requirements.
packages/climate-ref-pmp/src/climate_ref_pmp/diagnostics/annual_cycle.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/zec.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/tcre.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/tcr.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/sea_ice_sensitivity.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/sea_ice_area_basic.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/regional_historical_changes.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/enso.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/ecs.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/cloud_scatterplots.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/cloud_radiative_effects.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/climate_drivers_for_fire.py Removes realm facet from requirements.
packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/diagnostics/climate_at_global_warming_levels.py Removes realm facet from requirements.
changelog/571.improvement.md Notes shared finalisation logic extraction.
changelog/571.feature.md Notes CMIP7 lazy loading + finalisation feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/climate-ref/src/climate_ref/datasets/mixins.py Outdated
Comment thread packages/climate-ref/src/climate_ref/datasets/cmip7_parsers.py Outdated
@lewisjared lewisjared merged commit 5445cf8 into main Mar 1, 2026
26 checks passed
@lewisjared lewisjared deleted the cmip7-finalised branch March 1, 2026 02:38
lewisjared added a commit that referenced this pull request Mar 1, 2026
* origin/main: (40 commits)
  chore: read mandatory variables
  fix: Better handling of nan values
  docs: Update documenation about DRS parser
  docs: changelog update
  fix: correct the order of the constraints
  chore: add changelog entries for PR #571
  chore: Clean up CMIP6 and CMIP7 test overlap
  chore: refactor tests
  chore: update tests
  chore: remove realm from filtering
  feat: Add CMIP7 lazy loading
  chore: Fix regression outputs
  chore: changelog
  fix: apply version filtering to the regression analysis
  chore: Use variable_name
  chore: fix pre-commit
  add change log
  rename double_ITCZ to doubleITCZ for consistency in output file naming
  chore: add test case for double ITCZ
  chore(deps-dev): bump jupyterlab in the python-dependencies group
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants