flexmeasures.data.services.data_sources

Functions

flexmeasures.data.services.data_sources.get_data_generator(source: DataSource | None, model: str, config: dict, save_config: bool, data_generator_type: Type[DG]) → DG | None
flexmeasures.data.services.data_sources.get_or_create_source(source: User | str, source_type: str | None = None, model: str | None = None, version: str | None = None, attributes: dict | None = None, account: Account | None = None, flush: bool = True) → DataSource
flexmeasures.data.services.data_sources.get_readable_source_account_ids() → list[int] | None

Return the ids of the accounts whose data sources the current user may read.

Returns None to say that every account’s sources are readable, which is what admin access amounts to.

flexmeasures.data.services.data_sources.get_source_or_none(source: int | str, source_type: str | None = None) → DataSource | None
Parameters:
  • source – source id

  • source_type – optionally, filter by source type

flexmeasures.data.services.data_sources.readable_source_filter() → ColumnElement[bool] | None

A condition selecting the data sources the current user may read.

On top of the sources which are theirs to work with (see usable_source_filter), this covers the sources which have recorded data on a sensor they may read, because “what computed this number?” is a fair question about data one is allowed to see.

Returns None to say that every source is readable, which is what admin access amounts to.

flexmeasures.data.services.data_sources.usable_source_filter() → ColumnElement[bool] | None

A condition selecting the data sources which are the current user’s to work with.

These are the sources they may reuse for an automation of their own, and the ones whose stored configuration they may read, which is a stronger thing to be allowed than reading what a source has computed: see readable_source_filter.

Returns None to say that every source qualifies, which is what admin access amounts to.

flexmeasures.data.services.data_sources.user_may_read_source(source: DataSource) → bool

Whether the current user may read the given data source.

See readable_source_filter for what makes a source readable.

flexmeasures.data.services.data_sources.user_may_use_source(source: DataSource) → bool

Whether the given data source is the current user’s to work with.

See usable_source_filter for what that means, and why it is a stronger thing to be allowed than reading the source.