schema#
hydromodpy.schema exposes the JSON Schema export and the
partial-field validator that any frontend (Streamlit, Angular,
React, Jupyter widget) consumes. It is the only public, stable
contract for non-Python integrations.
Sub-modules#
schema/export.py–export_full_schema(output_dir)writes three JSON files underoutput_dir/:config.json– full JSON Schema ofHydroModPyConfig;config_meta.json– ordered TOML sections, UI groups, titles;field_validators.json– flatfield_path -> validator_type(enum, number, date, …).
schema/partial_validator.py–validate_field(path, value)resolves the dotted path onHydroModPyConfig, picks the matchingpydantic.TypeAdapter, and returns a lightweightValidationResult. Lookups are memoised, runs under 50 ms.
Annotations carried by the schema#
Each field of config.json keeps the json_schema_extra
annotations declared by the Pydantic models:
widget_type(slider,text,select,date,file,map);unit(canonical SI:m,m/s,1/m);display_name_franddisplay_name_en;help_text_frandhelp_text_en;display_minanddisplay_maxfor sliders;profile(user/dev/expert).
These annotations are the contract between the Pydantic models and any UI integration. Honour them and you avoid a custom mapping layer.
Key public symbols#
hydromodpy.schema.export.export_full_schemahydromodpy.schema.partial_validator.validate_fieldhydromodpy.schema.partial_validator.ValidationResult
CLI bindings#
hmp schema export --output ./schema/-> three JSON files.hmp schema validate-field <path> <value>-> JSONValidationResult.
Both subcommands live under hydromodpy/cli/commands/schema.py.
Recommended reading path#
hydromodpy/schema/export.pyhydromodpy/schema/partial_validator.pyThe composition root
hydromodpy/config/hydromodpy_config.pyto see what is exported.One model that ships rich annotations (for example
hydromodpy/physics/flow/flow_config.py).
Layer-matrix neighbours#
Allowed targets:
core,schema,config.Allowed sources: every other layer (the schema export is the most central public contract).
The schema export must stay deterministic. Do not introduce side-effects or environment-dependent fields.
See also#
Frontend Hooks – design rationale for the integration surface.
Build a Frontend – step-by-step recipe (Streamlit, Angular, React).
Add a Config Field – adding a field with the annotations the schema consumes.
Schema Explorer – user-facing schema viewer.