From cea5ab37c7b499982ecc86b6ee6f50fa2f9b01f9 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Tue, 8 Oct 2024 15:56:38 -0500 Subject: [PATCH 01/11] Updates to chgres_cube test coverage failing --- docs/shared/chgres_cube.yaml | 25 ++++++++++--------- src/uwtools/drivers/chgres_cube.py | 18 +++++++++---- .../jsonschema/chgres-cube.jsonschema | 10 ++------ src/uwtools/tests/drivers/test_chgres_cube.py | 23 +++++++++-------- src/uwtools/tests/test_schemas.py | 6 ++--- 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/docs/shared/chgres_cube.yaml b/docs/shared/chgres_cube.yaml index e7028d300..1b572a637 100644 --- a/docs/shared/chgres_cube.yaml +++ b/docs/shared/chgres_cube.yaml @@ -8,22 +8,23 @@ chgres_cube: namelist: update_values: config: + fix_dir_target_grid: /path/to/fix_lam + mosaic_file_target_grid: C432.mosaic.halo4.nc + orog_dir_target_grid: /path/to/fix_lam + orog_files_target_grid: C432.oro_data.tile7.halo4.nc + vcoord_file_target_grid: /path/to/global_hyblev.l65.txt + varmap_file: /path/to/varmap_table + data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }} + grib2_file_input_grid: a.file.gb2 atm_files_input_grid: atm.t{{cycle.strftime('%H') }}z.nc - convert_atm: true - convert_nst: true - convert_sfc: true + sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc cycle_day: !int "{{ cycle.strftime('%d') }}" cycle_hour: !int "{{ cycle.strftime('%H') }}" cycle_mon: !int "{{ cycle.strftime('%m') }}" - data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }} - fix_dir_target_grid: /path/to/fixdir - grib2_file_input_grid: a.file.gb2 - mosaic_file_target_grid: /path/to/mosaic/C432.mosaic.halo4.nc - orog_files_target_grid: /path/to/orog/C432.oro_data.tile7.halo4.nc - sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc - varmap_file: /path/to/varmap_table - vcoord_file_target_grid: /path/to/global_hyblev.l65.txt - validate: true + convert_atm: true + convert_nst: false + convert_sfc: true + validate: true rundir: /path/to/dir platform: account: me diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index 1cf6dca67..7c7016b4c 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -35,18 +35,26 @@ def namelist_file(self): input_files.append(base_file) if update_values := namelist.get(STR.updatevalues): config_files = update_values["config"] - for k in ["mosaic_file_target_grid", "vcoord_file_target_grid"]: - input_files.append(config_files[k]) + file_keys = ["mosaic_file_target_grid", "orog_files_target_grid"] + dir_keys = ["fix_dir_target_grid", "orog_dir_target_grid"] + for file_key, dir_key in zip(file_keys, dir_keys): + full_path = Path(config_files[dir_key]) / config_files[file_key] + input_files.append(full_path) for k in [ - "atm_core_files_input_grid", "atm_files_input_grid", - "atm_tracer_files_input_grid", "grib2_file_input_grid", + "sfc_files_input_grid", + ]: + full_path = Path(config_files[k]) / config_files["data_dir_input_grid"] + input_files.append(full_path) + for k in [ + "atm_core_files_input_grid", + "atm_tracer_files_input_grid", "nst_files_input_grid", "orog_files_input_grid", "orog_files_target_grid", - "sfc_files_input_grid", "varmap_file", + "vcoord_file_target_grid", ]: if k in config_files: v = config_files[k] diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index 15df5c93c..380f57023 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -27,14 +27,7 @@ "update_values": { "properties": { "config": { - "additionalProperties": { - "type": [ - "array", - "boolean", - "number", - "string" - ] - }, + "additionalProperties": false, "properties": { "atm_core_files_input_grid": { "items": { @@ -92,6 +85,7 @@ }, "external_model": { "enum": [ + "FV3GFS", "GFS", "HRRR", "NAM", diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index de399e7fe..b5a4f2c3e 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -47,21 +47,22 @@ def config(tmp_path): "namelist": { "update_values": { "config": { - "atm_core_files_input_grid": [str(afile), str(afile)], + "fix_dir_target_grid": "/path/to/dir", + "mosaic_file_target_grid": str(afile), + "orog_dir_target_grid": "/path/to/dir", + "orog_files_target_grid": str(afile), + "vcoord_file_target_grid": str(afile), + "varmap_file": str(afile), + "data_dir_input_grid": str(afile), "atm_files_input_grid": str(afile), - "atm_tracer_files_input_grid": str(afile), - "atm_weight_file": str(afile), + "sfc_files_input_grid": str(afile), + "grib2_file_input_grid": str(afile), + "tracers_input": [str(afile), str(afile)], + "tracers": [str(afile), str(afile)], "convert_atm": True, - "data_dir_input_grid": str(afile), + "input_type": "gaussian_nemsio", "external_model": "GFS", - "fix_dir_target_grid": "/path/to/dir", "geogrid_file_input_grid": str(afile), - "grib2_file_input_grid": str(afile), - "mosaic_file_input_grid": str(afile), - "mosaic_file_target_grid": str(afile), - "sfc_files_input_grid": str(afile), - "varmap_file": str(afile), - "vcoord_file_target_grid": str(afile), } }, "validate": True, diff --git a/src/uwtools/tests/test_schemas.py b/src/uwtools/tests/test_schemas.py index b2d616209..78973788f 100644 --- a/src/uwtools/tests/test_schemas.py +++ b/src/uwtools/tests/test_schemas.py @@ -527,9 +527,8 @@ def test_schema_chgres_cube_namelist_update_values(chgres_cube_config, chgres_cu # Some entries are required: for key in ["mosaic_file_target_grid", "vcoord_file_target_grid"]: assert "is a required property" in errors(with_del(config, key)) - # Additional entries of namelist-compatible types are permitted: - for val in [[1, 2, 3], True, 42, 3.14, "bar"]: - assert not errors(with_set(config, val, "foo")) + # Additional top-level keys are not allowed: + assert "Additional properties are not allowed" in errors({**config, "foo": "bar"}) # Namelist values must be of the correct type: # boolean: for key in [ @@ -590,6 +589,7 @@ def test_schema_chgres_cube_namelist_update_values(chgres_cube_config, chgres_cu ]: assert "is not of type 'array', 'string'\n" in errors(with_set(config, None, key)) assert "is not of type 'string'\n" in errors(with_set(config, [1, 2, 3], key)) + assert not errors(with_set(config, ["foo", "bar", "baz"], key)) # esg-grid From 4ea910c954379b640147aa1e2469a7e989084bbe Mon Sep 17 00:00:00 2001 From: WeirAE Date: Tue, 8 Oct 2024 17:50:35 -0500 Subject: [PATCH 02/11] revert key order; partial logic fix --- docs/shared/chgres_cube.yaml | 24 +++++++++---------- src/uwtools/drivers/chgres_cube.py | 7 +++--- .../jsonschema/chgres-cube.jsonschema | 8 ------- src/uwtools/tests/drivers/test_chgres_cube.py | 24 +++++++++---------- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/docs/shared/chgres_cube.yaml b/docs/shared/chgres_cube.yaml index 1b572a637..3d95e1d54 100644 --- a/docs/shared/chgres_cube.yaml +++ b/docs/shared/chgres_cube.yaml @@ -8,23 +8,23 @@ chgres_cube: namelist: update_values: config: + atm_files_input_grid: atm.t{{cycle.strftime('%H') }}z.nc + convert_atm: true + convert_nst: false + convert_sfc: true + cycle_day: !int "{{ cycle.strftime('%d') }}" + cycle_hour: !int "{{ cycle.strftime('%H') }}" + cycle_mon: !int "{{ cycle.strftime('%m') }}" + data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }} fix_dir_target_grid: /path/to/fix_lam + grib2_file_input_grid: a.file.gb2 mosaic_file_target_grid: C432.mosaic.halo4.nc orog_dir_target_grid: /path/to/fix_lam orog_files_target_grid: C432.oro_data.tile7.halo4.nc - vcoord_file_target_grid: /path/to/global_hyblev.l65.txt - varmap_file: /path/to/varmap_table - data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }} - grib2_file_input_grid: a.file.gb2 - atm_files_input_grid: atm.t{{cycle.strftime('%H') }}z.nc sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc - cycle_day: !int "{{ cycle.strftime('%d') }}" - cycle_hour: !int "{{ cycle.strftime('%H') }}" - cycle_mon: !int "{{ cycle.strftime('%m') }}" - convert_atm: true - convert_nst: false - convert_sfc: true - validate: true + varmap_file: /path/to/varmap_table + vcoord_file_target_grid: /path/to/global_hyblev.l65.txt + validate: true rundir: /path/to/dir platform: account: me diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index 7c7016b4c..c8c5d4af2 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -35,14 +35,15 @@ def namelist_file(self): input_files.append(base_file) if update_values := namelist.get(STR.updatevalues): config_files = update_values["config"] - file_keys = ["mosaic_file_target_grid", "orog_files_target_grid"] - dir_keys = ["fix_dir_target_grid", "orog_dir_target_grid"] + file_keys = ["mosaic_file_target_grid","orog_files_input_grid", "orog_files_target_grid"] + dir_keys = ["fix_dir_target_grid", "orog_dir_input_grid", "orog_dir_target_grid"] for file_key, dir_key in zip(file_keys, dir_keys): full_path = Path(config_files[dir_key]) / config_files[file_key] input_files.append(full_path) for k in [ "atm_files_input_grid", "grib2_file_input_grid", + "nst_files_input_grid", "sfc_files_input_grid", ]: full_path = Path(config_files[k]) / config_files["data_dir_input_grid"] @@ -50,9 +51,7 @@ def namelist_file(self): for k in [ "atm_core_files_input_grid", "atm_tracer_files_input_grid", - "nst_files_input_grid", "orog_files_input_grid", - "orog_files_target_grid", "varmap_file", "vcoord_file_target_grid", ]: diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index ff7668022..56f93db11 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -84,14 +84,6 @@ "type": "string" }, "external_model": { - "enum": [ - "FV3GFS", - "GFS", - "HRRR", - "NAM", - "RAP", - "UKMET" - ], "type": "string" }, "fix_dir_target_grid": { diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index 4d127fe55..be418b96e 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -47,22 +47,22 @@ def config(tmp_path): "namelist": { "update_values": { "config": { - "fix_dir_target_grid": "/path/to/dir", - "mosaic_file_target_grid": str(afile), - "orog_dir_target_grid": "/path/to/dir", - "orog_files_target_grid": str(afile), - "vcoord_file_target_grid": str(afile), - "varmap_file": str(afile), - "data_dir_input_grid": str(afile), + "atm_core_files_input_grid": [str(afile), str(afile)], "atm_files_input_grid": str(afile), - "sfc_files_input_grid": str(afile), - "grib2_file_input_grid": str(afile), - "tracers_input": [str(afile), str(afile)], - "tracers": [str(afile), str(afile)], + "atm_tracer_files_input_grid": str(afile), + "atm_weight_file": str(afile), "convert_atm": True, - "input_type": "gaussian_nemsio", + "data_dir_input_grid": str(afile), "external_model": "GFS", + "fix_dir_target_grid": "/path/to/dir", "geogrid_file_input_grid": str(afile), + "grib2_file_input_grid": str(afile), + "mosaic_file_input_grid": str(afile), + "mosaic_file_target_grid": str(afile), + "orog_dir_target_file": "/path/to/dir" + "sfc_files_input_grid": str(afile), + "varmap_file": str(afile), + "vcoord_file_target_grid": str(afile), } }, "validate": True, From ef41c921ed74aa07ed1822470c1cf9a398ce8aa4 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Tue, 8 Oct 2024 18:16:37 -0500 Subject: [PATCH 03/11] coverage fixed, partial logic updates --- src/uwtools/drivers/chgres_cube.py | 7 +++++-- src/uwtools/tests/drivers/test_chgres_cube.py | 6 +++++- src/uwtools/tests/test_schemas.py | 3 --- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index c8c5d4af2..ff8147a33 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -35,7 +35,11 @@ def namelist_file(self): input_files.append(base_file) if update_values := namelist.get(STR.updatevalues): config_files = update_values["config"] - file_keys = ["mosaic_file_target_grid","orog_files_input_grid", "orog_files_target_grid"] + file_keys = [ + "mosaic_file_target_grid", + "orog_files_input_grid", + "orog_files_target_grid", + ] dir_keys = ["fix_dir_target_grid", "orog_dir_input_grid", "orog_dir_target_grid"] for file_key, dir_key in zip(file_keys, dir_keys): full_path = Path(config_files[dir_key]) / config_files[file_key] @@ -51,7 +55,6 @@ def namelist_file(self): for k in [ "atm_core_files_input_grid", "atm_tracer_files_input_grid", - "orog_files_input_grid", "varmap_file", "vcoord_file_target_grid", ]: diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index be418b96e..d17df095a 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -59,7 +59,11 @@ def config(tmp_path): "grib2_file_input_grid": str(afile), "mosaic_file_input_grid": str(afile), "mosaic_file_target_grid": str(afile), - "orog_dir_target_file": "/path/to/dir" + "nst_files_input_grid": str(afile), + "orog_dir_input_grid": "/path/to/dir", + "orog_dir_target_grid": "/path/to/dir", + "orog_files_input_grid": str(afile), + "orog_files_target_grid": str(afile), "sfc_files_input_grid": str(afile), "varmap_file": str(afile), "vcoord_file_target_grid": str(afile), diff --git a/src/uwtools/tests/test_schemas.py b/src/uwtools/tests/test_schemas.py index 95f10bdb6..951d6447d 100644 --- a/src/uwtools/tests/test_schemas.py +++ b/src/uwtools/tests/test_schemas.py @@ -544,9 +544,6 @@ def test_schema_chgres_cube_namelist_update_values(chgres_cube_config, chgres_cu "wam_cold_start", ]: assert "not of type 'boolean'" in errors(with_set(config, None, key)) - # enum: - for key in ["external_model", "input_type"]: - assert "is not one of" in errors(with_set(config, None, key)) # integer: for key in [ "cycle_day", From bd2e7d1066d8a2b7ee6176e210e6c77a54dd4e91 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Wed, 9 Oct 2024 17:14:14 -0500 Subject: [PATCH 04/11] schema and key logic complete --- src/uwtools/drivers/chgres_cube.py | 38 +++++++++----- .../jsonschema/chgres-cube.jsonschema | 52 +++++++++++++++++++ src/uwtools/tests/drivers/test_chgres_cube.py | 6 +-- 3 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index ff8147a33..17833bd5b 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -36,28 +36,38 @@ def namelist_file(self): if update_values := namelist.get(STR.updatevalues): config_files = update_values["config"] file_keys = [ - "mosaic_file_target_grid", - "orog_files_input_grid", - "orog_files_target_grid", - ] - dir_keys = ["fix_dir_target_grid", "orog_dir_input_grid", "orog_dir_target_grid"] - for file_key, dir_key in zip(file_keys, dir_keys): - full_path = Path(config_files[dir_key]) / config_files[file_key] - input_files.append(full_path) - for k in [ "atm_files_input_grid", "grib2_file_input_grid", + "mosaic_file_target_grid", "nst_files_input_grid", "sfc_files_input_grid", - ]: - full_path = Path(config_files[k]) / config_files["data_dir_input_grid"] - input_files.append(full_path) - for k in [ + "orog_files_input_grid", + "orog_files_target_grid", + ] + path_keys = [ "atm_core_files_input_grid", "atm_tracer_files_input_grid", "varmap_file", "vcoord_file_target_grid", - ]: + ] + dir_keys = [ + "data_dir_input_grid", + "data_dir_input_grid", + "fix_dir_target_grid", + "data_dir_input_grid", + "data_dir_input_grid", + "orog_dir_input_grid", + "orog_dir_target_grid", + ] + for file_key, dir_key in zip(file_keys, dir_keys): + if file_key and dir_key in config_files: + v = config_files[file_key] + if isinstance(v, str): + full_path = Path(config_files[dir_key]) / config_files[file_key] + input_files.append(full_path) + else: + input_files += v + for k in path_keys: if k in config_files: v = config_files[k] if isinstance(v, str): diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index 56f93db11..3991ce5a5 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -28,6 +28,58 @@ "properties": { "config": { "additionalProperties": false, + "anyOf": [ + { + "required": [ + "data_dir_input_grid", + "atm_files_input_grid" + ] + }, + { + "required": [ + "data_dir_input_grid", + "grib2_files_input_grid" + ] + }, + { + "required": [ + "data_dir_input_grid", + "nst_files_input_grid" + ] + }, + { + "required": [ + "data_dir_input_grid", + "sfc_files_input_grid" + ] + } + ], + "dependencies": { + "atm_files_input_grid": [ + "data_dir_input_grid" + ], + "grib2_file_input_grid": [ + "data_dir_input_grid" + ], + "nst_files_input_grid": [ + "data_dir_input_grid" + ], + "orog_dir_input_grid": [ + "orog_files_input_grid" + ], + "orog_dir_target_grid": [ + "orog_files_target_grid" + ], + "orog_files_input_grid": [ + "orog_files_dir_grid" + ], + "orog_files_target_grid": [ + "orog_dir_target_grid" + ], + "sfc_files_input_grid": [ + "data_dir_input_grid" + ] + }, "properties": { "atm_core_files_input_grid": { "items": { diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index d17df095a..d42ca2afe 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -48,7 +48,7 @@ def config(tmp_path): "update_values": { "config": { "atm_core_files_input_grid": [str(afile), str(afile)], - "atm_files_input_grid": str(afile), + "atm_files_input_grid": [str(afile), str(afile)], "atm_tracer_files_input_grid": str(afile), "atm_weight_file": str(afile), "convert_atm": True, @@ -60,10 +60,6 @@ def config(tmp_path): "mosaic_file_input_grid": str(afile), "mosaic_file_target_grid": str(afile), "nst_files_input_grid": str(afile), - "orog_dir_input_grid": "/path/to/dir", - "orog_dir_target_grid": "/path/to/dir", - "orog_files_input_grid": str(afile), - "orog_files_target_grid": str(afile), "sfc_files_input_grid": str(afile), "varmap_file": str(afile), "vcoord_file_target_grid": str(afile), From b141aa58574dfbe79158a2e591402446dc3ccdec Mon Sep 17 00:00:00 2001 From: WeirAE Date: Wed, 9 Oct 2024 17:19:25 -0500 Subject: [PATCH 05/11] revert missed changes to chgres_cube.yaml --- docs/shared/chgres_cube.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/shared/chgres_cube.yaml b/docs/shared/chgres_cube.yaml index 3d95e1d54..d717b7395 100644 --- a/docs/shared/chgres_cube.yaml +++ b/docs/shared/chgres_cube.yaml @@ -10,16 +10,16 @@ chgres_cube: config: atm_files_input_grid: atm.t{{cycle.strftime('%H') }}z.nc convert_atm: true - convert_nst: false + convert_nst: true convert_sfc: true cycle_day: !int "{{ cycle.strftime('%d') }}" cycle_hour: !int "{{ cycle.strftime('%H') }}" cycle_mon: !int "{{ cycle.strftime('%m') }}" data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }} - fix_dir_target_grid: /path/to/fix_lam + fix_dir_target_grid: /path/to/fixdir grib2_file_input_grid: a.file.gb2 - mosaic_file_target_grid: C432.mosaic.halo4.nc - orog_dir_target_grid: /path/to/fix_lam + mosaic_file_target_grid: /path/to/mosaic/C432.mosaic.halo4.nc + orog_dir_target_grid: /path/to/fixdir orog_files_target_grid: C432.oro_data.tile7.halo4.nc sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc varmap_file: /path/to/varmap_table From 72cb4cb38740ed1cd7f1d343add686369726e33e Mon Sep 17 00:00:00 2001 From: WeirAE Date: Thu, 10 Oct 2024 10:35:51 -0500 Subject: [PATCH 06/11] cap python version for rtd environment --- docs/environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/environment.yml b/docs/environment.yml index ea7494fd7..da3733dc2 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,6 +2,7 @@ name: readthedocs channels: - conda-forge dependencies: + - python>=3.9,<3.14 - sphinx_rtd_theme=2.0.* - sphinxcontrib-bibtex=2.6.* - tree From 3622f5f1d793525847407ad23f2683166a955ee6 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Thu, 10 Oct 2024 10:36:26 -0500 Subject: [PATCH 07/11] fix pi brain typo --- docs/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/environment.yml b/docs/environment.yml index da3733dc2..5d9a898a4 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,7 +2,7 @@ name: readthedocs channels: - conda-forge dependencies: - - python>=3.9,<3.14 + - python>=3.9,<3.13 - sphinx_rtd_theme=2.0.* - sphinxcontrib-bibtex=2.6.* - tree From 4013bfafb32a0c09a1ced72815e59208ecc73410 Mon Sep 17 00:00:00 2001 From: Brian Weir <94982354+WeirAE@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:13:13 -0500 Subject: [PATCH 08/11] Update src/uwtools/resources/jsonschema/chgres-cube.jsonschema Co-authored-by: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> --- .../jsonschema/chgres-cube.jsonschema | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index 3991ce5a5..40b632e28 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -54,30 +54,30 @@ ] } ], - "dependencies": { - "atm_files_input_grid": [ - "data_dir_input_grid" - ], - "grib2_file_input_grid": [ - "data_dir_input_grid" - ], - "nst_files_input_grid": [ - "data_dir_input_grid" - ], - "orog_dir_input_grid": [ - "orog_files_input_grid" - ], - "orog_dir_target_grid": [ - "orog_files_target_grid" - ], - "orog_files_input_grid": [ - "orog_files_dir_grid" - ], - "orog_files_target_grid": [ - "orog_dir_target_grid" - ], - "sfc_files_input_grid": [ - "data_dir_input_grid" + "atm_core_files_input_grid": [ + "data_dir_input_grid" + ], + "atm_files_input_grid": [ + "data_dir_input_grid" + ], + "atm_tracer_files_input_grid": [ + "data_dir_input_grid" + ], + "grib2_file_input_grid": [ + "data_dir_input_grid" + ], + "nst_files_input_grid": [ + "data_dir_input_grid" + ], + "orog_files_input_grid": [ + "orog_dir_input_grid" + ], + "orog_files_target_grid": [ + "orog_dir_target_grid" + ], + "sfc_files_input_grid": [ + "data_dir_input_grid" + ], ] }, "properties": { From 2cb5a1918f9631015febface24d80d2474fb2877 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Thu, 10 Oct 2024 13:41:19 -0500 Subject: [PATCH 09/11] apply changes from comments --- docs/environment.yml | 2 +- src/uwtools/drivers/chgres_cube.py | 48 +++++++------------ .../jsonschema/chgres-cube.jsonschema | 48 +++++++++---------- src/uwtools/tests/drivers/test_chgres_cube.py | 4 ++ 4 files changed, 47 insertions(+), 55 deletions(-) diff --git a/docs/environment.yml b/docs/environment.yml index 5d9a898a4..e71700ed5 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,7 +2,7 @@ name: readthedocs channels: - conda-forge dependencies: - - python>=3.9,<3.13 + - python=3.12 - sphinx_rtd_theme=2.0.* - sphinxcontrib-bibtex=2.6.* - tree diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index 17833bd5b..2723a47be 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -35,45 +35,33 @@ def namelist_file(self): input_files.append(base_file) if update_values := namelist.get(STR.updatevalues): config_files = update_values["config"] - file_keys = [ - "atm_files_input_grid", + for k in ["mosaic_file_target_grid", "varmap_file", "vcoord_file_target_grid"]: + input_files.append(config_files[k]) + for k in [ + "atm_core_files_input_grid", + "atm_tracer_files_input_grid", "grib2_file_input_grid", - "mosaic_file_target_grid", "nst_files_input_grid", "sfc_files_input_grid", - "orog_files_input_grid", - "orog_files_target_grid", - ] - path_keys = [ - "atm_core_files_input_grid", - "atm_tracer_files_input_grid", - "varmap_file", - "vcoord_file_target_grid", - ] - dir_keys = [ - "data_dir_input_grid", - "data_dir_input_grid", - "fix_dir_target_grid", - "data_dir_input_grid", - "data_dir_input_grid", - "orog_dir_input_grid", - "orog_dir_target_grid", - ] - for file_key, dir_key in zip(file_keys, dir_keys): - if file_key and dir_key in config_files: - v = config_files[file_key] + ]: + if k in config_files: + grid_path = Path(config_files["data_dir_input_grid"]) + v = config_files[k] if isinstance(v, str): - full_path = Path(config_files[dir_key]) / config_files[file_key] - input_files.append(full_path) + input_files.append(grid_path / v) else: - input_files += v - for k in path_keys: + input_files.extend([grid_path / f for f in v]) + for k in [ + "orog_files_input_grid", + "orog_files_target_grid", + ]: if k in config_files: + grid_path = Path(config_files[k.replace("files", "dir")]) v = config_files[k] if isinstance(v, str): - input_files.append(v) + input_files.append(grid_path / v) else: - input_files += v + input_files.extend([grid_path / f for f in v]) yield [file(Path(input_file)) for input_file in input_files] self._create_user_updated_config( config_class=NMLConfig, diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index 40b632e28..abc931e84 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -54,30 +54,30 @@ ] } ], - "atm_core_files_input_grid": [ - "data_dir_input_grid" - ], - "atm_files_input_grid": [ - "data_dir_input_grid" - ], - "atm_tracer_files_input_grid": [ - "data_dir_input_grid" - ], - "grib2_file_input_grid": [ - "data_dir_input_grid" - ], - "nst_files_input_grid": [ - "data_dir_input_grid" - ], - "orog_files_input_grid": [ - "orog_dir_input_grid" - ], - "orog_files_target_grid": [ - "orog_dir_target_grid" - ], - "sfc_files_input_grid": [ - "data_dir_input_grid" - ], + "dependencies": { + "atm_core_files_input_grid": [ + "data_dir_input_grid" + ], + "atm_files_input_grid": [ + "data_dir_input_grid" + ], + "atm_tracer_files_input_grid": [ + "data_dir_input_grid" + ], + "grib2_file_input_grid": [ + "data_dir_input_grid" + ], + "nst_files_input_grid": [ + "data_dir_input_grid" + ], + "orog_files_input_grid": [ + "orog_dir_input_grid" + ], + "orog_files_target_grid": [ + "orog_dir_target_grid" + ], + "sfc_files_input_grid": [ + "data_dir_input_grid" ] }, "properties": { diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index d42ca2afe..b796005c6 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -59,6 +59,10 @@ def config(tmp_path): "grib2_file_input_grid": str(afile), "mosaic_file_input_grid": str(afile), "mosaic_file_target_grid": str(afile), + "orog_dir_input_grid": "/path/to/dir", + "orog_files_input_grid": [str(afile), str(afile)], + "orog_dir_target_grid": "/path/to/dir", + "orog_files_target_grid": str(afile), "nst_files_input_grid": str(afile), "sfc_files_input_grid": str(afile), "varmap_file": str(afile), From 9dbcbf114690115ae3d605de47deda29998a1a34 Mon Sep 17 00:00:00 2001 From: WeirAE Date: Thu, 10 Oct 2024 15:30:30 -0500 Subject: [PATCH 10/11] restore missing "atm_files_input_grid" --- src/uwtools/drivers/chgres_cube.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index 2723a47be..6dc9594d2 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -39,6 +39,7 @@ def namelist_file(self): input_files.append(config_files[k]) for k in [ "atm_core_files_input_grid", + "atm_files_input_grid", "atm_tracer_files_input_grid", "grib2_file_input_grid", "nst_files_input_grid", From d45b323355d7c340c53f4eee677cab5efd86e85e Mon Sep 17 00:00:00 2001 From: WeirAE Date: Thu, 10 Oct 2024 17:29:02 -0500 Subject: [PATCH 11/11] remove anyOf requirement with dir --- .../jsonschema/chgres-cube.jsonschema | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema index abc931e84..6a584d5ea 100644 --- a/src/uwtools/resources/jsonschema/chgres-cube.jsonschema +++ b/src/uwtools/resources/jsonschema/chgres-cube.jsonschema @@ -28,32 +28,6 @@ "properties": { "config": { "additionalProperties": false, - "anyOf": [ - { - "required": [ - "data_dir_input_grid", - "atm_files_input_grid" - ] - }, - { - "required": [ - "data_dir_input_grid", - "grib2_files_input_grid" - ] - }, - { - "required": [ - "data_dir_input_grid", - "nst_files_input_grid" - ] - }, - { - "required": [ - "data_dir_input_grid", - "sfc_files_input_grid" - ] - } - ], "dependencies": { "atm_core_files_input_grid": [ "data_dir_input_grid"