Use natsort to sort the produced csv rows from gather_summary_observations#13684
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13684 +/- ##
==========================================
- Coverage 89.39% 89.34% -0.05%
==========================================
Files 469 469
Lines 33406 33420 +14
==========================================
- Hits 29862 29859 -3
- Misses 3544 3561 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
|
c48332c to
517e58c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates convert_summary_observations (used by the gather_summary_observations CLI flow) to output CSV rows in a natural sort order (e.g., OP2, OP4, OP10, OP30) rather than preserving dict insertion order, addressing the ordering issue described in #13665.
Changes:
- Sort CSV output rows by summary key using
natsort.natsorted(...). - Add a unit test that asserts natural ordering of generated CSV rows for well keys containing numbers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ert/gather_summary_observations.py |
Iterate summary keys using natsorted(...) to produce naturally ordered CSV rows. |
tests/ert/unit_tests/cli/test_gather_summary_observations.py |
Add regression test verifying natural sort order in the produced CSV. |
Natsort is a transitive dependency of resdata, and should be an explicit dependency of ert when used in Ert code.
2618c13 to
44ca2e7
Compare
eivindjahren
approved these changes
Jun 4, 2026
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.
Issue
Resolves #13665
Approach
I believe this is ready to go unless I have misunderstood the prioritization of the sorting.
The code natsorts on the complete string, but perhaps it is more sensible to sort based on well names first, then summary keyword?