Skip to content

ECC-2317: Improve parsing comma-separated arguments - #533

Merged
joobog merged 4 commits into
developfrom
bugfix/ecc-2317_parse_commas_in_gridspec_json
Aug 31, 2026
Merged

ECC-2317: Improve parsing comma-separated arguments#533
joobog merged 4 commits into
developfrom
bugfix/ecc-2317_parse_commas_in_gridspec_json

Conversation

@joobog

@joobog joobog commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Description

This pull request addresses parsing improvements in the parse_keyval_string function to handle comma-separated values that may include nested JSON-like structures. It also introduces a new regression test to ensure correct behavior for this case and updates the test suite to include the new test.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@joobog joobog added the approved-for-ci Approved to run CI on ECMWF machines label Aug 28, 2026
Comment thread tests/grib_ecc-2317.sh Outdated
tempGrib=temp.$label.grib
sample_grib2=$ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl

${tools_dir}/grib_set -s gridSpec='{grid:[0.5,0.5]}' ${sample_grib2} $tempGrib

@sawom666 sawom666 Aug 28, 2026

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.

Another test should be added which combines the two forms separated by commas
e.g.,

grib_set -s year=1994,gridSpec='{blah,blah,etc}',month=5  in out

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That’s a good point! Otherwise, the test wouldn’t be complete.

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.

Also check what we just set actually went through,

grib_check_key_equals out month 5
grib_check_key_equals out year 1994

etc

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.

And also the grid increment changes should be checked ( as a result of setting gridSpec key )
:)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For gridSpec, we’re adding a new systematic test. We’ll cover it there. Thanks a lot for improving the test!

Comment thread tests/grib_ecc-2317.sh

grib_check_key_equals $tempGrib month 1
grib_check_key_equals $tempGrib year 1983
grib_check_key_equals $tempGrib gridSpec '{"area":[20,0,0,20],"grid":[10,10]}'

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.

Beautiful 👍

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.22%. Comparing base (e3694ee) to head (9a05acb).

Files with missing lines Patch % Lines
src/eccodes/grib_util.cc 83.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #533      +/-   ##
===========================================
- Coverage    88.22%   88.22%   -0.01%     
===========================================
  Files          854      854              
  Lines        63553    63559       +6     
  Branches     11290    11293       +3     
===========================================
+ Hits         56071    56075       +4     
- Misses        7482     7484       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joobog
joobog merged commit ce948df into develop Aug 31, 2026
460 of 461 checks passed
@joobog
joobog deleted the bugfix/ecc-2317_parse_commas_in_gridspec_json branch August 31, 2026 09:14
joobog added a commit that referenced this pull request Aug 31, 2026
* ECC-2317: Add JSON parsing test

* ECC-2317: Split args on commas, but skipt commas inside {} and []

* ECC-2317: Improve test by add more arguments

* ECC-2317: Check if all parameters are set correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Approved to run CI on ECMWF machines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants