Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fv3-schema-update #405

Merged
merged 23 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
2 changes: 1 addition & 1 deletion docs/sections/user_guide/uw_yaml/forecast_yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ The MPI command used to run the model executable. Typical options are ``srun``,

``scheduler:``
^^^^^^^^^^^^^^
The name of the batch system. Supported options are ``lfs``, ``pbs``, and ``slurm``.
The name of the batch system. Supported options are ``lsf``, ``pbs``, and ``slurm``.
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved

The ``preprocessing:`` block
----------------------------
Expand Down
18 changes: 6 additions & 12 deletions src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run_cmd(self) -> str:
:return: Collated string that contains MPI command, runtime arguments, and exec name.
"""
components = [
self._platform_config.get("mpicmd"), # MPI run program
self._platform_config["mpicmd"], # MPI run program
*[str(x) for x in self._config["runtime_info"].get("mpi_args", [])], # MPI arguments
self._config["executable"], # NWP tool executable name
]
Expand Down Expand Up @@ -149,28 +149,22 @@ def _create_user_updated_config(
config_class: Type[Config], config_values: dict, output_path: OptionalPath
) -> None:
"""
The standard procedure for updating a file of a configuration class type with user-provided
values.
Create a config from a base file, user-provided values, of a combination of the two.

:param config_class: The Config subclass matching the configure file type.
:param config_values: The in-memory configuration object to update base values with.
:param config_class: The Config subclass matching the config type.
:param config_values: The configuration object to update base values with.
:param output_path: Optional path to dump file to.
"""

# User-supplied values that override any settings in the base
# file.
user_values = config_values.get("update_values", {})

if base_file := config_values.get("base_file"):
config_obj = config_class(base_file)
config_obj.update_values(user_values)
config_obj.dereference()
config_obj.dump(output_path)
else:
config_class.dump_dict(cfg=user_values, path=output_path)

msg = f"Configure file {output_path} created"
log.info(msg)
if output_path:
log.info(f"Wrote config to {output_path}")

def _validate(self) -> bool:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/drivers/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def resources(self) -> Mapping:
"""

return {
"account": self._experiment_config["user"]["account"],
"account": self._experiment_config["platform"]["account"],
"scheduler": self._experiment_config["platform"]["scheduler"],
**self._config["jobinfo"],
}
Expand Down
249 changes: 195 additions & 54 deletions src/uwtools/resources/FV3Forecast.jsonschema
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
{
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"$defs": {
"updatable_config": {
"additionalProperties": false,
"properties": {
"properties": {
"base_file": {
"format": "uri",
"type": "string"
},
"update_values": {
"type": "object"
}
},
"required": [
"base_file"
],
"type": "object"
}
"filesToStage": {
"minProperties": 1,
"patternProperties": {
"^.*$": {
"type": "string"
}
},
"type": "object"
}
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
},
"description": "This document is to validate user-defined FV3 forecast config files",
"properties": {
"forecast": {
"additionalProperties": false,
"description": "parameters of the forecast",
"properties": {
"cycle_dependent|static": {
"propertyNames": {
"type": "string"
},
"type": "object"
},
"diag_table": {
"format": "uri",
"type": "string"
},
"domain": {
Expand All @@ -43,44 +25,199 @@
"type": "string"
},
"executable": {
"format": "uri",
"type": "string"
},
"fd_ufs": {
"$ref": "#/$defs/updatable_config"
},
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"field_table": {
"$ref": "#/$defs/updatable_config"
"additionalProperties": false,
"anyOf": [
{
"required": [
"base_file"
]
},
{
"required": [
"update_values"
]
}
],
"properties": {
"base_file": {
"type": "string"
},
"update_values": {
"minProperties": 1,
"patternProperties": {
"^.*$": {
"additionalProperties": false,
"properties": {
"longname": {
"type": "string"
},
"profile_type": {
"additionalProperties": false,
"allOf": [
{
"if": {
"properties": {
"name": {
"const": "profile"
}
}
},
"then": {
"required": [
"top_value"
]
}
}
],
"properties": {
"name": {
"enum": [
"fixed",
"profile"
]
},
"surface_value": {
"type": "number"
},
"top_value": {
"type": "number"
}
},
"required": [
"name",
"surface_value"
],
"type": "object"
},
"units": {
"type": "string"
}
},
"required": [
"longname",
"profile_type",
"units"
],
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
},
"files_to_copy": {
"$ref": "#/$defs/filesToStage"
},
"files_to_link": {
"$ref": "#/$defs/filesToStage"
},
"length": {
"minimum": 1,
"type": "integer"
},
"model_configure": {
"$ref": "#/$defs/updatable_config"
},
"mpicmd": {
"type": "string"
"additionalProperties": false,
"properties": {
"base_file": {
"type": "string"
},
"update_values": {
"minProperties": 1,
"patternProperties": {
"^.*$": {
"type": [
"boolean",
"number",
"string"
]
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
}
},
"type": "object"
}
},
"required": [
"base_file"
],
"type": "object"
},
"namelist": {
"$ref": "#/$defs/updatable_config"
"additionalProperties": false,
"properties": {
"base_file": {
"type": "string"
},
"update_values": {
"minProperties": 1,
"patternProperties": {
"^.*$": {
"minProperties": 1,
"patternProperties": {
"^.*$": {
"minProperties": 1,
"type": [
"array",
"boolean",
"number",
"string"
]
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
},
"type": "object"
},
"type": "object"
}
},
"type": "object"
}
},
"required": [
"base_file"
],
"type": "object"
},
"run_dir": {
"format": "uri",
"type": "string"
},
"ufs_configure": {
"format": "uri",
"type": "string"
"runtime_info": {
"additionalProperties": false,
"properties": {
"mpi_args": {
"items": {
"type": "string"
},
"type": "array"
},
"threads": {
"type": "integer"
}
},
"type": "object"
}
},
"required": [
"field_table",
"run_dir",
"runtime_info"
],
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"type": "object"
},
"platform": {
"additionalProperties": false,
"dependentRequired": {
"scheduler": [
"account"
]
},
"properties": {
"required": [
"mpicmd"
],
"account": {
"type": "string"
},
"mpicmd": {
"type": "string"
},
"scheduler": {
"enum": [
"lsf",
Expand All @@ -90,41 +227,45 @@
"type": "string"
}
},
"required": [
"mpicmd"
],
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"type": "object"
},
"preprocessing": {
"additionalProperties": false,
"properties": {
"lateral_boundary_conditions": {
"additionalProperties": false,
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"properties": {
"interval_hours": {
"default": 3,
"minimum": 1,
"type": "number"
"type": "integer"
},
"offset": {
"default": 0,
"minimum": 0,
"type": "number"
"type": "integer"
},
"output_file_path": {
"format": "uri",
"type": "string"
}
},
"required": [
"interval_hours",
"offset",
"output_file_path"
],
"type": "object"
}
},
"required": [
"lateral_boundary_conditions"
],
maddenp-noaa marked this conversation as resolved.
Show resolved Hide resolved
"type": "object"
},
"user": {
"properties": {
"account": {
"type": "string"
}
},
"type": "object"
}
},
"title": "FV3 Forecast config",
"type": "object"
}
Loading
Loading