Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor BaseRunModel #9676

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

frode-aarstad
Copy link
Contributor

Issue
Resolves #9604

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 'pytest tests/ert/unit_tests -n logical -m "not integration_test"')

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: Create Backport PR to latest release

@frode-aarstad frode-aarstad added the release-notes:maintenance Automatically categorise as maintenance change in release notes label Jan 8, 2025
@frode-aarstad frode-aarstad self-assigned this Jan 8, 2025
@frode-aarstad frode-aarstad force-pushed the refactor-baserunmodel branch 2 times, most recently from 95a4211 to a049423 Compare January 8, 2025 09:16
Copy link

codspeed-hq bot commented Jan 8, 2025

CodSpeed Performance Report

Merging #9676 will improve performances by 10.99%

Comparing frode-aarstad:refactor-baserunmodel (6b7f276) with main (9b0a3b1)

Summary

⚡ 1 improvements
✅ 23 untouched benchmarks

Benchmarks breakdown

Benchmark main frode-aarstad:refactor-baserunmodel Change
test_load_from_context[gen_x: 20, sum_x: 20 reals: 10] 7.2 ms 6.5 ms +10.99%

@frode-aarstad frode-aarstad force-pushed the refactor-baserunmodel branch from a049423 to 4b764b8 Compare January 8, 2025 10:49
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.73%. Comparing base (383d645) to head (4b764b8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9676      +/-   ##
==========================================
- Coverage   91.74%   91.73%   -0.01%     
==========================================
  Files         426      426              
  Lines       26518    26553      +35     
==========================================
+ Hits        24328    24359      +31     
- Misses       2190     2194       +4     
Flag Coverage Δ
cli-tests 39.79% <87.23%> (+0.08%) ⬆️
everest-models-test 34.26% <62.50%> (+0.04%) ⬆️
gui-tests 71.96% <80.85%> (+0.01%) ⬆️
integration-test 38.09% <64.58%> (+0.03%) ⬆️
performance-tests 51.68% <72.34%> (+0.03%) ⬆️
test 39.63% <64.58%> (+0.03%) ⬆️
unit-tests 74.28% <85.41%> (+0.01%) ⬆️

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.

@@ -146,27 +159,37 @@ def __init__(
the forward model and passing events back through the supplied queue.
"""
self._total_iterations = total_iterations
config.analysis_config.num_iterations = total_iterations
# config.analysis_config.num_iterations = total_iterations
Copy link
Contributor

@yngve-sk yngve-sk Jan 13, 2025

Choose a reason for hiding this comment

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

Stray comment? Not sure exactly why this was there in the first place also... Found some logic using it in the ExportRunpathJob, so maybe we still need to mutate it? Could be done from model_factory.py in _setup_iterative_ensemble_smoother to preserve old behavior

@@ -146,27 +159,37 @@ def __init__(
the forward model and passing events back through the supplied queue.
"""
self._total_iterations = total_iterations
config.analysis_config.num_iterations = total_iterations
# config.analysis_config.num_iterations = total_iterations
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stray comment?

src/ert/run_models/base_run_model.py Outdated Show resolved Hide resolved
active_realizations=[], # Set dynamically in run_forward_model()
)
self.support_restart = False
self._parameter_configuration = config.ensemble_config.parameter_configuration
self._parameter_configs = config.ensemble_config.parameter_configs
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to keep both these fields? One is a dict, other is a list, could just keep the dict and do .values() or something like that. Also, the second invocation:

            ext_config = self.ert_config.ensemble_config.parameter_configs[control_name]

Here the experiment will always exist, so we could do self._experiment.parameter_configuration to get the parameter configs, and extract the ExtParam ones (should only be those anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should probably be part of a refactor of EnsembleConfig. Both parameter_config and parameter_configuration seems to be used quite a bit around in the code.

@frode-aarstad frode-aarstad force-pushed the refactor-baserunmodel branch 3 times, most recently from d126be3 to 200b926 Compare January 13, 2025 10:08
@yngve-sk
Copy link
Contributor

Are you sure about the removal of this part: config.analysis_config.num_iterations = total_iterations? If yes, it should at least be in its own commit. Ref my previous comment wrt ExportRunpathJob, num iterations is set from the GUI when running it, so it has to be propagated there somehof

@frode-aarstad
Copy link
Contributor Author

Are you sure about the removal of this part: config.analysis_config.num_iterations = total_iterations? If yes, it should at least be in its own commit. Ref my previous comment wrt ExportRunpathJob, num iterations is set from the GUI when running it, so it has to be propagated there somehof

You are right. Its probably best to leave it as it was

@yngve-sk
Copy link
Contributor

Are you sure about the removal of this part: config.analysis_config.num_iterations = total_iterations? If yes, it should at least be in its own commit. Ref my previous comment wrt ExportRunpathJob, num iterations is set from the GUI when running it, so it has to be propagated there somehof

You are right. Its probably best to leave it as it was

I think we have to move the "edit analysis config num iterations" behavior to the ies part of model_factory as outlined in my previous comment to preserve the behavior and also not have the entire AnalysisConfig in the BaseRunModel init signature

Copy link
Contributor

@yngve-sk yngve-sk left a comment

Choose a reason for hiding this comment

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

LGTM

@frode-aarstad frode-aarstad merged commit 0c7bf35 into equinor:main Jan 14, 2025
36 checks passed
@frode-aarstad frode-aarstad deleted the refactor-baserunmodel branch January 14, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes:maintenance Automatically categorise as maintenance change in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove ErtConfig from the BaseRunModel
4 participants