From a068d8c65673bdd0e717ca790e67d8e41ffd5003 Mon Sep 17 00:00:00 2001 From: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:20:57 -0600 Subject: [PATCH] Allow native with cores and nodes. (#554) * The native flag may show up with the other resources. * Update src/uwtools/tests/test_schemas.py Co-authored-by: NaureenBharwaniNOAA <136371446+NaureenBharwaniNOAA@users.noreply.github.com> --------- Co-authored-by: NaureenBharwaniNOAA <136371446+NaureenBharwaniNOAA@users.noreply.github.com> --- .../user_guide/cli/tools/rocoto/rocoto.yaml | 1 + .../resources/jsonschema/rocoto.jsonschema | 34 +++++++++---------- .../tests/fixtures/hello_workflow.yaml | 1 + src/uwtools/tests/test_schemas.py | 12 +++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/sections/user_guide/cli/tools/rocoto/rocoto.yaml b/docs/sections/user_guide/cli/tools/rocoto/rocoto.yaml index eac2c7fa5..41614a40d 100644 --- a/docs/sections/user_guide/cli/tools/rocoto/rocoto.yaml +++ b/docs/sections/user_guide/cli/tools/rocoto/rocoto.yaml @@ -17,6 +17,7 @@ workflow: account: "&ACCOUNT;" command: "echo hello $person" jobname: hello + native: --reservation my_reservation nodes: 1:ppn=1 walltime: 00:01:00 envars: diff --git a/src/uwtools/resources/jsonschema/rocoto.jsonschema b/src/uwtools/resources/jsonschema/rocoto.jsonschema index fded4633c..1b3bcbf0f 100644 --- a/src/uwtools/resources/jsonschema/rocoto.jsonschema +++ b/src/uwtools/resources/jsonschema/rocoto.jsonschema @@ -290,6 +290,23 @@ }, "task": { "additionalProperties": false, + "anyOf": [ + { + "required": [ + "cores" + ] + }, + { + "required": [ + "native" + ] + }, + { + "required": [ + "nodes" + ] + } + ], "dependentSchemas": { "exclusive": { "not": { @@ -328,23 +345,6 @@ ] } }, - "oneOf": [ - { - "required": [ - "cores" - ] - }, - { - "required": [ - "native" - ] - }, - { - "required": [ - "nodes" - ] - } - ], "properties": { "account": { "type": "string" diff --git a/src/uwtools/tests/fixtures/hello_workflow.yaml b/src/uwtools/tests/fixtures/hello_workflow.yaml index b7d524ae5..be9a10607 100644 --- a/src/uwtools/tests/fixtures/hello_workflow.yaml +++ b/src/uwtools/tests/fixtures/hello_workflow.yaml @@ -23,6 +23,7 @@ workflow: attrs: offset: 01:00 value: hello-@Y@m@d@H + native: --reservation my_reservation nodes: 1:ppn=1 walltime: 00:01:00 envars: diff --git a/src/uwtools/tests/test_schemas.py b/src/uwtools/tests/test_schemas.py index 2d2016c01..da91ae96d 100644 --- a/src/uwtools/tests/test_schemas.py +++ b/src/uwtools/tests/test_schemas.py @@ -1664,6 +1664,18 @@ def test_schema_rocoto_workflow_cycledef(): assert "'foo' is not valid" in errors([{"attrs": {"activation_offset": "foo"}, "spec": spec}]) +def test_schena_rocoto_task_resources(): + errors = schema_validator("rocoto", "$defs", "task", "properties") + # Basic resource options + assert not errors([{"cores": 1}]) + assert not errors([{"native": "abc"}]) + assert not errors([{"native": {"cyclestr": {"value": "def"}}}]) + assert not errors([{"nodes": "1:ppn=12"}]) + # Combined valid resources + assert not errors([{"cores": 1, "native": "abc"}]) + assert not errors([{"native": "abc", "nodes": "1:ppn=12"}]) + + # schism