Skip to content

Commit

Permalink
Add option to specify computer for available data items
Browse files Browse the repository at this point in the history
This allows to specify data items that are only remotely available or
should not be copied over to the aiida internal folder. I did not add
the computer information to the IR because the IR focuses on
representing the unrolling/expansion from the config to a graph and the
computer information is completely independent from this logic.
  • Loading branch information
agoscinski committed Jan 9, 2025
1 parent 4b77727 commit b23168b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/sirocco/parsing/_yaml_data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 8 additions & 1 deletion src/sirocco/workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/cases/small/config/test_config_small.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ data:
src: data/input
- initial_conditions:
type: file
computer: localhost
src: data/initial_conditions
generated:
- icon_output:
Expand Down

0 comments on commit b23168b

Please sign in to comment.