Skip to content

Fix/cmip7 use metadata not cmip6 tables#261

Draft
JanStreffing wants to merge 6 commits intoprep-releasefrom
fix/cmip7-use-metadata-not-cmip6-tables
Draft

Fix/cmip7 use metadata not cmip6 tables#261
JanStreffing wants to merge 6 commits intoprep-releasefrom
fix/cmip7-use-metadata-not-cmip6-tables

Conversation

@JanStreffing
Copy link
Copy Markdown
Contributor

@JanStreffing JanStreffing commented Mar 30, 2026

Refactor CMIP7 to use native compound name architecture

- Index variables by full compound name instead of cmip6_table
- Implement exact compound name matching for CMIP7 (find_matching_rule_cmip7)
- Generate synthetic table headers from variable metadata
- Remove dependency on cmip6_table field for CMIP7 data loading
- Add comprehensive unit tests for synthetic header generation
- Maintain full backward compatibility with CMIP6 and existing CMIP7 metadata

merge after #257

The entry_points() API changed between Python 3.9 and 3.10:
- Python 3.9: entry_points() returns dict-like object
- Python 3.10+: entry_points(group='name') with keyword argument

Use try/except to detect the API version at runtime.

Fixes TypeError: entry_points() got an unexpected keyword argument 'group'
…6_table-based approach

- Use user-specified CMIP7_DReq_metadata file for DataRequest loading
- Fix cmip6_cmor_table -> cmip6_table key mismatch in table.py
- Extract table IDs from cmip6_table values not compound name prefix
- Add warning when rules have no matching data_request_variables
- Add debug logging to find_matching_rule for troubleshooting

This partially addresses the architectural issue where CMIP7 is forced
into CMIP6's table-based structure. Full compound name matching still
needs implementation (see CMIP7_ARCHITECTURE_ISSUE.md).

Fixes silent failure where rules were dropped with no user feedback.
Add step-by-step failure scenario showing:
- Silent failure symptoms
- Root cause discovery process (3 layered bugs)
- Log output at each debugging stage
- Key symptoms and workarounds
The branch fixes immediate bugs (silent failure, config ignored) but
architectural issues persist (cmip6_table dependency, partial matching).
- Index variables by full compound name instead of cmip6_table
- Implement exact compound name matching for CMIP7 (find_matching_rule_cmip7)
- Generate synthetic table headers from variable metadata
- Remove dependency on cmip6_table field for CMIP7 data loading
- Add comprehensive unit tests for synthetic header generation
- Maintain full backward compatibility with CMIP6 and existing CMIP7 metadata

Resolves critical AttributeError for table_header in CMIP7 processing.
Addresses architectural issues identified in CMIP7_ARCHITECTURE_ISSUE.md.

Tests: 15 passed, 1 skipped
@JanStreffing JanStreffing self-assigned this Mar 30, 2026
@JanStreffing JanStreffing added the enhancement New feature or request label Mar 30, 2026
@JanStreffing JanStreffing changed the base branch from main to prep-release March 30, 2026 11:33

table_ids = set(
v.get("cmip6_cmor_table") for v in all_var_info["Compound Name"].values() if v.get("cmip6_cmor_table")
v.get("cmip6_table") for v in all_var_info["Compound Name"].values() if v.get("cmip6_table")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMIP7 DataRequest Implementation Relies on CMIP6 Backward Compatibility Fields

1 participant