pymetkit.paramdb.models#

Pydantic models for pymetkit parameter metadata.

Classes#

MarsRequestContext

A MARS-key context that (partly) selects a parameter id.

ParameterEntry

A single entry from the ECMWF parameter database.

Module Contents#

class MarsRequestContext(/, **data: Any)#

Bases: pydantic.BaseModel

A MARS-key context that (partly) selects a parameter id.

This mirrors a single matcher rule from share/metkit/params.yaml. Its schema is kept separate from ParameterEntry so the context contract can evolve independently and so user-supplied context schemas can validate against it. All fields are optional because params.yaml rules do not always constrain every key (e.g. levtype is occasionally absent).

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class_: str | None = None#
stream: str | None = None#
type: str | None = None#
levtype: str | None = None#
class ParameterEntry(/, **data: Any)#

Bases: pydantic.BaseModel

A single entry from the ECMWF parameter database.

This model accepts the canonical field names only (shortname / longname). Raw API alias spellings (e.g. shortName, name) are NOT accepted and must be normalised to canonical keys before validation.

The JSON schema emitted from this model (and bundled as parameter_entry_schema.json) mirrors this contract: it validates the canonical keys only.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: int = None#
shortname: str = None#
longname: str = None#
units: str = None#
table: int | None = None#
mars_request_context: list[MarsRequestContext] = None#
origin_ids: list[int] = None#
access_ids: list[str] = None#
classmethod coerce_id_to_int(v: Any) int#
classmethod normalise_shortname_key(v: Any) str#
classmethod normalise_longname_key(v: Any) str#
classmethod default_empty_units(v: Any) str#
classmethod coerce_table(v: Any) int | None#
classmethod coerce_origin_ids(v: Any) list[int]#
classmethod coerce_access_ids(v: Any) list[str]#