diff --git a/recipe/meta.json b/recipe/meta.json index c37b5486b..faa658d13 100644 --- a/recipe/meta.json +++ b/recipe/meta.json @@ -33,5 +33,5 @@ "pyyaml =6.0.*" ] }, - "version": "2.4.1" + "version": "2.4.2" } diff --git a/src/uwtools/api/config.py b/src/uwtools/api/config.py index 2d402b1be..6cb54e6fd 100644 --- a/src/uwtools/api/config.py +++ b/src/uwtools/api/config.py @@ -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, diff --git a/src/uwtools/resources/info.json b/src/uwtools/resources/info.json index 3fc5690e5..ecb08defa 100644 --- a/src/uwtools/resources/info.json +++ b/src/uwtools/resources/info.json @@ -1,4 +1,4 @@ { - "version": "2.4.1", + "version": "2.4.2", "buildnum": "0" } diff --git a/src/uwtools/rocoto.py b/src/uwtools/rocoto.py index a04cda373..5c29fdafe 100644 --- a/src/uwtools/rocoto.py +++ b/src/uwtools/rocoto.py @@ -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: @@ -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 element to the . + + :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: @@ -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" diff --git a/src/uwtools/tests/api/test_config.py b/src/uwtools/tests/api/test_config.py index c2cd84e64..5506785c7 100644 --- a/src/uwtools/tests/api/test_config.py +++ b/src/uwtools/tests/api/test_config.py @@ -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 @@ -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} diff --git a/src/uwtools/tests/test_rocoto.py b/src/uwtools/tests/test_rocoto.py index 66032dc64..2c8b3fb67 100644 --- a/src/uwtools/tests/test_rocoto.py +++ b/src/uwtools/tests/test_rocoto.py @@ -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"}}})],