Implement parsing of commonly configured summary observations#13438
Implement parsing of commonly configured summary observations#13438SAKavli wants to merge 3 commits intoequinor:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13438 +/- ##
==========================================
- Coverage 89.97% 89.96% -0.01%
==========================================
Files 460 460
Lines 32409 32517 +108
==========================================
+ Hits 29160 29254 +94
- Misses 3249 3263 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
be7bd7e to
4f0d418
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for a new SUMMARY { ... } observation declaration that allows defining multiple SUMMARY_OBSERVATIONs from a CSV plus shared well-level settings (localization and optional breakthrough), integrating this into the existing observations parsing/validation pipeline.
Changes:
- Extend the observations grammar to parse a
SUMMARYblock with nestedWELL_NAME { ... }andBREAKTHROUGH { ... }. - Implement
SummaryObservation.from_common_config_dict(...)to expand the common config into concreteSummaryObservation(andBreakthroughObservation) instances. - Add unit tests verifying equivalence between common-config parsing and equivalent explicit observation declarations, plus a validation/error-labeling test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/ert/config/parsing/observations_parser.py |
Extends the observation grammar and transformer to recognize SUMMARY, WELL_NAME, and nested BREAKTHROUGH blocks. |
src/ert/config/_observations.py |
Expands SUMMARY common config into observation instances, adds CSV-column missing error helper, and factors localization shape registration into a helper. |
tests/ert/unit_tests/config/test_summary_config.py |
Refactors test helpers and adds tests for the new SUMMARY common configuration behavior and error surfacing. |
40f3b3c to
79b9656
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
Comments suppressed due to low confidence (1)
src/ert/config/parsing/observations_parser.py:109
- The "unknown observation type" error message is now triggered for both
TYPEandCOMMON_TYPE, but the message still only lists the legacy observation types. Update the message to includeSUMMARY(and consider includingBREAKTHROUGH_OBSERVATIONtoo) so users see the full set of accepted top-level keywords.
token=unexpected_token,
), ["COMMON_TYPE", "TYPE"]:
message = (
f"Unknown observation type '{unexpected_token}', "
f"expected either 'RFT_OBSERVATION', 'GENERAL_OBSERVATION', "
f"'SUMMARY_OBSERVATION' or 'HISTORY_OBSERVATION'."
)
bd7ea4d to
5df41ea
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/ert/config/parsing/observations_parser.py:109
- The "Unknown observation type" error message is now out of sync with the grammar: it still lists only RFT/GENERAL/SUMMARY_OBSERVATION/HISTORY_OBSERVATION, but the parser also accepts BREAKTHROUGH_OBSERVATION and the new SUMMARY common config. Updating this message would make validation errors accurate and less confusing.
message = (
f"Unknown observation type '{unexpected_token}', "
f"expected either 'RFT_OBSERVATION', 'GENERAL_OBSERVATION', "
f"'SUMMARY_OBSERVATION' or 'HISTORY_OBSERVATION'."
)
1996808 to
e8b8fa4
Compare
a99b64d to
31e009e
Compare
|
Should change "common" to "shared" configuration |
8b60810 to
c89fc07
Compare
c8b2e1d to
2fc76bd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
src/ert/config/parsing/observations_parser.py:108
- The unknown-observation-type error message is now out of sync with the grammar: SUMMARY shared blocks are valid and BREAKTHROUGH_OBSERVATION is also a supported TYPE, but the message only lists a subset. Update the message to include SUMMARY and BREAKTHROUGH_OBSERVATION (and any other supported types) so users get accurate guidance.
), ["SHARED_TYPE", "TYPE"]:
message = (
f"Unknown observation type '{unexpected_token}', "
f"expected either 'RFT_OBSERVATION', 'GENERAL_OBSERVATION', "
f"'SUMMARY_OBSERVATION' or 'HISTORY_OBSERVATION'."
dce2245 to
24df41c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/ert/config/parsing/observations_parser.py:109
- The "unknown observation type" parse error message is now triggered for both TYPE and SHARED_TYPE tokens, but the message does not mention the new "SUMMARY" shared-config keyword (and it also omits BREAKTHROUGH_OBSERVATION). This makes the validation error misleading when users mistype/encounter SUMMARY-related parsing issues. Update the expected-type list in the message to match the grammar/token expectations.
case UnexpectedToken(
token=unexpected_token,
), ["SHARED_TYPE", "TYPE"]:
message = (
f"Unknown observation type '{unexpected_token}', "
f"expected either 'RFT_OBSERVATION', 'GENERAL_OBSERVATION', "
f"'SUMMARY_OBSERVATION' or 'HISTORY_OBSERVATION'."
)
| validated_error = validate_positive_float( | ||
| row["error"], f"({summary_key}) ERROR", strictly_positive=True | ||
| ) | ||
| validated_value = validate_float(row["value"], f"({summary_key}) VALUE") | ||
| date = row["date"] |
There was a problem hiding this comment.
This should probably be fixed.
| BREAKTHROUGH allows the user to define a BREAKTHROUGH observations for | ||
| the given well. BREAKTHROUGH is configured like a regular | ||
| BREAKTHROUGH_OBSERVATION - which requires the fields KEY, THRESHOLD, DATE | ||
| and ERROR. BREAKTHROUGH will also inherit the LOCALIZATION values should | ||
| they be defined for the well. Only one occurrence of BREAKTHROUGH can | ||
| be configured per WELL. |
There was a problem hiding this comment.
This seems relevant :)
| csv_df = pl.read_csv( | ||
| csv_path, | ||
| encoding="utf-8", | ||
| ) |
There was a problem hiding this comment.
This should probably be fixed
| @given( | ||
| keyword=st.text( | ||
| min_size=1, | ||
| max_size=8, | ||
| alphabet=st.characters(categories=("L", "N", "P"), exclude_characters=","), | ||
| ) | ||
| ) | ||
| @pytest.mark.usefixtures("use_tmpdir") | ||
| def test_that_fully_populated_csv_does_not_crash_given_arbitrary_keyword(keyword): |
24df41c to
d29ee0a
Compare
| Shared configuration for summary observations | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Summary observations can also be created in bulk by the "SUMMARY" |
There was a problem hiding this comment.
Maybe using the word "bulk" instead of "Shared" throughout, makes this easier to understand.
| ObservationType.GENERAL: GeneralObservation, | ||
| ObservationType.RFT: RFTObservation, | ||
| ObservationType.BREAKTHROUGH: BreakthroughObservation, | ||
| ObservationType.SUMMARY_SHARED_CONFIG: SummaryObservation, |
There was a problem hiding this comment.
So maybe BULK_SUMMARY ?
eivindjahren
left a comment
There was a problem hiding this comment.
I mostly had comments about using "bulk" instead of "shared" for naming and also some of the errors noted by copilot needs to be adressed. Otherwise, this looks ready to go :)
This change will allow users to define summary observations in bulk, defined under a single well name sharing the well name and localization values. This change has one assumption that there is only one BREAKTHROUGH observation per well. This might need to be revisited. The naming of the WELL object should preferably be just WELL but it shadows the keyword of RFT observations WELL, so the well object name is currently named WELL_NAME for now.
d29ee0a to
04e79a5
Compare
This change will allow users to define summary observations in bulk, defined under a single well name sharing the well name and localization values.
This change has one assumption that there is only one BREAKTHROUGH observation per well. This might need to be revisited.
The naming of the WELL object should preferably be just WELL but it shadows the keyword of RFT observations WELL, so the well object name is currently named WELL_NAME for now.
Issue
Resolves #12943
All the summary observations in snake_oil can now have a shared configuration like:
With csv file:
Approach
Short description of the approach
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'just rapid-tests')When applicable