fedn.network.storage.statestore.stores package

class fedn.network.storage.statestore.stores.ClientStore[source]

Bases: Store[ClientDTO]

Client store interface.

abstract connected_client_count(combiners: List[str]) List[ClientDTO][source]

Count the number of connected clients for each combiner.

Parameters:
  • combiners (list) – list of combiners to get data for.

  • sort_key (str) – The key to sort by.

  • sort_order (pymongo.ASCENDING or pymongo.DESCENDING) – The sort order.

Returns:

list of combiner data.

Return type:

list(ObjectId)

class fedn.network.storage.statestore.stores.CombinerStore[source]

Bases: Store[CombinerDTO]

abstract get_by_name() CombinerDTO[source]
class fedn.network.storage.statestore.stores.MetricStore[source]

Bases: Store[MetricDTO]

class fedn.network.storage.statestore.stores.ModelStore[source]

Bases: Store[ModelDTO]

abstract get_leaf_nodes() List[ModelDTO][source]

List orphans return: A list of entities

abstract list_ancestors(id: str, limit: int, include_self: bool = False, reverse: bool = False) List[ModelDTO][source]

List ancestors param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

abstract list_descendants(id: str, limit: int) List[ModelDTO][source]

List descendants param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

class fedn.network.storage.statestore.stores.PackageStore[source]

Bases: Store[PackageDTO]

abstract delete_active() bool[source]

Delete the active entity return: Whether the operation was successful

abstract get_active() PackageDTO[source]

Get the active entity return: The entity

abstract set_active(id: str) bool[source]

Set the active entity param id: The id of the entity

type: str

return: Whether the operation was successful

abstract set_active_helper(helper: str) bool[source]

Set the active helper param helper: The helper to set as active

type: str

return: Whether the operation was successful

class fedn.network.storage.statestore.stores.PredictionStore[source]

Bases: Store[PredictionDTO]

class fedn.network.storage.statestore.stores.RoundStore[source]

Bases: Store[RoundDTO]

abstract get_latest_round_id() int[source]
class fedn.network.storage.statestore.stores.SessionStore[source]

Bases: Store[SessionDTO]

class fedn.network.storage.statestore.stores.StatusStore[source]

Bases: Store[StatusDTO]

class fedn.network.storage.statestore.stores.ValidationStore[source]

Bases: Store[ValidationDTO]

Subpackages

Submodules

fedn.network.storage.statestore.stores.attribute_store module

class fedn.network.storage.statestore.stores.attribute_store.AttributeStore[source]

Bases: Store[AttributeDTO]

get_current_attributes_for_client(client_id: str) List[AttributeDTO][source]

Get all attributes for a specific client.

This method returns the most recent attributes for the given client_id.

class fedn.network.storage.statestore.stores.attribute_store.MongoDBAttributeStore(database: Database, collection: str)[source]

Bases: AttributeStore, MongoDBStore[AttributeDTO]

__init__(database: Database, collection: str)[source]
class fedn.network.storage.statestore.stores.attribute_store.SQLAttributeStore(session)[source]

Bases: AttributeStore, SQLStore[AttributeDTO, AttributeModel]

__init__(session)[source]
count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

fedn.network.storage.statestore.stores.client_store module

class fedn.network.storage.statestore.stores.client_store.ClientStore[source]

Bases: Store[ClientDTO]

Client store interface.

abstract connected_client_count(combiners: List[str]) List[ClientDTO][source]

Count the number of connected clients for each combiner.

Parameters:
  • combiners (list) – list of combiners to get data for.

  • sort_key (str) – The key to sort by.

  • sort_order (pymongo.ASCENDING or pymongo.DESCENDING) – The sort order.

Returns:

list of combiner data.

Return type:

list(ObjectId)

class fedn.network.storage.statestore.stores.client_store.MongoDBClientStore(database: Database, collection: str)[source]

Bases: ClientStore, MongoDBStore[ClientDTO]

__init__(database: Database, collection: str)[source]
connected_client_count(combiners: List[str]) List[source]

Count the number of connected clients for each combiner.

Parameters:
  • combiners (list) – list of combiners to get data for.

  • sort_key (str) – The key to sort by.

  • sort_order (pymongo.ASCENDING or pymongo.DESCENDING) – The sort order.

Returns:

list of combiner data.

Return type:

list(ObjectId)

update(item: ClientDTO) ClientDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.client_store.SQLClientStore(Session)[source]

Bases: ClientStore, SQLStore[ClientDTO, ClientModel]

__init__(Session)[source]
connected_client_count(combiners) List[Dict][source]

Count the number of connected clients for each combiner.

Parameters:
  • combiners (list) – list of combiners to get data for.

  • sort_key (str) – The key to sort by.

  • sort_order (pymongo.ASCENDING or pymongo.DESCENDING) – The sort order.

Returns:

list of combiner data.

Return type:

list(ObjectId)

update(item: ClientDTO) ClientDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

fedn.network.storage.statestore.stores.combiner_store module

class fedn.network.storage.statestore.stores.combiner_store.CombinerStore[source]

Bases: Store[CombinerDTO]

abstract get_by_name() CombinerDTO[source]
class fedn.network.storage.statestore.stores.combiner_store.MongoDBCombinerStore(database: Database, collection: str)[source]

Bases: CombinerStore, MongoDBStore[CombinerDTO]

__init__(database: Database, collection: str)[source]
get_by_name(name: str) CombinerDTO[source]
class fedn.network.storage.statestore.stores.combiner_store.SQLCombinerStore(Session)[source]

Bases: CombinerStore, SQLStore[CombinerDTO, CombinerModel]

__init__(Session)[source]
get_by_name(name: str) CombinerDTO[source]

fedn.network.storage.statestore.stores.metric_store module

class fedn.network.storage.statestore.stores.metric_store.MetricStore[source]

Bases: Store[MetricDTO]

class fedn.network.storage.statestore.stores.metric_store.MongoDBMetricStore(database: Database, collection: str)[source]

Bases: MetricStore, MongoDBStore[MetricDTO]

__init__(database: Database, collection: str)[source]
class fedn.network.storage.statestore.stores.metric_store.SQLMetricStore(session)[source]

Bases: MetricStore, SQLStore[MetricDTO, MetricModel]

__init__(session)[source]
count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

fedn.network.storage.statestore.stores.model_store module

class fedn.network.storage.statestore.stores.model_store.ModelStore[source]

Bases: Store[ModelDTO]

abstract get_leaf_nodes() List[ModelDTO][source]

List orphans return: A list of entities

abstract list_ancestors(id: str, limit: int, include_self: bool = False, reverse: bool = False) List[ModelDTO][source]

List ancestors param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

abstract list_descendants(id: str, limit: int) List[ModelDTO][source]

List descendants param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

class fedn.network.storage.statestore.stores.model_store.MongoDBModelStore(database: Database, collection: str)[source]

Bases: ModelStore, MongoDBStore[ModelDTO]

__init__(database: Database, collection: str)[source]
count(**kwargs) int[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

get(id: str) ModelDTO[source]

Get an entity by id.

Parameters:

id (str) – Entity id

Returns:

The entity or null if not found

Return type:

DTO

get_leaf_nodes() List[ModelDTO][source]

List orphans return: A list of entities

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

list_ancestors(id: str, limit: int, include_self: bool = False, reverse: bool = False) List[ModelDTO][source]

List ancestors param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

list_descendants(id: str, limit: int) List[ModelDTO][source]

List descendants param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

update(item: ModelDTO) ModelDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.model_store.SQLModelStore(Session)[source]

Bases: ModelStore, SQLStore[ModelDTO, ModelModel]

__init__(Session)[source]
get_leaf_nodes() List[ModelDTO][source]

List orphans return: A list of entities

list_ancestors(id: str, limit: int, include_self=False, reverse=False)[source]

List ancestors param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

list_descendants(id: str, limit: int)[source]

List descendants param id: The id of the entity

type: str description: The id of the entity, can be either the id or the model (property)

param limit: The maximum number of entities to return

type: int

return: A list of entities

update(item: ModelDTO) ModelDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

fedn.network.storage.statestore.stores.package_store module

class fedn.network.storage.statestore.stores.package_store.MongoDBPackageStore(database: Database, collection: str)[source]

Bases: PackageStore, MongoDBStore[PackageDTO]

__init__(database: Database, collection: str)[source]
count(**kwargs) int[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

delete(id: str) bool[source]

Delete an entity.

Parameters:

id (str) – The id of the entity

Returns:

success or failure

Return type:

Bool

delete_active() bool[source]

Delete the active entity return: Whether the operation was successful

get(id: str) PackageDTO[source]

Get an entity by id.

Parameters:

id (str) – Entity id

Returns:

The entity or null if not found

Return type:

DTO

get_active() PackageDTO[source]

Get the active entity return: The entity

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs) List[PackageDTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

set_active(id: str) bool[source]

Set the active entity param id: The id of the entity

type: str

return: Whether the operation was successful

set_active_helper(helper: str) bool[source]

Set the active helper param helper: The helper to set as active

type: str

return: Whether the operation was successful

class fedn.network.storage.statestore.stores.package_store.PackageStore[source]

Bases: Store[PackageDTO]

abstract delete_active() bool[source]

Delete the active entity return: Whether the operation was successful

abstract get_active() PackageDTO[source]

Get the active entity return: The entity

abstract set_active(id: str) bool[source]

Set the active entity param id: The id of the entity

type: str

return: Whether the operation was successful

abstract set_active_helper(helper: str) bool[source]

Set the active helper param helper: The helper to set as active

type: str

return: Whether the operation was successful

class fedn.network.storage.statestore.stores.package_store.SQLPackageStore(Session)[source]

Bases: PackageStore, SQLStore[PackageDTO, PackageModel]

__init__(Session)[source]
delete_active() bool[source]

Delete the active entity return: Whether the operation was successful

get_active() PackageDTO[source]

Get the active entity return: The entity

set_active(id: str)[source]

Set the active entity param id: The id of the entity

type: str

return: Whether the operation was successful

set_active_helper(helper: str) bool[source]

Set the active helper param helper: The helper to set as active

type: str

return: Whether the operation was successful

fedn.network.storage.statestore.stores.package_store.is_active_package(package_id, active_package: dict) bool[source]

fedn.network.storage.statestore.stores.prediction_store module

class fedn.network.storage.statestore.stores.prediction_store.MongoDBPredictionStore(database: Database, collection: str)[source]

Bases: PredictionStore, MongoDBStore[PredictionDTO]

__init__(database: Database, collection: str)[source]
class fedn.network.storage.statestore.stores.prediction_store.PredictionStore[source]

Bases: Store[PredictionDTO]

class fedn.network.storage.statestore.stores.prediction_store.SQLPredictionStore(Session)[source]

Bases: PredictionStore, SQLStore[PredictionDTO, PredictionModel]

__init__(Session)[source]
count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit: int = 0, skip: int = 0, sort_key: str | None = None, sort_order=SortOrder.DESCENDING, **kwargs) List[PredictionDTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

fedn.network.storage.statestore.stores.round_store module

class fedn.network.storage.statestore.stores.round_store.MongoDBRoundStore(database: Database, collection: str)[source]

Bases: RoundStore, MongoDBStore[RoundDTO]

__init__(database: Database, collection: str)[source]
get_latest_round_id() int[source]
update(item: RoundDTO) RoundDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.round_store.RoundStore[source]

Bases: Store[RoundDTO]

abstract get_latest_round_id() int[source]
class fedn.network.storage.statestore.stores.round_store.SQLRoundStore(Session)[source]

Bases: RoundStore, SQLStore[RoundDTO, RoundModel]

__init__(Session)[source]
get_latest_round_id() int[source]
update(item: RoundDTO) RoundDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

fedn.network.storage.statestore.stores.run_store module

class fedn.network.storage.statestore.stores.run_store.MongoDBRunStore(database: Database, collection: str)[source]

Bases: RunStore, MongoDBStore[RunDTO]

__init__(database: Database, collection: str)[source]
update(item: RunDTO) RunDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.run_store.RunStore[source]

Bases: Store[RunDTO]

class fedn.network.storage.statestore.stores.run_store.SQLRunStore(session)[source]

Bases: RunStore, SQLStore[RunDTO, RunModel]

__init__(session)[source]
update(item)[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

fedn.network.storage.statestore.stores.session_store module

class fedn.network.storage.statestore.stores.session_store.MongoDBSessionStore(database: Database, collection: str)[source]

Bases: SessionStore, MongoDBStore[SessionDTO]

__init__(database: Database, collection: str)[source]
update(item: SessionDTO) SessionDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.session_store.SQLSessionStore(Session)[source]

Bases: SessionStore, SQLStore[SessionDTO, SessionModel]

__init__(Session)[source]
update(item: SessionDTO) SessionDTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.session_store.SessionStore[source]

Bases: Store[SessionDTO]

fedn.network.storage.statestore.stores.shared module

exception fedn.network.storage.statestore.stores.shared.EntityNotFound[source]

Bases: Exception

exception fedn.network.storage.statestore.stores.shared.MissingFieldError(field: str, class_name: str)[source]

Bases: Exception

__init__(field: str, class_name: str)[source]
user_message()[source]
class fedn.network.storage.statestore.stores.shared.SortOrder(value)[source]

Bases: Enum

An enumeration.

ASCENDING = 'ASC'
DESCENDING = 'DESC'
exception fedn.network.storage.statestore.stores.shared.ValidationError(field: str, message: str)[source]

Bases: Exception

__init__(field: str, message: str)[source]
user_message()[source]

fedn.network.storage.statestore.stores.status_store module

class fedn.network.storage.statestore.stores.status_store.MongoDBStatusStore(database: Database, collection: str)[source]

Bases: StatusStore, MongoDBStore[StatusDTO]

__init__(database: Database, collection: str)[source]
class fedn.network.storage.statestore.stores.status_store.SQLStatusStore(Session)[source]

Bases: StatusStore, SQLStore[StatusDTO, StatusModel]

__init__(Session)[source]
count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit: int, skip: int, sort_key: str, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

class fedn.network.storage.statestore.stores.status_store.StatusStore[source]

Bases: Store[StatusDTO]

fedn.network.storage.statestore.stores.store module

class fedn.network.storage.statestore.stores.store.MongoDBStore(database: Database, collection: str, primary_key: str)[source]

Bases: Store[DTO], Generic[DTO]

Base MongoDB store implementation.

__init__(database: Database, collection: str, primary_key: str) None[source]

Initialize MongoDBStore.

add(item: DTO) DTO[source]

Add an entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

ValidationError – If validation fails.

count(**kwargs) int[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

delete(id: str) bool[source]

Delete an entity.

Parameters:

id (str) – The id of the entity

Returns:

success or failure

Return type:

Bool

get(id)[source]

Get an entity by id.

Parameters:

id (str) – Entity id

Returns:

The entity or null if not found

Return type:

DTO

list(limit: int = 0, skip: int = 0, sort_key: str | None = None, sort_order=SortOrder.DESCENDING, **kwargs) List[DTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

mongo_update(item: DTO) DTO[source]
update(item: DTO) DTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.store.SQLStore(Session: Type[Session], SQLModel: Type[MODEL], primary_key: str)[source]

Bases: Store[DTO], Generic[DTO, MODEL]

Base SQL store implementation.

__init__(Session: Type[Session], SQLModel: Type[MODEL], primary_key: str) None[source]

Initialize SQLStore.

add(item: DTO) DTO[source]

Add an entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

ValidationError – If validation fails.

count(**kwargs) int[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

delete(id: str) bool[source]

Delete an entity.

Parameters:

id (str) – The id of the entity

Returns:

success or failure

Return type:

Bool

get(id: str) DTO[source]

Get an entity by id.

Parameters:

id (str) – Entity id

Returns:

The entity or null if not found

Return type:

DTO

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs) List[DTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

sql_update(item: DTO) DTO[source]
update(item: DTO) DTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
class fedn.network.storage.statestore.stores.store.Store[source]

Bases: ABC, Generic[DTO]

Abstract class for a store.

OBS! This is an interface, do not add any implementations here.

abstract add(item: DTO) DTO[source]

Add an entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

ValidationError – If validation fails.

abstract count(**kwargs) int[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

abstract delete(id: str) bool[source]

Delete an entity.

Parameters:

id (str) – The id of the entity

Returns:

success or failure

Return type:

Bool

abstract get(id: str) DTO[source]

Get an entity by id.

Parameters:

id (str) – Entity id

Returns:

The entity or null if not found

Return type:

DTO

abstract list(limit: int = 0, skip: int = 0, sort_key: str | None = None, sort_order=SortOrder.DESCENDING, **kwargs) List[DTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

abstract update(item: DTO) DTO[source]

Update an existing entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:
fedn.network.storage.statestore.stores.store.from_document(document: dict) dict[source]

fedn.network.storage.statestore.stores.telemetry_store module

class fedn.network.storage.statestore.stores.telemetry_store.MongoDBTelemetryStore(database: Database, collection: str)[source]

Bases: TelemetryStore, MongoDBStore[TelemetryDTO]

__init__(database: Database, collection: str)[source]
add(item: TelemetryDTO) TelemetryDTO[source]

Add an entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

ValidationError – If validation fails.

list(limit: int, skip: int, sort_key: str, sort_order=SortOrder.DESCENDING, **kwargs) List[TelemetryDTO][source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

class fedn.network.storage.statestore.stores.telemetry_store.SQLTelemetryStore(Session)[source]

Bases: TelemetryStore, SQLStore[TelemetryDTO, TelemetryModel]

__init__(Session)[source]
add(item: TelemetryDTO) TelemetryDTO[source]

Add an entity.

Parameters:

item (DTO) – The entity to update.

Returns:

The updated entity.

Return type:

DTO

Raises:

ValidationError – If validation fails.

count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit=0, skip=0, sort_key=None, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

class fedn.network.storage.statestore.stores.telemetry_store.TelemetryStore[source]

Bases: Store[TelemetryDTO]

fedn.network.storage.statestore.stores.validation_store module

class fedn.network.storage.statestore.stores.validation_store.MongoDBValidationStore(database: Database, collection: str)[source]

Bases: ValidationStore, MongoDBStore[ValidationDTO]

__init__(database: Database, collection: str)[source]
class fedn.network.storage.statestore.stores.validation_store.SQLValidationStore(Session)[source]

Bases: ValidationStore, SQLStore[ValidationDTO, ValidationModel]

__init__(Session)[source]
count(**kwargs)[source]

Count entities.

Parameters:

kwargs (dict) – Additional query parameters, example: {“key”: “models”}

Returns:

The number of entities

Return type:

int

list(limit: int, skip: int, sort_key: str, sort_order=SortOrder.DESCENDING, **kwargs)[source]

Select entities.

Parameters:
  • limit (int) – The maximum number of entities to return

  • skip (int) – The number of entities to skip

  • sort_key (str) – The key to sort by

  • sort_order (SortOrder.DESCENDING | SortOrder.ASCENDING) – The order to sort by

  • kwargs (dict) – Additional query parameters

Returns:

The list of entities

Return type:

List[DTO]

class fedn.network.storage.statestore.stores.validation_store.ValidationStore[source]

Bases: Store[ValidationDTO]