diff --git a/src/sirocco/parsing/_yaml_data_models.py b/src/sirocco/parsing/_yaml_data_models.py index d5920d0..9a5b6fa 100644 --- a/src/sirocco/parsing/_yaml_data_models.py +++ b/src/sirocco/parsing/_yaml_data_models.py @@ -390,6 +390,7 @@ class ConfigBaseDataSpecs: type: str | None = None src: str | None = None format: str | None = None + computer: str | None = None class ConfigBaseData(_NamedBaseModel, ConfigBaseDataSpecs): @@ -417,7 +418,13 @@ class ConfigAvailableData(ConfigBaseData): class ConfigGeneratedData(ConfigBaseData): - pass + @field_validator("computer") + @classmethod + def invalid_field(cls, value: str | None) -> str | None: + if value is not None: + msg = "The field 'computer' can only be specified for available data." + raise ValueError(msg) + return value class ConfigData(BaseModel): diff --git a/src/sirocco/workgraph.py b/src/sirocco/workgraph.py index 5eb9127..772fe8b 100644 --- a/src/sirocco/workgraph.py +++ b/src/sirocco/workgraph.py @@ -145,7 +145,14 @@ def _add_aiida_input_data_node(self, task: graph_items.Task, input_: graph_items input_path = Path(input_.src) input_full_path = input_.src if input_path.is_absolute() else task.config_rootdir / input_path - if input_.type == "file": + if input_.computer is not None: + try: + computer = aiida.orm.load_computer(input_.computer) + except NotExistent as err: + msg = f"Could not find computer {input_.computer!r} for input {input_}." + raise ValueError(msg) from err + self._aiida_data_nodes[label] = aiida.orm.RemoteData(remote_path=input_.src, label=label, computer=computer) + elif input_.type == "file": self._aiida_data_nodes[label] = aiida.orm.SinglefileData(label=label, file=input_full_path) elif input_.type == "dir": self._aiida_data_nodes[label] = aiida.orm.FolderData(label=label, tree=input_full_path) diff --git a/tests/cases/small/config/test_config_small.yml b/tests/cases/small/config/test_config_small.yml index 3dd6fbe..75098c2 100644 --- a/tests/cases/small/config/test_config_small.yml +++ b/tests/cases/small/config/test_config_small.yml @@ -42,6 +42,7 @@ data: src: data/input - initial_conditions: type: file + computer: localhost src: data/initial_conditions generated: - icon_output: