Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
adapt output names of files from statistics.py

expand the variables from the yaml file. might need to remove because it
could cause problems with codes that are defined on HPC

change labels a bit for tasks, TODO need to do the same for data
  • Loading branch information
agoscinski committed Dec 9, 2024
1 parent af7e4e4 commit f40e4c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/sirocco/parsing/_yaml_data_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from os.path import expandvars
import time
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -273,6 +274,12 @@ class ConfigTaskShell(ConfigTaskBase):
input_arg_options: dict[str, str] = Field(default_factory=dict)
src: str | None = None

@field_validator("command", "command_option", "src")
@classmethod
def expand_var(cls, value: str | None) -> str | None:
"""Expand environemnt variables"""
# TODO this might be not intended if we want to use environment variables on remote HPC
return None if value is None else expandvars(value)

class ConfigTaskIcon(ConfigTaskBase):
plugin: Literal["icon"]
Expand Down
7 changes: 4 additions & 3 deletions src/sirocco/workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def parse_to_aiida_label(label: str) -> str:
def get_aiida_label_from_unrolled_data(obj: core.BaseNode) -> str:
""" """
return AiidaWorkGraph.parse_to_aiida_label(
f"{obj.name}" + "_".join(f"_{key}_{value}" for key, value in obj.coordinates.items())
f"{obj.name}" + "__".join(f"_{key}_{value}" for key, value in obj.coordinates.items())
)

@staticmethod
Expand All @@ -136,9 +136,10 @@ def get_aiida_label_from_unrolled_task(obj: core.BaseNode) -> str:
# so do we check somewhere that a task is not used in multiple cycles?
# Otherwise the label is not unique
# --> task name + date + parameters
return AiidaWorkGraph.parse_to_aiida_label(
f"{obj.name}" + "_".join(f"_{key}_{value}" for key, value in obj.coordinates.items())
label = AiidaWorkGraph.parse_to_aiida_label(
"__".join([f"{obj.name}"] + [f"_{key}_{value}" for key, value in obj.coordinates.items()])
)
return label

def _add_aiida_input_data_node(self, input_: core.UnrolledData):
"""
Expand Down
9 changes: 5 additions & 4 deletions tests/files/configs/test_config_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cycles:
inputs:
- icon_output:
parameters:
# PR COMMENT: Is this the intention that multiple files can be taken by statistics.py here? it gets the icon_output for all the foo values
bar: single
outputs: [analysis_foo]
- statistics_foo_bar:
Expand Down Expand Up @@ -73,22 +74,22 @@ data:
generated:
- icon_output:
type: file
src: output
src: icon_output
parameters: [foo, bar]
- icon_restart:
type: file
src: restart
parameters: [foo, bar]
- analysis_foo:
type: file
src: analysis_foo
src: analysis
parameters: [bar]
- analysis_foo_bar:
type: file
src: foo_analysis_bar
src: analysis
- yearly_analysis:
type: file
src: yearly_analysis
src: analysis

parameters:
foo: [0, 1, 2]
Expand Down
2 changes: 1 addition & 1 deletion tests/files/scripts/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
args = parser.parse_args()


output = Path('output')
output = Path('icon_output')
output.write_text("")

if args.restart and args.init:
Expand Down

0 comments on commit f40e4c2

Please sign in to comment.