Skip to content

Commit

Permalink
2.4.2 prep (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa authored Aug 22, 2024
1 parent 1365b39 commit 22f6ba9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 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"
}
4 changes: 3 additions & 1 deletion src/uwtools/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ def realize(
"""
NB: This docstring is dynamically replaced: See realize.__doc__ definition below.
"""
if update_config is None and update_format is not None: # i.e. updates will be read from stdin
update_config = _ensure_data_source(update_config, stdin_ok)
return _realize(
input_config=_ensure_data_source(_str2path(input_config), stdin_ok),
input_format=input_format,
update_config=_ensure_data_source(_str2path(update_config), stdin_ok),
update_config=_str2path(update_config),
update_format=update_format,
output_file=_str2path(output_file),
output_format=output_format,
Expand Down
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
29 changes: 27 additions & 2 deletions src/uwtools/tests/api/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from unittest.mock import patch

import yaml
from pytest import mark
from pytest import mark, raises

from uwtools.api import config
from uwtools.config.formats.yaml import YAMLConfig
from uwtools.exceptions import UWConfigError
from uwtools.exceptions import UWConfigError, UWError
from uwtools.utils.file import FORMAT


Expand Down Expand Up @@ -92,6 +92,31 @@ def test_realize_to_dict():
)


def test_realize_update_config_from_stdin():
with raises(UWError) as e:
config.realize(input_config={}, output_file="output.yaml", update_format="yaml")
assert str(e.value) == "Set stdin_ok=True to permit read from stdin"


def test_realize_update_config_none():
input_config = {"n": 88}
output_file = Path("output.yaml")
with patch.object(config, "_realize") as _realize:
config.realize(input_config=input_config, output_file=output_file)
_realize.assert_called_once_with(
input_config=input_config,
input_format=None,
update_config=None,
update_format=None,
output_file=output_file,
output_format=None,
key_path=None,
values_needed=False,
total=False,
dry_run=False,
)


@mark.parametrize("cfg", [{"foo": "bar"}, YAMLConfig(config={})])
def test_validate(cfg):
kwargs: dict = {"schema_file": "schema-file", "config": cfg}
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 22f6ba9

Please sign in to comment.