hydromodpy.core.config_kit.field_metadata#

Typed convention for Field(json_schema_extra=...) metadata.

The codebase attaches UI hints, calibration bindings, and serialisation flags through json_schema_extra. This module defines the canonical key set so typos surface during validation and tooling can rely on a stable contract.

Use field_metadata() when declaring a new Field:

from hydromodpy.core.config_kit.field_metadata import field_metadata

k_aquifer: Annotated[float, Profile.USER] = Field(
    default=1e-5,
    description="Hydraulic conductivity.",
    json_schema_extra=field_metadata(
        widget_type="input",
        unit="m/s",
        display_name_fr="Conductivite hydraulique",
    ),
)

The helper rejects unknown keys at module import time, catching typos in CI rather than at first JSON schema export.

Module attributes

WidgetType

UI widget hint consumed by the Streamlit/React frontend.

Stability

Maturity tag attached to a field.

Functions

field_metadata(**kwargs)

Build a validated json_schema_extra dict.

is_valid_field_metadata(payload)

Return True when payload only contains canonical keys.

unknown_metadata_keys(payload)

Return the set of keys in payload that are not canonical.

Classes

FieldMetadata

Canonical schema for Field.json_schema_extra payloads.