flexmeasures.data.automations

Registered automation handlers and the worker for plugin data generators.

Functions

flexmeasures.data.automations.check_execution_access(automation, sensors)

Recheck the API creator’s current permissions for unattended execution.

A null identity denotes trusted CLI creation or a legacy automation. A deleted identity remains stored and fails closed, rather than reverting to CLI trust.

flexmeasures.data.automations.execute_automation_job(automation_id: int, data_source_id: int, parameters: dict)

Compute and persist declared results with provenance in a plugin-enabled worker.

flexmeasures.data.automations.get_automation_handler(type_id: str) AutomationHandler

Resolve a trusted handler, failing safely when its plugin is unavailable.

flexmeasures.data.automations.get_automation_types() dict[str, AutomationHandler]

Return the handlers available in this application.

flexmeasures.data.automations.initialize_automation_handlers(app)

Install built-in handlers in this application’s registry.

flexmeasures.data.automations.load_automation_payload(schema: Schema, payload: dict, field: str) dict

Load a strict plugin schema and retain the payload’s field in errors.

flexmeasures.data.automations.register_automation_handler(app, handler: AutomationHandler)

Register trusted plugin code, rejecting ambiguous types and generators.

flexmeasures.data.automations.resolve_plugin_generator(automation, handler, parameters=None)

Resolve the declared generator and sensors without sharing mutable run state.

flexmeasures.data.automations.validate_automation_type(type_id: str)

Validate creation against the current registry, not a static type list.

flexmeasures.data.automations.validate_output_scope(asset_id, sensors)

Require plugin results to stay within the automation’s asset subtree.

Classes

class flexmeasures.data.automations.AutomationHandler(type_id: str, display_name: str, generator_class: type[DataGenerator] | None = None, queue: str = 'ingestion', result_noun: str = 'result')

Declare a type backed by a generator with configuration and parameter schemas.

Plugins expose instances in __automation_types__. Generator sensor properties must enumerate every sensor read or written by the computation. Credentials belong in server settings, never configuration or parameters persisted by this handler.

__init__(type_id: str, display_name: str, generator_class: type[DataGenerator] | None = None, queue: str = 'ingestion', result_noun: str = 'result') None
create(**kwargs)

Validate and create the automation without committing it.

run(automation, scheduled_at=None)

Queue work using only registered code and committed identifiers.

Exceptions

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

A plugin payload error that identifies configuration versus run parameters.