Skip to content

Commit

Permalink
Add workflow fixture: user_config_file
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Feb 6, 2025
1 parent 68271ad commit f90a338
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/ert/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def execute_workflow(
msg = "Workflow {} is not in the list of available workflows"
logger.error(msg.format(workflow_name))
return
runner = WorkflowRunner(workflow=workflow, storage=storage, ert_config=ert_config)
runner = WorkflowRunner(
workflow=workflow,
storage=storage,
ert_config=ert_config,
config_file=ert_config.user_config_file,
)
runner.run_blocking()
if not all(v["completed"] for v in runner.workflowReport().values()):
logger.error(f"Workflow {workflow_name} failed!")
3 changes: 2 additions & 1 deletion src/ert/gui/tools/workflows/run_workflow_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def startWorkflow(self) -> None:

workflow = self.config.workflows[self.getCurrentWorkflowName()]
self._workflow_runner = WorkflowRunner(
workflow,
workflow=workflow,
storage=self.storage,
ensemble=self.source_ensemble_selector.currentData(),
config_file=self.config.user_config_file,
)
self._workflow_runner.run()

Expand Down
1 change: 1 addition & 0 deletions src/ert/libres_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def run_ertscript( # type: ignore
"ert_config": self.config,
"ensemble": ensemble,
"storage": storage,
"config_file": self.config.user_config_file,
},
)

Expand Down
7 changes: 6 additions & 1 deletion src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,12 @@ def run_workflows(
ensemble: Ensemble | None = None,
) -> None:
for workflow in self._hooked_workflows[runtime]:
WorkflowRunner(workflow, storage, ensemble).run_blocking()
WorkflowRunner(
workflow=workflow,
storage=storage,
ensemble=ensemble,
config_file=str(self._user_config_file),
).run_blocking()

def _evaluate_and_postprocess(
self,
Expand Down
6 changes: 4 additions & 2 deletions src/ert/workflow_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ class WorkflowRunner:
def __init__(
self,
workflow: Workflow,
config_file: str | None = None,
storage: Storage | None = None,
ensemble: Ensemble | None = None,
ert_config: ErtConfig | None = None,
) -> None:
self.__workflow = workflow
self.storage = storage
self.ensemble = ensemble
self.ert_config = ert_config
self.ert_config = ert_config # Should eventually be removed
self.config_file = config_file

self.__workflow_result: bool | None = None
self._workflow_executor = futures.ThreadPoolExecutor(max_workers=1)
Expand Down Expand Up @@ -152,7 +154,7 @@ def run_blocking(self) -> None:
self.__running = True
fixtures = {
k: getattr(self, k)
for k in ["storage", "ensemble", "ert_config"]
for k in ["storage", "ensemble", "ert_config", "config_file"]
if getattr(self, k)
}

Expand Down

0 comments on commit f90a338

Please sign in to comment.