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

Run ensemble experiment with design matrix #8941

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Oct 10, 2024

Issue
Resolves #8961

Approach

  • Do design matrix validation on startup

    • Validate active realizations and design matrix xsls
  • Use design_matrix parameters in ensemble experiment

  • add merge function to merge design parameters with existing parameters

    • currently if there is a full overlap the design matrix parameters takes precedence
    • we raise Validation error in case of partial overlap
  • remove poly_design once done.

  • add unit and cli tests

(Screenshot of new behavior in GUI if applicable)

When hitting run and overlapping fails:
image

When loading wrongly formatted design matrix:
image

  • 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

@xjules xjules self-assigned this Oct 10, 2024
@xjules xjules added the blocked label Oct 10, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 88.70968% with 7 lines in your changes missing coverage. Please review.

Project coverage is 91.84%. Comparing base (d875982) to head (5b49260).

Files with missing lines Patch % Lines
...rc/ert/gui/simulation/ensemble_experiment_panel.py 28.57% 5 Missing ⚠️
src/ert/config/design_matrix.py 92.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8941      +/-   ##
==========================================
+ Coverage   91.64%   91.84%   +0.20%     
==========================================
  Files         433      433              
  Lines       26722    26761      +39     
==========================================
+ Hits        24489    24579      +90     
+ Misses       2233     2182      -51     
Flag Coverage Δ
cli-tests 39.76% <79.03%> (+0.34%) ⬆️
everest-models-test 34.66% <14.51%> (?)
gui-tests 72.14% <30.64%> (-0.07%) ⬇️
integration-test 37.20% <14.51%> (-0.06%) ⬇️
performance-tests 51.97% <30.64%> (-0.04%) ⬇️
test 40.47% <14.51%> (-0.04%) ⬇️
unit-tests 74.12% <77.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.

@xjules xjules added release-notes:new-feature Automatically categorise as new feature in release notes and removed blocked labels Oct 14, 2024
@xjules xjules force-pushed the checkbox_dm branch 3 times, most recently from 707fd91 to 88537d3 Compare October 15, 2024 11:31
@xjules xjules changed the title Add design matrix validation in ensemble experiment panel Run ensemble experiment with design matrix Oct 15, 2024
@xjules xjules force-pushed the checkbox_dm branch 2 times, most recently from 403b2fa to 2fe829a Compare October 15, 2024 14:05
@xjules xjules marked this pull request as ready for review October 15, 2024 14:08
@xjules xjules force-pushed the checkbox_dm branch 4 times, most recently from b97fc39 to a2f1053 Compare October 17, 2024 11:00
src/ert/enkf_main.py Outdated Show resolved Hide resolved
@xjules xjules force-pushed the checkbox_dm branch 2 times, most recently from 2d4c2cf to b399e41 Compare October 17, 2024 13:01
src/ert/enkf_main.py Outdated Show resolved Hide resolved
@xjules xjules force-pushed the checkbox_dm branch 2 times, most recently from 494347a to ff892b4 Compare October 18, 2024 11:35
@xjules xjules force-pushed the checkbox_dm branch 2 times, most recently from dbf426b to 04bf908 Compare October 21, 2024 14:08
src/ert/config/design_matrix.py Show resolved Hide resolved
src/ert/config/design_matrix.py Outdated Show resolved Hide resolved
src/ert/gui/simulation/ensemble_experiment_panel.py Outdated Show resolved Hide resolved
src/ert/run_models/ensemble_experiment.py Outdated Show resolved Hide resolved
src/ert/run_models/ensemble_experiment.py Show resolved Hide resolved
dedent(
"""\
#!/usr/bin/env python
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

Is numpy and sys used in the script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, good catch. it will be removed 👍

MIN_REALIZATIONS 10
ANALYSIS_SET_VAR STD_ENKF ENKF_TRUNCATION 0.8
DESIGN_MATRIX my_design_matrix.xlsx DESIGN_SHEET:my_sheet DEFAULT_SHEET:my_default_sheet
with suppress(ConfigValidationError):
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the reason for this suppress? I can not see how the test actually test anything now, since we do not expect it to reach the assert statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test just compares to configs, wherein the assert in the middle does exactly that. Suppress is to neglect validation error from wrongly formatted design matrix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will it not now just exit the with context when you first encounter a validation error, which is before the assert is done?
I tried changing the NUM_REALIZATIONS to -10 in the first dedent block, and the test passed still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, I sort of thought when the name of test is test_analysis_config_from_file_is_same_as_from_dict it only compares the content of the dicts and not go into semantics, but can change it to have a meaningful entries in the matrix and can remove the suppress statement.

"""\
#!/usr/bin/env python
import numpy as np
import sys
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, sys and numpy seems to be unused in the script.

@@ -162,6 +159,29 @@ def _seed_sequence(seed: Optional[int]) -> int:
return int_seed


def save_design_matrix_to_ensemble(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a method in the ensemble class? my_ensemble.save_design_matrix(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already ensemble.save_parameters, which represents the interface for storing parameters. Not sure if it would bring any value having it there as it is a special "class" of parameters.

Copy link
Contributor

@larsevj larsevj left a comment

Choose a reason for hiding this comment

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

Add test for this latest commit?

- Catagorical data is not treated properly yet, wherein the design
matrix group that contains catagorical data will automatically store all
parameters inside this group to objects; ie, strings.
- Prefil active realization box with realizations from design matrix
- Use design_matrix parameters in ensemble experiment
- add test run cli with design matrix and poly example
- add test that save parameters internalize DataFrame parameters in the storage
- add merge function to merge design parameters with existing parameters
 -- Raise Validation error when having multiple overlapping groups
- Update writting to parameter.txt with categorical values
Copy link
Contributor

@larsevj larsevj left a comment

Choose a reason for hiding this comment

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

Great work! 🚀

@xjules xjules merged commit 4301b63 into equinor:main Dec 12, 2024
39 checks passed
@xjules xjules deleted the checkbox_dm branch December 12, 2024 23:26
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.

Implement support for DESIGN_MATRIX when running ensemble experiment
5 participants