fre.cmor: harden branded-variable disambiguations#832
Draft
Conversation
…rors, input guard
- Replace fragile split('_') brand extraction with prefix-based startswith()
matching in cmor_mixer.py to handle target variables containing underscores
and prevent IndexError on non-branded MIP table entries
- Add informative ValueError message (was bare ValueError) when no brands
match dimension count, including the target var, dim count, and available
branded entries
- Improve filter_brands() error messages to include input data properties
(has_time_bnds, input_vert_dim), candidate brands, and actionable guidance
for both 'all eliminated' and 'multiple remain' error paths
- Add input guard in filter_brands() for empty brands list
- Add tests: empty brands list, error message property assertions
Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/aef8d820-d1d3-4c34-8e54-15da812d8e42
Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/aef8d820-d1d3-4c34-8e54-15da812d8e42 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Harden branded-variable disambiguations
harden branded-variable disambiguations in fre.cmor
Apr 3, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #832 +/- ##
=======================================
Coverage 84.12% 84.12%
=======================================
Files 71 71
Lines 4944 4952 +8
=======================================
+ Hits 4159 4166 +7
- Misses 785 786 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
fre.cmor: harden branded-variable disambiguations
This was referenced Apr 7, 2026
Member
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Brand extraction used
split('_')indexing, which breaks whentarget_varcontains underscores and raisesIndexErroron non-branded MIP entries. Error messages on disambiguation failure were either empty (bareValueError) or lacked the context needed to diagnose the problem.Brand extraction (
cmor_mixer.py):mip_var.split('_')[0]/[1]withstartswith(target_var + '_')+ prefix stripping_)ValueError→ message with target var, dim count, available branded entriesDisambiguation errors (
cmor_helpers.pyfilter_brands()):has_time_bnds,input_vert_dim, candidate brands, and actionable guidanceTests (
test_cmor_helpers.py):test_filter_brands_empty_brands_listtest_filter_brands_all_eliminated_message_contains_propertiestest_filter_brands_multiple_remain_message_contains_propertiesIssue ticket number and link (if applicable)
Checklist before requesting a review