Skip to content

Commit 35bba75

Browse files
committed
fixup! Split workflows into executable and ert_script
1 parent 666842c commit 35bba75

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/ert/config/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from .summary_observation import SummaryObservation
3939
from .surface_config import SurfaceConfig
4040
from .workflow import Workflow
41-
from .workflow_job import WorkflowJob
41+
from .workflow_job import _WorkflowJob
4242

4343
__all__ = [
4444
"AnalysisConfig",
@@ -83,7 +83,7 @@
8383
"UpdateSettings",
8484
"WarningInfo",
8585
"Workflow",
86-
"WorkflowJob",
86+
"_WorkflowJob",
8787
"capture_validation",
8888
"field_transform",
8989
"lint_file",

src/ert/config/ert_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
ErtScriptLoadFailure,
7575
ErtScriptWorkflow,
7676
ExecutableWorkflow,
77-
WorkflowJob,
77+
_WorkflowJob,
7878
workflow_job_from_file,
7979
)
8080

@@ -561,7 +561,7 @@ class ErtConfig:
561561
random_seed: int | None = None
562562
analysis_config: AnalysisConfig = field(default_factory=AnalysisConfig)
563563
queue_config: QueueConfig = field(default_factory=QueueConfig)
564-
workflow_jobs: dict[str, WorkflowJob] = field(default_factory=dict)
564+
workflow_jobs: dict[str, _WorkflowJob] = field(default_factory=dict)
565565
workflows: dict[str, Workflow] = field(default_factory=dict)
566566
hooked_workflows: defaultdict[HookRuntime, list[Workflow]] = field(
567567
default_factory=lambda: defaultdict(list)

src/ert/config/workflow.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@
1010
if TYPE_CHECKING:
1111
from ert.substitutions import Substitutions
1212

13-
from .workflow_job import WorkflowJob
13+
from .workflow_job import _WorkflowJob
1414

1515

1616
@dataclass
1717
class Workflow:
1818
src_file: str
19-
cmd_list: list[tuple[WorkflowJob, Any]]
19+
cmd_list: list[tuple[_WorkflowJob, Any]]
2020

2121
def __len__(self) -> int:
2222
return len(self.cmd_list)
2323

24-
def __getitem__(self, index: int) -> tuple[WorkflowJob, Any]:
24+
def __getitem__(self, index: int) -> tuple[_WorkflowJob, Any]:
2525
return self.cmd_list[index]
2626

27-
def __iter__(self) -> Iterator[tuple[WorkflowJob, Any]]:
27+
def __iter__(self) -> Iterator[tuple[_WorkflowJob, Any]]:
2828
return iter(self.cmd_list)
2929

3030
@classmethod
3131
def _parse_command_list(
3232
cls,
3333
src_file: str,
3434
context: list[tuple[str, str]],
35-
job_dict: dict[str, WorkflowJob],
36-
) -> list[tuple[WorkflowJob, Any]]:
35+
job_dict: dict[str, _WorkflowJob],
36+
) -> list[tuple[_WorkflowJob, Any]]:
3737
schema = init_workflow_schema()
3838
config_dict = parse(src_file, schema, pre_defines=context)
3939

@@ -88,7 +88,7 @@ def from_file(
8888
cls,
8989
src_file: str,
9090
context: Substitutions | None,
91-
job_dict: dict[str, WorkflowJob],
91+
job_dict: dict[str, _WorkflowJob],
9292
) -> Workflow:
9393
cmd_list = cls._parse_command_list(
9494
src_file=src_file,

src/ert/config/workflow_job.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ def workflow_job_parser(file: str) -> ConfigDict:
3333
return parse(file, schema=schema)
3434

3535

36-
def workflow_job_from_file(config_file: str, name: str | None = None) -> WorkflowJob:
36+
def workflow_job_from_file(config_file: str, name: str | None = None) -> _WorkflowJob:
3737
if not name:
3838
name = os.path.basename(config_file)
3939

4040
content_dict = workflow_job_parser(config_file)
41-
arg_types_list = WorkflowJob._make_arg_types_list(content_dict)
41+
arg_types_list = _WorkflowJob._make_arg_types_list(content_dict)
4242
min_args = content_dict.get("MIN_ARG") # type: ignore
4343
max_args = content_dict.get("MAX_ARG") # type: ignore
4444
script = str(content_dict.get("SCRIPT")) if "SCRIPT" in content_dict else None # type: ignore
@@ -85,7 +85,7 @@ def workflow_job_from_file(config_file: str, name: str | None = None) -> Workflo
8585

8686

8787
@dataclass
88-
class WorkflowJob:
88+
class _WorkflowJob:
8989
name: str
9090
min_args: int | None = None
9191
max_args: int | None = None
@@ -125,12 +125,12 @@ def is_plugin(self) -> bool:
125125

126126

127127
@dataclass
128-
class ExecutableWorkflow(WorkflowJob):
128+
class ExecutableWorkflow(_WorkflowJob):
129129
executable: str | None = None
130130

131131

132132
@dataclass
133-
class ErtScriptWorkflow(WorkflowJob):
133+
class ErtScriptWorkflow(_WorkflowJob):
134134
"""
135135
Single workflow configuration object
136136
"""

src/ert/gui/tools/export/exporter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING, Any
55

66
if TYPE_CHECKING:
7-
from ert.config import ErtConfig, WorkflowJob
7+
from ert.config import ErtConfig, _WorkflowJob
88

99
from ert.gui.ertnotifier import ErtNotifier
1010
from ert.workflow_runner import WorkflowJobRunner
@@ -15,7 +15,7 @@
1515
class Exporter:
1616
def __init__(
1717
self,
18-
export_job: WorkflowJob | None,
18+
export_job: _WorkflowJob | None,
1919
notifier: ErtNotifier,
2020
config: ErtConfig,
2121
):

src/ert/gui/tools/plugins/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if TYPE_CHECKING:
1111
from PyQt6.QtWidgets import QWidget
1212

13-
from ert.config import WorkflowJob
13+
from ert.config import _WorkflowJob
1414
from ert.gui.ertnotifier import ErtNotifier
1515
from ert.storage import Ensemble, LocalStorage
1616

@@ -66,5 +66,5 @@ def storage(self) -> LocalStorage:
6666
def ensemble(self) -> Ensemble | None:
6767
return self.__notifier.current_ensemble
6868

69-
def getWorkflowJob(self) -> WorkflowJob:
69+
def getWorkflowJob(self) -> _WorkflowJob:
7070
return self.__workflow_job

src/ert/workflow_runner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from concurrent.futures import Future
66
from typing import Any, Self
77

8-
from ert.config import ErtScript, ExternalErtScript, Workflow, WorkflowJob
8+
from ert.config import ErtScript, ExternalErtScript, Workflow, _WorkflowJob
99
from ert.config.workflow_fixtures import WorkflowFixtures
1010
from ert.config.workflow_job import ErtScriptWorkflow
1111

1212

1313
class WorkflowJobRunner:
14-
def __init__(self, workflow_job: WorkflowJob):
14+
def __init__(self, workflow_job: _WorkflowJob):
1515
self.job = workflow_job
1616
self.__running = False
1717
self.__script: ErtScript | None = None

tests/ert/unit_tests/config/test_workflow.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from hypothesis import given, strategies
66

7-
from ert.config import ConfigValidationError, Workflow, WorkflowJob
7+
from ert.config import ConfigValidationError, Workflow, _WorkflowJob
88
from ert.substitutions import Substitutions
99

1010

@@ -35,7 +35,7 @@ def test_that_substitution_happens_in_workflow():
3535
substlist = Substitutions()
3636
substlist["<A>"] = "a"
3737
substlist["<B>"] = "b"
38-
job = WorkflowJob(
38+
job = _WorkflowJob(
3939
name="JOB",
4040
min_args=None,
4141
max_args=None,
@@ -50,7 +50,7 @@ def test_that_substitution_happens_in_workflow():
5050

5151

5252
def get_workflow_job(name):
53-
return WorkflowJob(
53+
return _WorkflowJob(
5454
name=name,
5555
min_args=None,
5656
max_args=None,
@@ -183,7 +183,7 @@ def test_args_validation(config, expectation, min_args, max_args):
183183
src_file="workflow",
184184
context=None,
185185
job_dict={
186-
"WORKFLOW": WorkflowJob(
186+
"WORKFLOW": _WorkflowJob(
187187
name="WORKFLOW",
188188
min_args=min_args,
189189
max_args=max_args,

0 commit comments

Comments
 (0)