Add update_strategy for parameter type#13461
Add update_strategy for parameter type#13461frode-aarstad wants to merge 5 commits intoequinor:mainfrom
Conversation
89ea744 to
fba19df
Compare
9bbd4a1 to
fa13793
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13461 +/- ##
==========================================
- Coverage 89.90% 84.97% -4.94%
==========================================
Files 460 462 +2
Lines 32372 32476 +104
==========================================
- Hits 29105 27597 -1508
- Misses 3267 4879 +1612
Flags with carried forward coverage won't be shown. Click here to find out more.
|
db1a1fa to
10296f2
Compare
91f0bf1 to
9a956c5
Compare
9a956c5 to
d162f43
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new update_strategy concept for parameter configs (replacing the boolean update) and adds support for configuring default update strategy per parameter type via ANALYSIS_SET_VAR PARAMETERS ..., including local storage migration to v29.
Changes:
- Replace
update: boolwithupdate_strategy: str | Noneacross parameter config models, GUI/CLI checks, and analysis selection logic. - Add
ANALYSIS_SET_VAR PARAMETERS <TYPE> <STRATEGY>parsing and application (per parameter type default strategy), plus new helperget_update_from_options(). - Bump local storage version to 29 and add a migration converting stored parameter
updatebooleans intoupdate_strategy.
Reviewed changes
Copilot reviewed 58 out of 58 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ert/unit_tests/storage/test_storage_migration.py | Updates smoother update calls to pass strategy_map. |
| tests/ert/unit_tests/storage/test_local_storage.py | Updates hypothesis strategies to generate update_strategy. |
| tests/ert/unit_tests/storage/migration/test_to29.py | Adds tests for v29 migration converting update → update_strategy. |
| tests/ert/unit_tests/scenarios/test_summary_response.py | Updates smoother update calls to pass strategy_map. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_esmda_matches_snapshot/snake_oilsnake_oil.ert/snake_oil.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_esmda_matches_snapshot/poly_examplepoly.ert/poly.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_esmda_matches_snapshot/heat_equationconfig.ert/config.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_smoother_matches_snapshot/snake_oilsnake_oil.ert/snake_oil.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_smoother_matches_snapshot/poly_examplepoly.ert/poly.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_smoother_matches_snapshot/heat_equationconfig.ert/config.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_experiment_matches_snapshot/snake_oilsnake_oil.ert/snake_oil.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_experiment_matches_snapshot/poly_examplepoly.ert/poly.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_ensemble_experiment_matches_snapshot/heat_equationconfig.ert/config.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_enif_matches_snapshot/snake_oilsnake_oil.ert/snake_oil.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_enif_matches_snapshot/poly_examplepoly.ert/poly.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/run_models/snapshots/test_experiment_serialization/test_that_dumped_enif_matches_snapshot/heat_equationconfig.ert/config.json | Snapshot update: update → update_strategy. |
| tests/ert/unit_tests/gui/tools/plot/test_plot_api.py | Updates GUI plot API tests to use update_strategy. |
| tests/ert/unit_tests/gui/ertwidgets/models/test_ertsummary.py | Updates ERT summary model tests for update_strategy. |
| tests/ert/unit_tests/dark_storage/test_http_endpoints.py | Updates expected HTTP payload to update_strategy. |
| tests/ert/unit_tests/config/test_surface_config.py | Updates surface config tests to use update_strategy. |
| tests/ert/unit_tests/config/test_get_update_from_options.py | Adds unit tests for get_update_from_options(). |
| tests/ert/unit_tests/config/test_gen_kw_config.py | Updates gen_kw config parsing tests for update_strategy. |
| tests/ert/unit_tests/config/test_field.py | Updates field config tests to use update_strategy. |
| tests/ert/unit_tests/config/test_ert_config.py | Adds coverage for applying per-type parameter strategies in ErtConfig. |
| tests/ert/unit_tests/config/test_analysis_config.py | Adds tests for ANALYSIS_SET_VAR PARAMETERS parsing/validation. |
| tests/ert/unit_tests/analysis/test_es_update.py | Updates ES update tests for explicit strategy_map and new strategy mapping. |
| tests/ert/unit_tests/analysis/test_enif_update.py | Updates EnIF tests to use update_strategy. |
| tests/ert/unit_tests/analysis/test_distance_localization.py | Updates distance localization tests to use update_strategy. |
| tests/ert/ui_tests/gui/test_parameterviewer.py | Updates parameter viewer UI tests for string/None “updatable” state. |
| tests/ert/ui_tests/cli/test_field_parameter.py | Updates CLI field parameter test to new build_strategy_map API. |
| tests/ert/ui_tests/cli/analysis/test_es_update.py | Updates CLI ES update tests to use update_strategy. |
| tests/ert/ui_tests/cli/analysis/test_enif_update.py | Updates CLI EnIF test to use update_strategy. |
| tests/ert/ui_tests/cli/analysis/test_adaptive_localization.py | Adds PARAMETERS strategy configuration in adaptive localization UI test. |
| tests/ert/performance_tests/test_obs_and_responses_performance.py | Updates perf tests to pass strategy_map. |
| tests/ert/performance_tests/test_memory_usage.py | Updates perf tests to pass strategy_map. |
| tests/ert/performance_tests/test_create_run_path_performance.py | Updates surface perf test config to update_strategy. |
| tests/ert/performance_tests/test_analysis.py | Updates perf test for new build_strategy_map signature. |
| src/ert/storage/migration/to29.py | Adds migration converting stored update bool to update_strategy. |
| src/ert/storage/local_storage.py | Bumps storage version to 29 and wires in to29 migration. |
| src/ert/storage/local_experiment.py | Updates update_parameters selection to use update_strategy. |
| src/ert/run_models/update_run_model.py | Updates run model to build and pass strategy_map. |
| src/ert/run_models/model_factory.py | Updates “has updatable parameters” validation to use update_strategy. |
| src/ert/gui/experiments/experiment_panel.py | Updates GUI eligibility check to use update_strategy. |
| src/ert/gui/ertwidgets/parameterviewer.py | Updates parameter viewer display/filtering to use update_strategy. |
| src/ert/config/surface_config.py | Parses UPDATE into update_strategy for surface parameters. |
| src/ert/config/parameter_config.py | Changes base parameter config field to update_strategy. |
| src/ert/config/gen_kw_config.py | Parses UPDATE into update_strategy and handles CONST as non-updatable. |
| src/ert/config/field.py | Parses UPDATE into update_strategy for field parameters. |
| src/ert/config/everest_control.py | Sets Everest controls to non-updatable via update_strategy=None. |
| src/ert/config/ert_config.py | Applies per-parameter-type default strategies after parsing. |
| src/ert/config/design_matrix.py | Ensures design-matrix parameters are non-updatable via update_strategy=None. |
| src/ert/config/analysis_module.py | Adjusts (commented) localization default constant. |
| src/ert/config/analysis_config.py | Adds parameter_strategies and parsing for ANALYSIS_SET_VAR PARAMETERS. |
| src/ert/config/_get_update_from_options.py | New helper mapping UPDATE option to GLOBAL/None. |
| src/ert/cli/main.py | Updates CLI “all UPDATE:FALSE” validation to use update_strategy. |
| src/ert/analysis/_es_update.py | Moves update selection to explicit strategy_map and per-parameter strategies. |
| src/ert/analysis/_enif_update.py | Updates EnIF “updated parameters” selection to use update_strategy. |
| docs/ert/reference/configuration/keywords.rst | Documents new ANALYSIS_SET_VAR PARAMETERS syntax and strategies. |
16297a4 to
1071d8d
Compare
| .. note:: | ||
|
|
||
| The update strategy set with ``ANALYSIS_SET_VAR PARAMETERS`` acts as a default for all parameters of that type. | ||
| However, individual parameters can override this and disable updates by setting ``UPDATE:FALSE``. |
There was a problem hiding this comment.
Not sure if this is override or just disabling the update.
Maybe instead?
You can still turn off update for individual parameters by setting UPDATE:FALSE
There was a problem hiding this comment.
I will reword this.
| for param_name in parameters: | ||
| param_cfg = param_configs[param_name] | ||
| if isinstance(param_cfg, Field): | ||
| if param_cfg.update_strategy == "DISTANCE": |
There was a problem hiding this comment.
Can this be simplified somehow?
For example to use something like this:
strategy_table: dict[type, strategy_type] = {
Field: {
"DISTANCE": field_distance_strategy,
"ADAPTIVE": adaptive_localization_strategy,
"GLOBAL": global_strategy,
},
SurfaceConfig: {
"DISTANCE": surface_distance_strategy,
"ADAPTIVE": adaptive_localization_strategy,
"GLOBAL": global_strategy,
},
GenKwConfig: {
"ADAPTIVE": adaptive_localization_strategy,
"GLOBAL": global_strategy,
},
}There was a problem hiding this comment.
Not sure how this make it simpler.
There was a problem hiding this comment.
maybe it is not so straightforward to simplify this, yes. Ok, let's keep it for now, but there are way too many ifs for my taste ;)
Issue
Resolves #13027
Approach
Short description of the approach
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'just rapid-tests')When applicable