Skip to content

Migrate timemap/refcase dependent observations#12629

Merged
yngve-sk merged 4 commits intoequinor:mainfrom
yngve-sk:26.01.remove-history-obs-with-utility
Jan 20, 2026
Merged

Migrate timemap/refcase dependent observations#12629
yngve-sk merged 4 commits intoequinor:mainfrom
yngve-sk:26.01.remove-history-obs-with-utility

Conversation

@yngve-sk
Copy link
Contributor

@yngve-sk yngve-sk commented Jan 13, 2026

(Goes with equinor/semeio#862)

Overview of changes

  • Remove REFCASE, TIME_MAP, and HISTORY_OBSERVATION from ERT
  • Add tool to migrate older ERT configs so that information from REFCASE and TIME_MAP is embedded into the obs config
  • GENERAL_OBSERVATION can now only be used with RESTART, usage of DATE, HOURS, DAYS can be migrated if there is a REFCASE or TIME_MAP in the ERT config.
  • SUMMARY_OBSERVATION can now only be used with DATE, usage of RESTART, HOURS, DAYS can be migrated if there is a REFCASE or TIME_MAP in the ERT config.

Nice to know:

  • Tests that were previously testing now deprecated behaviors have been kept by shimming the obs config migration into the test.
  • Removed test case and logic for asserting that a SUMMARY_OBSERVATION's date matches up with the refcase / time map (this will be hard to pick up in migration, so suggest just dropping it)

Issue
Resolves #12619

Residual (IDEALLY NON BLOCKING) issues/TODOs
Recommend resolving before next release:

Should def be fixed:

  • Move validations/errors wrt observations parsing from _create_observation_dataframes.py to _observations.py. Will likely fix this in the following PR where *Observations are converted to BaseModel objs, opening up for moving validations there (instead of doing the the dataclasses.dataclass way now) Move validations/errors wrt observations parsing #12680

Not urgent:

Copy link

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

This PR introduces a migration tool to convert deprecated HISTORY_OBSERVATION to SUMMARY_OBSERVATION and remove dependencies on TIME_MAP and REFCASE from observation configurations. The tool aims to help users migrate away from deprecated features as part of issue #12619.

Changes:

  • Adds new ert_config_migrations.py module with observation migration logic
  • Adds convert_observations CLI command to __main__.py

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 18 comments.

File Description
src/ert/config/ert_config_migrations.py New module implementing observation migration logic including text editing, observation conversion, and configuration parsing
src/ert/main.py Adds CLI subcommand convert_observations to invoke the migration tool

@SAKavli SAKavli force-pushed the 26.01.remove-history-obs-with-utility branch 2 times, most recently from cd74709 to d486212 Compare January 13, 2026 12:22
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch 7 times, most recently from b71c665 to 5acb06d Compare January 14, 2026 13:04
@yngve-sk yngve-sk changed the title Migrate timemap/refacse depdendent observations Migrate timemap/refcase depdendent observations Jan 14, 2026
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch 7 times, most recently from 5ec12c5 to 2a46e17 Compare January 15, 2026 06:58
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 94.63519% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.63%. Comparing base (7238d60) to head (029718f).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/ert/config/observation_config_migrations.py 94.08% 23 Missing ⚠️
src/ert/config/_observations.py 93.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12629      +/-   ##
==========================================
- Coverage   90.66%   90.63%   -0.04%     
==========================================
  Files         430      431       +1     
  Lines       29814    30067     +253     
==========================================
+ Hits        27032    27252     +220     
- Misses       2782     2815      +33     
Flag Coverage Δ
cli-tests 37.33% <30.90%> (-0.27%) ⬇️
gui-tests 68.72% <32.61%> (-0.63%) ⬇️
performance-and-unit-tests 74.05% <92.91%> (+0.10%) ⬆️
test 37.57% <3.21%> (-0.49%) ⬇️

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

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 15, 2026

Merging this PR will not alter performance

✅ 22 untouched benchmarks


Comparing yngve-sk:26.01.remove-history-obs-with-utility (029718f) with main (7238d60)

Open in CodSpeed

@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch 3 times, most recently from 900c0e0 to 8bdce57 Compare January 16, 2026 07:27
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from 8bdce57 to e81be7b Compare January 16, 2026 07:29
@oyvindeide oyvindeide requested a review from Copilot January 18, 2026 20:39
@yngve-sk yngve-sk self-assigned this Jan 19, 2026
@yngve-sk yngve-sk added the release-notes:breaking-change Automatically categorise as breaking change in release notes label Jan 19, 2026
@oyvindeide
Copy link
Collaborator

Can do if that is most ideal? Was not sure whether we should do an inline edit to the ert config and not only the obs config. In the case that someone wants to add a new history obs, and then migrate it, removal of time map / refcase would block that.

Think that should be covered by tests, and it should be removed from snake_oil as that no longer has HISTORY_OBSERVATION.

@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch 3 times, most recently from 195008b to 38f4b1f Compare January 20, 2026 07:37
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from d9c193b to a4b65dc Compare January 20, 2026 09:29
Copy link
Contributor

@berland berland left a comment

Choose a reason for hiding this comment

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

I say let's go!

@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from a4b65dc to 38f4b1f Compare January 20, 2026 11:00
Copy link
Collaborator

@oyvindeide oyvindeide left a comment

Choose a reason for hiding this comment

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

Nice! Just some minor comments

{
VALUE = 0.9;
DATE = 2014-09-10;
KEY = FOPR;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor comment, but the KEY should be GOPR:FIELD and the name of the observation something else.

setattr(
date_dict, str(key).lower(), validate_positive_float(value, key)
case "DAYS" | "HOURS" | "RESTART":
raise ObservationConfigError.with_context(
Copy link
Collaborator

Choose a reason for hiding this comment

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

How much work is it to raise this as a specific error that we then catch higher up to add context, for example SummaryObservationError, the reason being that we dont need the context of the cli tool in this part of the code, that can live higher in the stack. Should still be available in the suggester in the same way as now, so should reraise it as ObservationConfigError higher up (or another type that brings it into the suggestor)

Copy link
Contributor Author

@yngve-sk yngve-sk Jan 20, 2026

Choose a reason for hiding this comment

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

ObservationConfigError is a ConfigValidationError, so it should show up in suggester?
Screenshot 2026-01-20 at 12 15 26
Screenshot 2026-01-20 at 12 15 38

Screenshot 2026-01-20 at 12 29 17 Screenshot 2026-01-20 at 12 29 30

Copy link
Collaborator

Choose a reason for hiding this comment

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

The message is good, I was thinking about the fact that _observations.py knows there exists and cli tool, while logically that information should exist higher in the stack _observations.py only knows that HISTORY_OBSERVATION is deprecated, and we can add more context higher in the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. I think this could be a residual followup issue, likely requires some design decisions (first idea that comes to my mind is having an own observation error type, indicating that it needs migration, and taking it from there) and moving of some things.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will also allow us to inject the path to the ert-file, so that the feedback message actually contains a valid command.
E.g.
ert convert_observations test-data/ert/poly_example/poly.ert instead of that placeholder.

@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from 38f4b1f to 58d1299 Compare January 20, 2026 11:23
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from 58d1299 to 31049ed Compare January 20, 2026 11:27
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from 31049ed to cb2eb11 Compare January 20, 2026 11:37
Avoid error from overlapping obs types
Avoid error from overlapping obs names across different response types
History observations and general observations already allow for keys being duplicate downstream, in the observation dataset. Thus, it does not make sense to allow a history obs to create 200 duplicate summary obs keys, but for the equivalent to be disallowed if explicitly done in the ert obs config.
@yngve-sk yngve-sk force-pushed the 26.01.remove-history-obs-with-utility branch from 09b1e47 to 029718f Compare January 20, 2026 14:03
@yngve-sk yngve-sk merged commit 6995ffc into equinor:main Jan 20, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes:breaking-change Automatically categorise as breaking change in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create conversion tool for HISTORY_OBSERVATION to SUMMARY_OBSERVATION

7 participants