Skip to content

Implement parsing of commonly configured summary observations#13438

Open
SAKavli wants to merge 3 commits intoequinor:mainfrom
SAKavli:add-common-summary-configuration
Open

Implement parsing of commonly configured summary observations#13438
SAKavli wants to merge 3 commits intoequinor:mainfrom
SAKavli:add-common-summary-configuration

Conversation

@SAKavli
Copy link
Copy Markdown
Contributor

@SAKavli SAKavli commented Apr 29, 2026

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:

SUMMARY {
    VALUES = summary_values.csv;
    WELL OP1 {
        LOCALIZATION {
            EAST = 10;
            NORTH = 20;
            RADIUS = 2000;
        };
    };
};

With csv file:

well, keyword, value, error, date
OP1, WOPR, 0.1, 0.05, 2010-03-31
OP1, WOPR, 0.7, 0.07, 2010-12-26
OP1, WOPR, 0.5, 0.05, 2011-12-21
OP1, WOPR, 0.3, 0.075, 2012-12-15
OP1, WOPR, 0.2, 0.035, 2013-12-10
OP1, WOPR, 0.015, 0.01, 2015-03-15

Approach
Short description of the approach

(Screenshot of new behavior in GUI if applicable)

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

@SAKavli SAKavli added the release-notes:new-feature Automatically categorise as new feature in release notes label Apr 29, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 92.92035% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.96%. Comparing base (eb7925e) to head (d29ee0a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/ert/config/_observations.py 91.57% 8 Missing ⚠️
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     
Flag Coverage Δ
cli-tests 37.02% <32.74%> (-0.03%) ⬇️
fuzz 43.97% <26.54%> (-0.06%) ⬇️
gui-tests 66.45% <32.74%> (-0.05%) ⬇️
performance-and-unit-tests 78.02% <92.92%> (+0.03%) ⬆️
test 45.62% <25.66%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/ert/config/parsing/observations_parser.py 93.63% <100.00%> (+1.16%) ⬆️
src/ert/config/_observations.py 94.83% <91.57%> (-0.77%) ⬇️

... and 2 files with indirect coverage changes

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 29, 2026

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing SAKavli:add-common-summary-configuration (d29ee0a) with main (15b1b96)

Open in CodSpeed

@SAKavli SAKavli force-pushed the add-common-summary-configuration branch from be7bd7e to 4f0d418 Compare April 29, 2026 10:04
@SAKavli SAKavli requested a review from Copilot April 29, 2026 10:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SUMMARY block with nested WELL_NAME { ... } and BREAKTHROUGH { ... }.
  • Implement SummaryObservation.from_common_config_dict(...) to expand the common config into concrete SummaryObservation (and BreakthroughObservation) 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.

Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 3 times, most recently from 40f3b3c to 79b9656 Compare April 30, 2026 12:00
@SAKavli SAKavli requested a review from Copilot April 30, 2026 12:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TYPE and COMMON_TYPE, but the message still only lists the legacy observation types. Update the message to include SUMMARY (and consider including BREAKTHROUGH_OBSERVATION too) 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'."
                )

Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/parsing/observations_parser.py
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 7 times, most recently from bd7ea4d to 5df41ea Compare April 30, 2026 14:28
@SAKavli SAKavli requested a review from Copilot April 30, 2026 14:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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'."
                )

Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py Outdated
Comment thread src/ert/config/_observations.py
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 8 times, most recently from 1996808 to e8b8fa4 Compare May 4, 2026 12:40
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 4 times, most recently from a99b64d to 31e009e Compare May 5, 2026 12:07
@SAKavli
Copy link
Copy Markdown
Contributor Author

SAKavli commented May 5, 2026

Should change "common" to "shared" configuration

@SAKavli SAKavli force-pushed the add-common-summary-configuration branch from 8b60810 to c89fc07 Compare May 8, 2026 08:40
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 5 times, most recently from c8b2e1d to 2fc76bd Compare May 8, 2026 10:21
@SAKavli SAKavli requested a review from Copilot May 8, 2026 10:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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'."

Comment thread src/ert/config/parsing/observations_parser.py
Comment thread src/ert/config/_observations.py Outdated
Comment thread docs/ert/reference/configuration/observations.rst Outdated
Comment thread tests/ert/unit_tests/config/test_bulk_summary_config.py
Comment thread tests/ert/unit_tests/config/test_bulk_summary_config.py
Comment thread docs/ert/reference/configuration/observations.rst Outdated
Comment thread docs/ert/reference/configuration/observations.rst Outdated
Comment thread src/ert/config/_observations.py Outdated
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch 2 times, most recently from dce2245 to 24df41c Compare May 8, 2026 11:52
@SAKavli SAKavli requested a review from Copilot May 8, 2026 11:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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'."
                )

Comment on lines +324 to +328
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"]
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.

This should probably be fixed.

Comment on lines +259 to +264
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.
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.

This seems relevant :)

Comment thread docs/ert/reference/configuration/observations.rst
Comment on lines +228 to +231
csv_df = pl.read_csv(
csv_path,
encoding="utf-8",
)
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.

This should probably be fixed

Comment on lines +453 to +461
@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):
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch from 24df41c to d29ee0a Compare May 8, 2026 12:20
Shared configuration for summary observations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Summary observations can also be created in bulk by the "SUMMARY"
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.

Maybe using the word "bulk" instead of "Shared" throughout, makes this easier to understand.

Comment thread src/ert/config/_observations.py Outdated
ObservationType.GENERAL: GeneralObservation,
ObservationType.RFT: RFTObservation,
ObservationType.BREAKTHROUGH: BreakthroughObservation,
ObservationType.SUMMARY_SHARED_CONFIG: SummaryObservation,
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.

So maybe BULK_SUMMARY ?

Copy link
Copy Markdown
Contributor

@eivindjahren eivindjahren left a comment

Choose a reason for hiding this comment

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

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 :)

SAKavli added 2 commits May 8, 2026 15:55
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.
@SAKavli SAKavli force-pushed the add-common-summary-configuration branch from d29ee0a to 04e79a5 Compare May 8, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes:new-feature Automatically categorise as new feature in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it possible to add common configuration options for summary observations

4 participants