fedn.network.storage.statestore package
Module handling storing state in the backend database (currently MongoDB).
Submodules
fedn.network.storage.statestore.mongostatestore module
- class fedn.network.storage.statestore.mongostatestore.MongoStateStore(network_id, config)[source]
Bases:
object
Statestore implementation using MongoDB.
- Parameters:
- create_round(round_data)[source]
Create a new round.
- Parameters:
round_data (dict) – Dictionary with round data.
- create_session(id=None)[source]
Create a new session object.
- Parameters:
id (uuid, str) – The ID of the created session.
- delete_combiner(combiner)[source]
Delete a combiner from statestore.
- Parameters:
combiner (str) – name of combiner to delete.
- Returns:
- get_client(client_id)[source]
Get client by client_id.
- Parameters:
client_id (str) – client_id of client to get.
- Returns:
The client. None if not found.
- Return type:
ObjectId
- get_combiner(name)[source]
Get combiner by name.
- Parameters:
name (str) – name of combiner to get.
- Returns:
The combiner.
- Return type:
ObjectId
- get_combiners(limit=None, skip=None, sort_key='updated_at', sort_order=-1, projection={})[source]
Get all combiners.
- Parameters:
- Returns:
Dictionary of combiners in result and count.
- Return type:
- get_compute_package()[source]
Get the active compute package.
- Returns:
The active compute package.
- Return type:
ObjectID
- get_events(**kwargs)[source]
Get events from the database.
- Parameters:
kwargs (dict) – query to filter events
- Returns:
events matching query
- Return type:
ObjectId
- get_helper()[source]
Get the active helper package.
- Returns:
The active helper set for the package.
- Return type:
- get_initial_model()[source]
Return model_id for the initial model in the model trail
- Returns:
The initial model id. None if no model is found.
- Return type:
- get_latest_model()[source]
Return model_id for the latest model in the model_trail
- Returns:
The latest model id. None if no model is found.
- Return type:
- get_latest_round()[source]
Get the id of the most recent round.
- Returns:
The id of the most recent round.
- Return type:
ObjectId
- get_model(model_id)[source]
Get model with id.
- Parameters:
model_id (str) – id of model to get
- Returns:
model with id
- Return type:
ObjectId
- get_model_trail()[source]
Get the model trail.
- Returns:
dictionary of model_id: committed_at
- Return type:
- get_round(id)[source]
Get round with id.
- Parameters:
id (int) – id of round to get
- Returns:
round with id, reducer and combiners
- Return type:
ObjectId
- get_session(session_id)[source]
Get session with id.
- Parameters:
session_id (str) – The session id.
- Returns:
The session.
- Return type:
ObjectID
- get_sessions(limit=None, skip=None, sort_key='_id', sort_order=-1)[source]
Get all sessions.
- Parameters:
- Returns:
Dictionary of sessions in result (array of session objects) and count.
- get_storage_backend()[source]
Get the storage backend.
- Returns:
The storage backend.
- Return type:
ObjectID
- get_validations(**kwargs)[source]
Get validations from the database.
- Parameters:
kwargs (dict) – query to filter validations
- Returns:
validations matching query
- Return type:
ObjectId
- is_inited()[source]
Check if the statestore is intialized.
- Returns:
True if initialized, else False.
- Return type:
- list_clients(limit=None, skip=None, status=None, sort_key='last_seen', sort_order=-1)[source]
List all clients registered on the network.
- list_compute_packages(limit: int | None = None, skip: int | None = None, sort_key='committed_at', sort_order=-1)[source]
List compute packages in the statestore (paginated).
- Parameters:
- Returns:
Dictionary of compute packages in result and count.
- Return type:
- list_models(session_id=None, limit=None, skip=None, sort_key='committed_at', sort_order=-1)[source]
List all models in the statestore.
- report_status(msg)[source]
Write status message to the database.
- Parameters:
msg (str) – The status message.
- report_validation(validation)[source]
Write model validation to database.
- Parameters:
validation (dict) – The model validation.
- set_client(client_data)[source]
Set client in statestore.
- Parameters:
client_data (dict) – dictionary of client config.
- Returns:
- set_combiner(combiner_data)[source]
Set combiner in statestore.
- Parameters:
combiner_data (dict) – dictionary of combiner config
- Returns:
- set_compute_package(file_name: str, storage_file_name: str, helper_type: str, name: str | None = None, description: str | None = None)[source]
Set the active compute package in statestore.
- set_current_model(model_id: str)[source]
Set the current model in statestore.
- Parameters:
model_id (str) – The model id.
- Returns:
- set_helper(helper)[source]
Set the active helper package in statestore.
- Parameters:
helper (str) – The name of the helper package. See helper.py for available helpers.
- Returns:
- set_latest_model(model_id, session_id=None)[source]
Set the latest model id.
- Parameters:
model_id (str) – The model id.
- Returns:
- set_reducer(reducer_data)[source]
Set the reducer in the statestore.
- Parameters:
reducer_data (dict) – dictionary of reducer config.
- Returns:
- set_round_combiner_data(data)[source]
Set combiner round controller data.
- Parameters:
data (dict) – The combiner data
- set_round_config(round_id, round_config: RoundConfig)[source]
Set round configuration.
- set_round_status(round_id, round_status)[source]
Set round status.
- Parameters:
round_id (str) – The round unique identifier
round_status – The status of the round.
- set_session_config(id: str, config: RoundConfig) None [source]
Set the session configuration.
- set_session_config_v2(id: str, config: RoundConfig) None [source]
Set the session configuration.
- set_session_status(id, status)[source]
Set session status.
- Parameters:
round_id (str) – The round unique identifier
round_status – The status of the session.
- set_storage_backend(config)[source]
Set the storage backend.
- Parameters:
config (dict) – The storage backend configuration.
- Returns:
fedn.network.storage.statestore.statestorebase module
- class fedn.network.storage.statestore.statestorebase.StateStoreBase[source]
Bases:
ABC
- abstract get_latest_model()[source]
Get the latest model id from the statestore.
- Returns:
The model object.
- Return type:
ObjectId
- abstract is_inited()[source]
Check if the statestore is initialized.
- Returns:
True if initialized, else False.
- Return type: