nvflare.app_common.app_defined.model_persistor module

class AppDefinedModelPersistor[source]

Bases: ModelPersistor, ComponentBase, ABC

Abstract class. Implementations will need to implement the load_model() and save_model() methods to persist & load the current ModelLearnable.

Parameters:

filter_id – Optional string that defines a filter component that is applied to prepare the model to be saved, e.g. for serialization of custom Python objects.

load_model(fl_ctx: FLContext) ModelLearnable[source]

Initialize and load the model.

Parameters:

fl_ctx – FLContext

Returns:

Model object

abstract read_model() Any[source]

Load model object.

Returns: a model object

save_model(learnable: ModelLearnable, fl_ctx: FLContext)[source]

Persist the model object.

Parameters:
  • model – Model object to be saved

  • fl_ctx – FLContext

abstract write_model(model_obj: Any)[source]

Save the model object

Parameters:

model_obj – the model object to be saved

Returns: None