Skip to content

Commit 0a650e1

Browse files
committed
Remove validation of src for AvailableData
I decided to remove the check since we will need to move it to to the aiida part after PR #136 is merged. With #136 we need to consider remote data which we cannot check neigher in core nor parsing. So moving this now to the yaml parsing would require the adoption of many test which will be anyway not be needed.
1 parent 5514432 commit 0a650e1

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

src/sirocco/core/graph_items.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class AvailableData(Data):
6262

6363
@classmethod
6464
def from_config(cls, config: ConfigBaseData, config_rootdir: Path, coordinates: dict) -> Self:
65-
src = cls._validate_src(config.name, config.src, config_rootdir)
65+
src = cls._validate_src(config.src, config_rootdir)
6666
return cls(
6767
name=config.name,
6868
computer=config.computer,
@@ -72,21 +72,14 @@ def from_config(cls, config: ConfigBaseData, config_rootdir: Path, coordinates:
7272
)
7373

7474
@staticmethod
75-
def _validate_src(name: str, config_src: Path | None, config_rootdir: Path | None = None) -> Path | None:
75+
def _validate_src(config_src: Path | None, config_rootdir: Path | None = None) -> Path | None:
7676
if config_src is None:
7777
return None
7878
if config_rootdir is None and not config_src.is_absolute():
7979
msg = f"Cannot specify relative path {config_src} for namelist while the rootdir is None"
8080
raise ValueError(msg)
8181

82-
src = config_src if config_rootdir is None else (config_rootdir / config_src)
83-
if not src.exists():
84-
msg = f"Data {name} in path {src} does not exist."
85-
raise FileNotFoundError(msg)
86-
if not src.is_file():
87-
msg = f"Data {name} in path {src} is not a file."
88-
raise OSError(msg)
89-
return src
82+
return config_src if config_rootdir is None else (config_rootdir / config_src)
9083

9184

9285
class GeneratedData(Data):

tests/conftest.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,24 @@ def icon_filepath_executable() -> str:
5858

5959

6060
@pytest.fixture(scope="session")
61-
def available_datas(tmp_path_factory):
62-
tmp_path = tmp_path_factory.mktemp("data")
63-
available_datas = [
64-
models.ConfigAvailableData(name="available", type=models.DataType.FILE, src=(tmp_path / "foo.txt"))
65-
]
66-
# validation in core representation requires that available data exists
67-
for available_data in available_datas:
68-
available_data.src.touch()
69-
return available_datas
70-
71-
72-
@pytest.fixture(scope="session")
73-
def minimal_config(available_datas) -> models.ConfigWorkflow:
61+
def minimal_config() -> models.ConfigWorkflow:
7462
return models.ConfigWorkflow(
7563
name="minimal",
7664
rootdir=pathlib.Path("minimal"),
7765
cycles=[models.ConfigCycle(name="minimal", tasks=[models.ConfigCycleTask(name="some_task")])],
7866
tasks=[models.ConfigShellTask(name="some_task", command="some_command")],
7967
data=models.ConfigData(
80-
available=available_datas,
68+
available=[
69+
models.ConfigAvailableData(name="available", type=models.DataType.FILE, src=pathlib.Path("foo.txt"))
70+
],
8171
generated=[models.ConfigGeneratedData(name="bar", type=models.DataType.DIR, src=pathlib.Path("bar"))],
8272
),
8373
parameters={},
8474
)
8575

8676

8777
@pytest.fixture(scope="session")
88-
def minimal_invert_task_io_config(available_datas) -> models.ConfigWorkflow:
78+
def minimal_invert_task_io_config() -> models.ConfigWorkflow:
8979
return models.ConfigWorkflow(
9080
name="minimal",
9181
rootdir=pathlib.Path("minimal"),
@@ -111,7 +101,9 @@ def minimal_invert_task_io_config(available_datas) -> models.ConfigWorkflow:
111101
models.ConfigShellTask(name="task_b", command="command_b"),
112102
],
113103
data=models.ConfigData(
114-
available=available_datas,
104+
available=[
105+
models.ConfigAvailableData(name="available", type=models.DataType.FILE, src=pathlib.Path("foo.txt"))
106+
],
115107
generated=[
116108
models.ConfigGeneratedData(name="output_a", type=models.DataType.DIR, src=pathlib.Path("bar")),
117109
models.ConfigGeneratedData(name="output_b", type=models.DataType.DIR, src=pathlib.Path("bar")),

0 commit comments

Comments
 (0)