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
118 changes: 58 additions & 60 deletions src/uwtools/resources/jsonschema/cdeps.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,48 @@
"^stream0[1-9]$": {
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"end_point": {
"type": "string"
},
"files": {
"items": {
"type": "string"
},
"type": "array"
},
"fxx": {
"type": "number"
},
"length": {
"type": "number"
},
"overwrite": {
"type": "boolean"
},
"protocol": {
"enum": [
"herbie",
"wget",
"s3"
]
},
"source": {
"enum": [
"hrrr",
"gfs"
]
},
"subset": {
"type": "boolean"
},
"target_directory": {
"type": "string"
}
}
},
"dtlimit": {
"type": "number"
},
Expand All @@ -31,48 +73,6 @@
},
"type": "array"
},
"data": {
"additionalProperties": false,
"properties": {
"source": {
"enum": [
"hrrr",
"gfs"
]
},
"length": {
"type": "number"
},
"fxx": {
"type": "number"
},
"subset": {
"type": "boolean"
},
"overwrite": {
"type": "boolean"
},
"target_directory": {
"type": "string"
},
"protocol": {
"enum": [
"herbie",
"wget",
"s3"
]
},
"end_point": {
"type": "string"
},
"files": {
"items": {
"type": "string"
},
"type": "array"
}
}
},
"stream_lev_dimname": {
"type": "string"
},
Expand Down Expand Up @@ -140,6 +140,9 @@
"base_file": {
"type": "string"
},
"streams": {
"$ref": "#/$defs/streams"
},
"update_values": {
"properties": {
"datm_nml": {
Expand Down Expand Up @@ -227,15 +230,11 @@
"datm_nml"
],
"type": "object"
},
"streams": {
"$ref": "#/$defs/streams"
},
"required": [
"streams"
],
"type": "object"
}
},
"required": [
"streams"
],
"type": "object"
},
"docn": {
Expand All @@ -256,6 +255,9 @@
"base_file": {
"type": "string"
},
"streams": {
"$ref": "#/$defs/streams"
},
"update_values": {
"properties": {
"docn_nml": {
Expand Down Expand Up @@ -303,21 +305,17 @@
"docn_nml"
],
"type": "object"
},
"streams": {
"$ref": "#/$defs/streams"
},
"required": [
"streams"
],
"type": "object"
}
},
"required": [
"streams"
],
"type": "object"
},
"template_file": {
"rundir": {
"type": "string"
},
"rundir": {
"template_file": {
"type": "string"
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/tests/drivers/test_cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_CDEPS_nml(caplog, driverobj, group):
log.setLevel(logging.DEBUG)
dst = driverobj.rundir / f"d{group}_in"
assert not dst.is_file()
del driverobj._config[f"{group}_in"]["base_file"]
del driverobj._config[f"d{group}"]["base_file"]
task = getattr(driverobj, f"{group}_nml")
path = Path(refs(task()))
assert dst.is_file()
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_CDEPS_streams(driverobj, group):
template_file = driverobj.rundir.parent / "template.jinja2"
with open(template_file, "w", encoding="utf-8") as f:
print(dedent(template).strip(), file=f)
driverobj._config[f"{group}_streams"]["template_file"] = template_file
driverobj._config["template_file"] = template_file
task = getattr(driverobj, f"{group}_stream")
path = Path(refs(task()))
assert dst.is_file()
Expand Down
22 changes: 8 additions & 14 deletions src/uwtools/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}
},
},
"template_file": "/path/to/atm.jinja2"
"template_file": "/path/to/atm.jinja2",
}


Expand Down Expand Up @@ -478,32 +478,26 @@ def test_schema_cdeps_streams(cdeps_config, section):
# Values must be of the correct types:
valerr = lambda k, v: errors(with_set(block, v, "streams", "stream01", k))
# enum:
ks_enum = ["readmode"]
assert "is not one of" in valerr("readmode", None)
# integer:
ks_integer = ["stream_offset", "yearAlign", "yearFirst", "yearLast"]
for k in ks_integer:
for k in ["stream_offset", "yearAlign", "yearFirst", "yearLast"]:
assert "is not of type 'integer'\n" in valerr(k, None)
# number:
ks_number = ["dtlimit"]
for k in ks_number:
for k in ["dtlimit"]:
assert "is not of type 'number'\n" in valerr(k, None)
# string:
ks_string = ["mapalgo", "stream_lev_dimname", "stream_mesh_file", "taxmode", "tinterpalgo"]
for k in ks_string:
for k in ["mapalgo", "stream_lev_dimname", "stream_mesh_file", "taxmode", "tinterpalgo"]:
assert "is not of type 'string'\n" in valerr(k, None)
# string arrays:
ks_string_array = ["stream_data_files", "stream_data_variables"]
for k in ks_string_array:
for k in ["stream_data_files", "stream_data_variables"]:
assert "is not of type 'array'\n" in valerr(k, None)
assert "is not of type 'string'\n" in valerr(k, [1])
# string or string array:
ks_string_or_string_array = ["stream_vectors"]
for k in ks_string_or_string_array:
for k in ["stream_vectors"]:
assert "is not of type 'array', 'string'\n" in valerr(k, None)
assert "is not of type 'string'\n" in valerr(k, [1])
# All keys are required:
for k in ks_enum + ks_integer + ks_number + ks_string + ks_string_array:
# Some keys are required:
for k in ["stream_data_files", "stream_data_variables", "stream_mesh_file"]:
assert "is a required property" in errors(with_del(block, "streams", "stream01", k))


Expand Down
Loading