Skip to content

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

yngve-sk
Copy link
Contributor

Issue
Resolves #9615

Copy link

codspeed-hq bot commented Apr 10, 2025

CodSpeed Performance Report

Merging #10597 will not alter performance

Comparing yngve-sk:25.04.10.everest-fm-config-change (93aaabf) with main (527d97b)

Summary

✅ 25 untouched benchmarks

@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 4 times, most recently from d436308 to c08e84f Compare April 14, 2025 13:21
@yngve-sk yngve-sk marked this pull request as ready for review April 15, 2025 07:08
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 2 times, most recently from f4edd63 to 7ccd960 Compare April 16, 2025 07:47
@yngve-sk yngve-sk closed this Apr 22, 2025
@yngve-sk yngve-sk reopened this Apr 22, 2025
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 11 times, most recently from 2e08023 to 3d84617 Compare April 22, 2025 11:36
@yngve-sk yngve-sk self-assigned this Apr 22, 2025
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch from 3943605 to bfae075 Compare April 22, 2025 12:21
Copy link
Collaborator

@oyvindeide oyvindeide left a 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

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]:
Copy link
Collaborator

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

Copy link
Contributor Author

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.

@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 2 times, most recently from cee48fb to 50275f0 Compare April 23, 2025 07:11
Comment on lines +411 to +402
data_file = values.get("model", {}).get("data_file", None)
eclbase = values.get("definitions", {}).get("eclbase", None)
Copy link
Collaborator

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?

message = "\n".join(
[
"model.data_file is deprecated. ",
"Instead, use install_data to specify the data file: ",
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Comment on lines 770 to 752
if self.forward_model is None:
return []
Copy link
Collaborator

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

@model_validator(mode="before")
@classmethod
def validate_no_data_file(cls, values: dict[str, Any]) -> dict[str, Any]:
if "data_file" in values:
Copy link
Collaborator

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 [])
Copy link
Collaborator

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 == "*":
Copy link
Collaborator

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.

Copy link
Contributor Author

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 []
Copy link
Collaborator

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(
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

@oyvindeide oyvindeide Apr 29, 2025

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

Comment on lines 136 to 140
- job: eclipse100 eclipse/model/EGG.DATA --version 2020.2
results:
file_name: eclipse/model/EGG
type: summary
- rf -s eclipse/model/EGG -o rf
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! 🎉

@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch from a182c95 to 7ef2639 Compare April 29, 2025 10:39
if isinstance(fm, dict):
return fm

return {"job": fm, "results": None}
Copy link
Collaborator

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?

class ForwardModelStepJSON(TypedDict):
. Do you have a feeling how much work that would be? Not for this PR, would be a separate issue

Copy link
Contributor Author

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
Copy link
Collaborator

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?

Copy link
Collaborator

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}}
Copy link
Collaborator

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
Copy link
Collaborator

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):
Copy link
Collaborator

@oyvindeide oyvindeide Apr 29, 2025

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 3 times, most recently from bddcbe1 to ce7ecee Compare April 30, 2025 06:38
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch from ce7ecee to 9ac4bf0 Compare April 30, 2025 07:06
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch 2 times, most recently from 112e591 to 0af90ee Compare April 30, 2025 07:14
@yngve-sk yngve-sk force-pushed the 25.04.10.everest-fm-config-change branch from 0af90ee to 93aaabf Compare April 30, 2025 07:30
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.

Context validation of the simulator specific keywords
2 participants