fedn.network.storage.models package

The models package handles storing of model updates durign the federated training process. The functionality is used by the combiner service during aggregation of model updates from clients. By implementing the interface in the base class modelstorage.py, a developer may customize the behaviour of the framework.

Submodules

fedn.network.storage.models.memorymodelstorage module

class fedn.network.storage.models.memorymodelstorage.MemoryModelStorage[source]

Bases: ModelStorage

Class for in-memory storage of model artifacts.

Models are stored as BytesIO objects in a dictionary.

exist(model_id)[source]

Check if model exists in storage

Parameters:

model_id (str) – The model id

Returns:

True if model exists, False otherwise

Return type:

bool

get(model_id)[source]

Get model from storage

Parameters:

model_id (str) – The model id

Returns:

The model

Return type:

object

get_model_metadata(model_id)[source]

Get model metadata from storage

Parameters:

model_id (str) – The model id

Returns:

The model metadata

Return type:

dict

get_ptr(model_id)[source]
Parameters:

model_id

Returns:

set_model_metadata(model_id, model_metadata)[source]

Set model metadata in storage

Parameters:
  • model_id (str) – The model id

  • model_metadata (dict) – The model metadata

Returns:

True if successful, False otherwise

Return type:

bool

fedn.network.storage.models.modelstorage module

class fedn.network.storage.models.modelstorage.ModelStorage[source]

Bases: ABC

abstract delete(model_id)[source]

Delete model from storage

Parameters:

model_id (str) – The model id

Returns:

True if successful, False otherwise

Return type:

bool

abstract delete_all()[source]

Delete all models from storage

Returns:

True if successful, False otherwise

Return type:

bool

abstract exist(model_id)[source]

Check if model exists in storage

Parameters:

model_id (str) – The model id

Returns:

True if model exists, False otherwise

Return type:

bool

abstract get(model_id)[source]

Get model from storage

Parameters:

model_id (str) – The model id

Returns:

The model

Return type:

object

abstract get_model_metadata(model_id)[source]

Get model metadata from storage

Parameters:

model_id (str) – The model id

Returns:

The model metadata

Return type:

dict

abstract set_model_metadata(model_id, model_metadata)[source]

Set model metadata in storage

Parameters:
  • model_id (str) – The model id

  • model_metadata (dict) – The model metadata

Returns:

True if successful, False otherwise

Return type:

bool

fedn.network.storage.models.tempmodelstorage module

class fedn.network.storage.models.tempmodelstorage.TempModelStorage[source]

Bases: ModelStorage

Class for managing local temporary models on file on combiners.

delete(model_id)[source]

Delete model from storage

Parameters:

model_id (str) – The model id

Returns:

True if successful, False otherwise

Return type:

bool

delete_all()[source]

Delete all models from storage

Returns:

True if successful, False otherwise

Return type:

bool

exist(model_id)[source]

Check if model exists in storage

Parameters:

model_id (str) – The model id

Returns:

True if model exists, False otherwise

Return type:

bool

get(model_id)[source]

Get model from storage

Parameters:

model_id (str) – The model id

Returns:

The model

Return type:

object

get_model_metadata(model_id)[source]

Get model metadata from storage

Parameters:

model_id (str) – The model id

Returns:

The model metadata

Return type:

dict

get_ptr(model_id)[source]
Parameters:

model_id

Returns:

set_model_metadata(model_id, model_metadata)[source]

Set model metadata in storage

Parameters:
  • model_id (str) – The model id

  • model_metadata (dict) – The model metadata

Returns:

True if successful, False otherwise

Return type:

bool