flexmeasures.data.schemas.forecasting.pipeline

Classes

class flexmeasures.data.schemas.forecasting.pipeline.AnnotationRegressorSchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: Literal['exclude', 'include', 'raise'] | None = None)

Schema for a single annotation regressor in the forecasting pipeline config.

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

remove_none_values(data, **kwargs)

Omit null fields from the serialised config to keep it clean.

skip_empty_sources(data, **kwargs)

Omit empty sources before custom ID fields serialise objects.

class flexmeasures.data.schemas.forecasting.pipeline.ForecasterParametersSchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: Literal['exclude', 'include', 'raise'] | None = None)

NB cli-exclusive fields are not exposed via the API (removed by make_openapi_compatible).

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

resolve_config(data: dict, original_data: dict | None = None, **kwargs) → dict

Resolve timing parameters, using sensible defaults and choices.

Defaults: 1. predict-period defaults to minimum of (FM planning horizon and max-forecast-horizon) only if there is a single default viewpoint. 2. max-forecast-horizon defaults to the predict-period 3. forecast-frequency defaults to minimum of (FM planning horizon, predict-period, max-forecast-horizon)

Choices: 1. If max-forecast-horizon < predict-period, we raise a ValidationError due to incomplete coverage 2. retraining-frequency becomes the maximum of (FM planning horizon and forecast-frequency, this is capped by the predict-period.

class flexmeasures.data.schemas.forecasting.pipeline.ForecastingTriggerSchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: Literal['exclude', 'include', 'raise'] | None = None)
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

class flexmeasures.data.schemas.forecasting.pipeline.TrainPredictPipelineConfigSchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: Literal['exclude', 'include', 'raise'] | None = None)
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

fold_in_max_training_period(data, **kwargs)

Read the deprecated max-training-period as the train-period it always was.

Both said how far back training may reach, so a config carrying both asks twice, and the shorter of the two is all that either of them allows. Folding it in here keeps configs written before the two were merged working, without keeping the merged name in the schema.

refuse_several_entries_for_the_sensor_to_forecast(data: dict, **kwargs)

Refuse a config that describes the sensor being forecast more than once.

Such an entry is taken out of the regressor lists and describes the target, so two of them are two answers to one question, whichever lists they were written in. Reading the last one and dropping the rest would leave a config whose recorded text does not say what the forecast did. The entries are counted before the lists are merged, since regressors asks for both roles with one entry.

validate_post_processing(data: dict, **kwargs)

Fail fast on unparseable post-processing values.

Unit compatibility with the sensor and interval semantics can only be checked once the output sensor is known, so those run at forecast time.