Skip to content

Update BaseModelWithContext with extra=forbid and fix tests#13457

Open
erlenlh wants to merge 2 commits intomainfrom
update-base-model-with-context-support
Open

Update BaseModelWithContext with extra=forbid and fix tests#13457
erlenlh wants to merge 2 commits intomainfrom
update-base-model-with-context-support

Conversation

@erlenlh
Copy link
Copy Markdown
Contributor

@erlenlh erlenlh commented Apr 30, 2026

Issue
Resolves #13444

Approach
Add extra=forbid flag to BaseModelWithContextSupport. Deal with downstream effect, adding to models or removing from tests where it seems fit.

(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')

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

This PR tightens Pydantic validation for ERT models by making BaseModelWithContextSupport forbid unknown fields, then adjusts affected run-model construction and unit tests to comply (issue #13444).

Changes:

  • Configure BaseModelWithContextSupport to use extra="forbid" (and update downstream call sites/tests impacted by stricter validation).
  • Update run-model serialization roundtrip tests to avoid validating computed/serialized-only fields.
  • Adjust Everest/ManualUpdate run-model construction/config so instantiation works under extra="forbid".

Reviewed changes

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

Show a summary per file
File Description
src/ert/base_model_context.py Makes context-enabled Pydantic base model forbid extra fields (and also enables arbitrary types).
src/ert/run_models/everest_run_model.py Adds fields to EverestRunModelConfig to satisfy stricter model validation; introduces optimization_callback handling as a config field.
src/ert/run_models/model_factory.py Stops passing observations into ManualUpdateConfig (now forbidden as an extra field).
tests/ert/unit_tests/run_models/test_experiment_serialization.py Excludes experiment_type from dumped payload when re-validating runmodels (to avoid extra="forbid" failures).
tests/ert/unit_tests/ensemble_evaluator/conftest.py Removes unsupported job_script argument from QueueConfig fixture construction.

Comment thread src/ert/run_models/everest_run_model.py
Comment thread src/ert/base_model_context.py Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.93%. Comparing base (94b18c4) to head (dcf4875).
⚠️ Report is 39 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13457      +/-   ##
==========================================
- Coverage   90.05%   89.93%   -0.12%     
==========================================
  Files         459      459              
  Lines       32040    32182     +142     
==========================================
+ Hits        28853    28944      +91     
- Misses       3187     3238      +51     
Flag Coverage Δ
cli-tests 37.33% <26.66%> (-0.18%) ⬇️
fuzz 44.15% <80.00%> (-0.08%) ⬇️
gui-tests 66.81% <46.66%> (-0.13%) ⬇️
performance-and-unit-tests 77.95% <100.00%> (-0.06%) ⬇️
test 45.79% <80.00%> (-0.10%) ⬇️

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

Files with missing lines Coverage Δ
src/ert/base_model_context.py 100.00% <100.00%> (ø)
src/ert/run_models/everest_run_model.py 92.19% <100.00%> (+0.09%) ⬆️
src/ert/run_models/model_factory.py 97.72% <100.00%> (+0.03%) ⬆️
src/ert/run_models/run_model.py 93.18% <100.00%> (+0.01%) ⬆️

... and 17 files with indirect coverage changes

@erlenlh erlenlh force-pushed the update-base-model-with-context-support branch from 74d18a9 to e138a24 Compare May 4, 2026 13:02
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 4, 2026

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing update-base-model-with-context-support (e138a24) with main (54f74d3)

Open in CodSpeed

@erlenlh erlenlh force-pushed the update-base-model-with-context-support branch from e138a24 to dda17fb Compare May 5, 2026 07:16
@erlenlh erlenlh force-pushed the update-base-model-with-context-support branch from dda17fb to dcf4875 Compare May 5, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update BaseModelWithContextSupport to extra="forbid"

3 participants