Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/sections/user_guide/yaml/rocoto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Starting at the top level of the UW YAML config for Rocoto, there are several re
entities:
ACCOUNT: myaccount
FOO: test.log
log:
log:
value: /some/path/to/&FOO;
tasks:
...
Expand Down Expand Up @@ -100,7 +100,7 @@ The ``attrs:`` and ``cyclestr`` blocks are optional within the ``log:`` block. F
It corresponds to the ``<log>`` tag. For example:

.. code-block:: xml

<log verbosity="10">
<cyclestr>/some/path/to/&FOO;</cyclestr>
</log>
Expand Down Expand Up @@ -134,7 +134,7 @@ Wherever a ``cyclestr:`` block is accepted, a YAML sequence mixing text and ``cy
.. code-block:: yaml

log:
- value:
value:
- cyclestr:
value: "%Y%m%d%H"
- -through-
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
"requests >=2.32,<2.33"
]
},
"version": "2.8.1"
"version": "2.8.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 @@
{
"buildnum": "0",
"version": "2.8.1"
"version": "2.8.2"
}
3 changes: 2 additions & 1 deletion src/uwtools/resources/jsonschema/upp-namelist.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"ioform": {
"enum": [
"binarynemsio",
"netcdf"
"netcdf",
"netcdfpara"
],
"type": "string"
},
Expand Down
4 changes: 3 additions & 1 deletion src/uwtools/rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ def _add_task_dependency_sh(
:param name_attr: XML name attribute for element.
"""
e = self._add_compound_time_string(e, config[STR.command], STR.sh)
config[STR.attrs][STR.name] = name_attr
config[STR.attrs] = config.get(STR.attrs, {})
if name_attr:
config[STR.attrs][STR.name] = name_attr
self._set_attrs(e, config)

def _add_task_dependency_strequality(self, e: _Element, config: dict, tag: str) -> None:
Expand Down
14 changes: 13 additions & 1 deletion src/uwtools/tests/test_rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,19 @@ def test__add_task_dependency_operator_timedep_operand(self, instance, root):
assert e.tag == "timedep"
assert e.text == str(value)

def test__add_task_dependency_sh(self, instance, root):
def test__add_task_dependency_sh__no_attrs(self, instance, root):
config = {"sh_foo": {"command": "ls"}}
errors = schema_validator("rocoto", "$defs", "dependency")
assert not errors(config)
instance._add_task_dependency(e=root, config=config)
dependency = root[0]
assert dependency.tag == "dependency"
sh = dependency[0]
assert sh.tag == "sh"
assert sh.get("name") == "foo"
assert sh.text == "ls"

def test__add_task_dependency_sh__with_attrs(self, instance, root):
config = {"sh_foo": {"attrs": {"runopt": "-c", "shell": "/bin/bash"}, "command": "ls"}}
errors = schema_validator("rocoto", "$defs", "dependency")
assert not errors(config)
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ def test_schema_upp_namelist(upp_prop):
assert "not one of ['grib2']" in errors({"update_values": {"model_inputs": {"grib": "grib1"}}})
assert "not of type 'string'" in errors({"update_values": {"model_inputs": {"grib": 42}}})
# model_inputs: Only certain ioform values are supported:
assert "not one of ['binarynemsio', 'netcdf']" in errors(
assert "not one of ['binarynemsio', 'netcdf', 'netcdfpara']" in errors(
{"update_values": {"model_inputs": {"ioform": "jpg"}}}
)
# model_inputs: Only certain modelname values are supported:
Expand Down
11 changes: 6 additions & 5 deletions src/uwtools/tests/utils/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def test_utils_tasks_filecopy__source_http(code, expected, src, tmp_path):
with patch.object(tasks, "requests") as requests:
response = requests.get()
response.status_code = code
response.content = b"data"
response.iter_content.return_value = iter([b"f", b"o", b"o"])
tasks.filecopy(src=src, dst=dst)
requests.get.assert_called_with(src, allow_redirects=True, timeout=3)
requests.get.assert_called_with(src, allow_redirects=True, stream=True, timeout=3)
assert dst.is_file() is expected


Expand Down Expand Up @@ -238,12 +238,13 @@ def test_utils_tasks_filecopy_http(ready_task, tmp_path):
patch.object(tasks.requests, "get") as get,
patch.object(tasks, "existing_http", wraps=ready_task) as existing_http,
):
response = Mock(status_code=200, content=b"data")
response = Mock(status_code=200)
response.iter_content.return_value = iter([b"f", b"o", b"o"])
get.return_value = response
tasks.filecopy_http(url=url, dst=dst)
existing_http.assert_called_once_with(url)
get.assert_called_once_with(url, allow_redirects=True, timeout=3)
assert dst.exists()
get.assert_called_once_with(url, allow_redirects=True, stream=True, timeout=3)
assert dst.read_bytes() == b"foo"


def test_utils_tasks_filecopy_local(tmp_path):
Expand Down
6 changes: 4 additions & 2 deletions src/uwtools/utils/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ def filecopy_http(url: str, dst: Path, check: bool = True):
yield asset(dst, dst.is_file)
yield existing_http(url) if check else None
dst.parent.mkdir(parents=True, exist_ok=True)
response = requests.get(url, allow_redirects=True, timeout=3)
response = requests.get(url, allow_redirects=True, stream=True, timeout=3)
if (code := response.status_code) == HTTPStatus.OK:
dst.write_bytes(response.content)
with dst.open(mode="wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
else:
log.error("Could not get '%s', HTTP status was: %s", url, code)

Expand Down