nvflare.client.model_registry module

class ModelRegistry(config: ClientConfig, rank: str | None = None, flare_agent: FlareAgent | None = None)[source]

Bases: TaskRegistry

This class is used to remember attributes that need to be shared for a user code.

For example, after “global_evaluate” we should remember the “metrics” value. And set that into the model that we want to submit after “train”.

For each user file:
  • we only need 1 model exchanger.

  • we only need to pull global model once

clear()[source]

Clears the model registry cache.

get_model(timeout: float | None = None) FLModel | None[source]

Gets a model from FLARE client.

This method gets the task from FLARE client, and extract the task.data out.

Parameters:

timeout (float, optional) – If specified, this call is blocked only for the specified amount of time. If not specified, this call is blocked forever until a task has been received or agent has been closed.

Returns:

None if flare agent is None; or an FLModel object if a task is available within timeout.

submit_model(model: FLModel) None[source]

Submits a model to FLARE client.

Parameters:

model (FLModel) – Trained local model to be submitted.