-
Notifications
You must be signed in to change notification settings - Fork 110
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
Some adaptations to workflows #9994
Some adaptations to workflows #9994
Conversation
e38fc26
to
16d8860
Compare
CodSpeed Performance ReportMerging #9994 will not alter performanceComparing Summary
|
a1fc9a1
to
ab916da
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.
Looks good, I have some minor questions.
src/ert/workflow_runner.py
Outdated
@@ -107,14 +107,16 @@ class WorkflowRunner: | |||
def __init__( | |||
self, | |||
workflow: Workflow, | |||
config_file: str | None = 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.
Also commented in semeio, could potentially give reports dir, we do something similar for the update report, that has a folder it writes to.
a60c42c
to
6e47da3
Compare
87c7ada
to
0aeee68
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.
Very good :) See some minor questions 🔍
0aeee68
to
9d1a66e
Compare
There seems to be a GUI test hanging now 🤔 |
f094ca8
to
1e668d0
Compare
1e668d0
to
563aa3f
Compare
563aa3f
to
aeccdd7
Compare
Will this resolve #9389? |
I think so yes, as it will no longer need the ertconfig |
Looks good to me, @oyvindeide should have a look at it too 🚀 |
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.
Looks good, but can we drop kwargs support in this PR and still fix the bug? Then feel free to suggest it in a different PR, but think that requires some additional tests.
src/ert/config/ert_script.py
Outdated
@deprecated("Use fixtures to the run function instead") | ||
def ert(self) -> ErtConfig | None: | ||
logger.info(f"Accessing EnKFMain from workflow: {self.__class__.__name__}") | ||
return self._ert | ||
|
||
@property | ||
def ensemble(self) -> Ensemble | None: | ||
warnings.warn( | ||
"The ensemble property is deprecated, use the fixture to the run function instead", | ||
DeprecationWarning, | ||
stacklevel=1, | ||
) | ||
logger.info(f"Accessing ensemble from workflow: {self.__class__.__name__}") | ||
return self._ensemble | ||
|
||
@property | ||
def storage(self) -> Storage | None: | ||
warnings.warn( | ||
"The storage property is deprecated, use the fixture to the run function instead", | ||
DeprecationWarning, | ||
stacklevel=1, | ||
) | ||
logger.info(f"Accessing storage from workflow: {self.__class__.__name__}") | ||
return self._storage | ||
|
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.
These deprecations should stay, but can raise an error.
src/ert/run_models/base_run_model.py
Outdated
@@ -181,13 +182,20 @@ def __init__( | |||
self.start_iteration = start_iteration | |||
self.restart = False | |||
|
|||
def reports_dir(self, ensemble_name: str) -> str: |
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.
Should use log_path
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.
Hmm I see, this was just replicating old behavior, but log_path
is the update_log_path
, but workflows are not necessarily related to the update? Or is the update_log_path
now just the "output" for non-storage, but permanent files pertaining to an ERT run?
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.
Yes, the latter, it is just the output path for things related to that experiment.
src/ert/config/ert_script.py
Outdated
use_kwargs = { | ||
k: (kwargs or {}).get(k, default_value) | ||
for k, default_value in ({**kwargs_defaults, **kwargs}).items() |
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 sure kwarg support is worth the extra complication, can we do without it?
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.
Should be in another PR unless it is needed to fix the bug, think we might need some additional tests for that.
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.
We can. I will use workflow_args and move the defaulting to not be in the function signature of ahmanalysis, as for the test that modifies/overrides alpha for the update settings I will edit it in the ert config before doing .run_ertscript
.
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.
Sounds good, yes, can remove the defaulting in the AHMAnalysis job
aeccdd7
to
6ad5a19
Compare
src/ert/config/ert_script.py
Outdated
@@ -71,36 +68,36 @@ def stderrdata(self) -> str: | |||
self._stderrdata = self._stderrdata.decode() | |||
return self._stderrdata | |||
|
|||
def isCancelled(self) -> bool: |
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 moved?
@@ -114,7 +111,7 @@ def initializeAndRun( | |||
self, | |||
argument_types: list[type[Any]], | |||
argument_values: list[str], | |||
fixtures: dict[str, Any] | None = None, | |||
fixtures: WorkflowFixtures | None = 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.
Typing problem. Is this hit by tests? In case it is actually incompatible.
src/ert/gui/tools/plugins/plugin.py
Outdated
""" | ||
Returns a list of arguments. Either from GUI or from arbitrary code. | ||
If the user for example cancels in the GUI a CancelPluginException is raised. | ||
""" | ||
script = self.__loadPlugin() | ||
fixtures["parent"] = self.__parent_window | ||
func_args = inspect.signature(script.getArguments).parameters | ||
arguments = script.insert_fixtures(func_args, fixtures) | ||
arguments = script.insert_fixtures(dict(func_args), fixtures, {}) |
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.
Seems like more than a typing problem?
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.
Yeah removing, empty placeholder for kwargs
"storage": self.storage, | ||
"random_seed": self.config.random_seed, | ||
"reports_dir": str( | ||
self.storage.path.parent |
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.
log_path
here too
"storage": self.storage, | ||
"random_seed": ert_config.random_seed, | ||
"reports_dir": str( | ||
self.storage.path.parent |
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.
log_path
src/ert/libres_facade.py
Outdated
"ensemble": ensemble, | ||
"reports_dir": ( | ||
storage.path.parent | ||
/ "reports" |
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.
log_path
b849ab8
to
ab80df4
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.
LGTM! Just some minor comments.
@@ -213,13 +216,15 @@ def api(self) -> BaseRunModelAPI: | |||
cancel=self.cancel, | |||
) | |||
|
|||
def reports_dir(self, experiment_name: str) -> str: | |||
return str(self._log_path / experiment_name) |
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.
Is it ok that this does not exist?
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.
Don't think so, assuming there is always a log_path
in every BaseRunModel as it comes from the ERT config, or is otherwise explicitly passed in.
@@ -21,4 +21,4 @@ def test_executing_workflow(storage): | |||
rc = ErtConfig.from_file(config_file) | |||
args = Namespace(name="test_wf") | |||
execute_workflow(rc, storage, args.name) | |||
assert os.path.isfile(".ert_runpath_list") | |||
assert os.path.isfile("test_workflow_output.csv") |
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.
Suggest parameterizing this test if it is fast so both workflows are run.
src/ert/config/ert_script.py
Outdated
logger.info(f"Accessing EnKFMain from workflow: {self.__class__.__name__}") | ||
return self._ert | ||
raise KeyError("Attribute 'ert' is deprecated, use fixtures instead.") |
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.
Nitpick, but this should be an AttributeError
ab80df4
to
3e43f4e
Compare
Co-authored-by: Jonathan Karlsen <[email protected]>
Co-authored-by: Jonathan Karlsen <[email protected]>
Co-authored-by: Jonathan Karlsen <[email protected]>
3e43f4e
to
6d042ec
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.
Very good
Issue
Resolves equinor/semeio#685
Resolves #9389
Add support for defaulted kwargs from workflows