flexmeasures.data.schemas.utils

Functions

flexmeasures.data.schemas.utils.with_appcontext_if_needed()

Execute within the script’s application context, in case there is one.

An exception is flexmeasures run, which has a click context at the time the decorator is called, but no longer has a click context at the time the decorated function is called, which, typically, is a request to the running FlexMeasures server.

Classes

class flexmeasures.data.schemas.utils.MarshmallowClickMixin(*args, **kwargs)
__init__(*args, **kwargs)
convert(value, param, ctx, **kwargs)

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

get_metavar(param)

Returns the metavar default for this param if it provides one.

name: str

the descriptive name of this type

Exceptions

exception flexmeasures.data.schemas.utils.FMValidationError(message: str | list | dict, field_name: str = '_schema', data: Mapping[str, Any] | Iterable[Mapping[str, Any]] | None = None, valid_data: list[dict[str, Any]] | dict[str, Any] | None = None, **kwargs)

Custom validation error class. It differs from the classic validation error by having two attributes, according to the USEF 2015 reference implementation. Subclasses of this error might adjust the status attribute accordingly.