openairclim.gui.components.schema

Helpers for driving GUI widgets off core.config_model’s pydantic schema.

openairclim.gui.components.schema.field_description(model: type[BaseModel], field: str) str | None[source]

Return a pydantic model field’s Field(description=…). This can be passed straight through to a panel widget’s own description kwarg to provide a tooltip.

Parameters:
  • model – A pydantic model class, e.g. submodel(“temperature”).

  • field (str) – Name of one of its fields.

Returns:

The field’s description, if one is set.

Return type:

str or None

openairclim.gui.components.schema.is_string_like_field(model: type[BaseModel], field: str) bool[source]

Return True if field’s values should be treated as strings/objects (e.g. for a pandas dtype or a Tabulator “input”/”list” editor), rather than numeric — i.e. its annotation is (optionally) str or a Literal[…] of strings.

Parameters:
  • model – A pydantic model class.

  • field (str) – Name of one of its fields.

Returns:

True if string-like, False if numeric.

Return type:

bool

openairclim.gui.components.schema.literal_choices(model: type[BaseModel], field: str) list[source]

Return the allowed values of a Literal[…] field — optionally wrapped in list[…] (e.g. species.out) and/or made optional (e.g. Literal[…] | None).

Parameters:
  • model – A pydantic model class, e.g. submodel(“species”).

  • field (str) – Name of one of its fields.

Returns:

Allowed values for that field. A list, not a tuple —

Panel’s SelectBase.options only accepts dict/list.

Return type:

list

openairclim.gui.components.schema.submodel(path: str) type[BaseModel][source]

Resolve a dotted config path to its pydantic submodel class. Walks through Config.model_fields (e.g. “responses.CO2.rf”) rather than importing the per-section classes directly, so that the data can be referenced in the actual toml shape.

Parameters:

path (str) – Dotted field path, starting from Config.

Returns:

The pydantic model class at that path.