-
Notifications
You must be signed in to change notification settings - Fork 110
Add new forward model configuration style #10597
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
base: main
Are you sure you want to change the base?
Add new forward model configuration style #10597
Conversation
CodSpeed Performance ReportMerging #10597 will not alter performanceComparing Summary
|
d436308
to
c08e84f
Compare
f4edd63
to
7ccd960
Compare
2e08023
to
3d84617
Compare
3943605
to
bfae075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Some comments which might simplify it a bit
src/everest/config/everest_config.py
Outdated
if job_name not in installed_jobs_name: | ||
errors.append(f"unknown job {job_name}") | ||
|
||
if len(errors) > 0: # Note: python3.11 ExceptionGroup will solve this nicely | ||
raise ValueError(errors) | ||
return self | ||
|
||
def get_forward_model_steps( | ||
self, result_type: Literal["gen_data", "summary"] | ||
) -> list[ForwardModelStepConfigWithResults]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also be simplified if you add a field validator on forward_model
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this and moved filtering to the 2 callsites, behavior wrt field validator remains the same though.
cee48fb
to
50275f0
Compare
data_file = values.get("model", {}).get("data_file", None) | ||
eclbase = values.get("definitions", {}).get("eclbase", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use these values in the error message?
src/everest/config/everest_config.py
Outdated
message = "\n".join( | ||
[ | ||
"model.data_file is deprecated. ", | ||
"Instead, use install_data to specify the data file: ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not done by data_file
before? So this message is not needed, only the summary loading is affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So think we only need the message below. eclbase
in definitions is still fine to do, but it will no longer have a special meaning. We can fix that by putting a note in the documentation.
src/everest/config/everest_config.py
Outdated
if self.forward_model is None: | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont think it can be None anymore
src/everest/config/model_config.py
Outdated
@model_validator(mode="before") | ||
@classmethod | ||
def validate_no_data_file(cls, values: dict[str, Any]) -> dict[str, Any]: | ||
if "data_file" in values: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double validation?
) | ||
summary_fms = [ | ||
fm | ||
for fm in (ever_config.forward_model or []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults to empty list now
|
||
requested_keys = summary_fm.results.keys | ||
|
||
if requested_keys == "*": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the default different from ert, where *
means all the keys in the summary file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set it to requested keys + default ones for now. Should maybe revisit the behavior here later.
@@ -353,7 +345,7 @@ def _extract_forward_model( | |||
) -> None: | |||
forward_model = _extract_data_operations(ever_config) | |||
forward_model += _extract_templating(ever_config) | |||
forward_model += ever_config.forward_model or [] | |||
forward_model += ever_config.forward_model_step_commands or [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults to empty list?
type: Literal["gen_data", "summary"] = Field( | ||
description="Type of the result, either 'gen_data' or 'summary'" | ||
) | ||
keys: Literal["*"] | list[str] = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in the case of summary
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, special casing, could instead accept ["*"] and have only a list[str] type and have the same behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForwardModelStepResultsConfig could be:
ForwardModelStepResultsConfig = SummaryConfig | GenDataConfig
with a new field: type
, then you can discriminate on type
- job: eclipse100 eclipse/model/EGG.DATA --version 2020.2 | ||
results: | ||
file_name: eclipse/model/EGG | ||
type: summary | ||
- rf -s eclipse/model/EGG -o rf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🎉
a182c95
to
7ef2639
Compare
if isinstance(fm, dict): | ||
return fm | ||
|
||
return {"job": fm, "results": None} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beyond the scope, but could use this directly?
ert/src/ert/config/forward_model_step.py
Line 30 in 0793f26
class ForwardModelStepJSON(TypedDict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we would have to make ERT also specify results along with forward models for it to be compatible like this, currently we have own keywords in the ERT config. Also the ERT config is less natural to give as a hierarchy than the everest config with yml. Would maybe defer to do as a future thing if we have the ERT config as purely yml/json. But a similar change in ERT would make sense conceptually.
@@ -1,5 +1,5 @@ | |||
definitions: | |||
eclbase: eclipse/model/EGG | |||
realization_folder: r{{configpath}}/../../eclipse/include/realizations/realization-r{{realization}}/eclipse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed? Can just remove the whole definitions
section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually might make sense to keep eclbase
here as it is being reused later in the config.
@@ -121,8 +120,7 @@ simulator: | |||
max_running: 3 | |||
|
|||
install_data: | |||
- | |||
source: r{{ configpath }}/../../eclipse/include/realizations/realization-r{{ realization }}/eclipse | |||
- source: r{{realization_folder}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to comment above, can just keep the old? It is not being reused.
file_name: distance_nonobj | ||
type: gen_data | ||
# Write the value of each control to a separate file | ||
- job: adv_dump_controls --controls-file point.json --out-suffix _coord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep this without job:
as it is not adding any results?
@skipif_no_everest_models | ||
@pytest.mark.everest_models_test | ||
@pytest.mark.integration_test | ||
def test_everest_main_configdump_entry(copy_egg_test_data_to_tmp): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? Think the assert can just be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
bddcbe1
to
ce7ecee
Compare
ce7ecee
to
9ac4bf0
Compare
112e591
to
0af90ee
Compare
Address review
0af90ee
to
93aaabf
Compare
Issue
Resolves #9615