flexmeasures.data.schemas.charts

Fields for choosing which chart to draw.

Functions

flexmeasures.data.schemas.charts.describe_asset_chart_types(include_legacy_names: bool = False) → str

List the asset chart types from the registry, for a field description.

Parameters:

include_legacy_names – whether to also mention the legacy names that are still accepted.

flexmeasures.data.schemas.charts.describe_chart_types(registry: ChartTypeRegistry, include_legacy_names: bool = False) → str

List the chart types from a registry, for a field description.

Parameters:
  • registry – the registry of asset or sensor chart types.

  • include_legacy_names – whether to also mention the legacy names that are still accepted.

flexmeasures.data.schemas.charts.describe_sensor_chart_types(include_legacy_names: bool = False) → str

List the sensor chart types from the registry, for a field description.

Parameters:

include_legacy_names – whether to also mention the legacy names that are still accepted.

Classes

class flexmeasures.data.schemas.charts.AssetChartTypeField(accept_legacy_names: bool = False, **kwargs)

The name of an asset chart type, validated against the registry of asset chart types.

class flexmeasures.data.schemas.charts.ChartTypeField(accept_legacy_names: bool = False, **kwargs)

The name of a chart type, validated against a registry of chart types.

The registry is read when a name is validated, so the field also accepts chart types that plugins register. An unknown name fails validation, which the API answers with a 422. Subclasses say which registry, and which chart type serves as the example.

__init__(accept_legacy_names: bool = False, **kwargs)

Set up the field.

The name is checked against the registry first, and then by any validators passed as validate. The legacy names, if accepted, are mapped before that check, so they are not among the allowed values (the enum, in OpenAPI).

Parameters:

accept_legacy_names – whether to also accept the names the chart endpoint took before the chart types had public names, mapping them to the public names.

_deserialize(value, attr, data, **kwargs) → str

Deserialize value. Concrete Field classes should implement this method.

Parameters:
  • value – The value to be deserialized.

  • attr – The attribute/key in data to be deserialized.

  • data – The raw input data passed to the Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – In case of formatting or validation failure.

Returns:

The deserialized value.

Changed in version 3.0.0: Added **kwargs to signature.

class flexmeasures.data.schemas.charts.RegisteredAssetChartType

Validate that a name is in the registry of asset chart types, reading the registry each time it validates.

__init__()
class flexmeasures.data.schemas.charts.RegisteredChartType(registry: ChartTypeRegistry)

Validate that a name is in a registry of chart types, reading the registry each time it validates.

Unlike validate.OneOf, which copies its choices when it is set up, this validator also accepts the chart types that plugins register after the field was made.

__init__(registry: ChartTypeRegistry)
_repr_args() → str

A string representation of the args passed to this validator. Used by __repr__.

property choices: list[str]

The names of the registered chart types (which the OpenAPI specs list as the field’s enum).

class flexmeasures.data.schemas.charts.RegisteredSensorChartType

Validate that a name is in the registry of sensor chart types, reading the registry each time it validates.

__init__()
class flexmeasures.data.schemas.charts.SensorChartTypeField(accept_legacy_names: bool = False, **kwargs)

The name of a sensor chart type, validated against the registry of sensor chart types.