Skip to content

Commit

Permalink
Fix issue with creating a metatask dep. (#589)
Browse files Browse the repository at this point in the history
The rocoto schema is set up to allow metataskdep entries in the YAML, but the logic was not included in the tool to handle them. This addition fixes that.
  • Loading branch information
christinaholtNOAA authored Aug 22, 2024
1 parent ba08c9d commit 161823b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion recipe/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
"pyyaml =6.0.*"
]
},
"version": "2.4.1"
"version": "2.4.2"
}
2 changes: 1 addition & 1 deletion src/uwtools/resources/info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.4.1",
"version": "2.4.2",
"buildnum": "0"
}
12 changes: 12 additions & 0 deletions src/uwtools/rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def _add_task_dependency_child(self, e: _Element, config: dict, tag: str) -> Non
self._add_task_dependency_datadep(e, config)
elif tag == STR.taskdep:
self._add_task_dependency_taskdep(e, config)
elif tag == STR.metataskdep:
self._add_task_dependency_metataskdep(e, config)
elif tag == STR.taskvalid:
self._add_task_dependency_taskvalid(e, config)
elif tag == STR.timedep:
Expand All @@ -235,6 +237,15 @@ def _add_task_dependency_datadep(self, e: _Element, config: dict) -> None:
e = self._add_compound_time_string(e, config[STR.value], STR.datadep)
self._set_attrs(e, config)

def _add_task_dependency_metataskdep(self, e: _Element, config: dict) -> None:
"""
Add a <metataskdep> element to the <dependency>.
:param e: The parent element to add the new element to.
:param config: Configuration data for this element.
"""
self._set_attrs(SubElement(e, STR.metataskdep), config)

def _add_task_dependency_sh(
self, e: _Element, config: dict, name_attr: Optional[str] = None
) -> None:
Expand Down Expand Up @@ -437,6 +448,7 @@ class STR:
log: str = "log"
memory: str = "memory"
metatask: str = "metatask"
metataskdep: str = "metataskdep"
name: str = "name"
nand: str = "nand"
native: str = "native"
Expand Down
9 changes: 9 additions & 0 deletions src/uwtools/tests/test_rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ def test__add_task_dependency_fail_bad_operand(self, instance, root):
with raises(UWConfigError):
instance._add_task_dependency(e=root, config=config)

def test__add_task_dependency_metataskdep(self, instance, root):
config = {"metataskdep": {"attrs": {"metatask": "foo"}}}
instance._add_task_dependency(e=root, config=config)
dependency = root[0]
assert dependency.tag == "dependency"
child = dependency[0]
assert child.tag == "metataskdep"
assert child.get("metatask") == "foo"

@mark.parametrize(
"tag_config",
[("and", {"strneq": {"attrs": {"left": "&RUN_GSI;", "right": "YES"}}})],
Expand Down

0 comments on commit 161823b

Please sign in to comment.