nvflare.client.model_registry module

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

Bases: TaskRegistry

Gets and submits FLModel.

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.

release_params(sent_model: FLModel) None[source]

Release large parameter arrays after serialization is complete.

Called by the API layer (conditioned on clear_cache) after submit_model() has serialized and sent the model via pipe. Nulls both the sent model’s params and the received model’s params — neither is needed on the client after flare.send() returns.

After this call, sent_model.params and the received model’s params will be None. Callers must not access these fields after flare.send().

Parameters:

sent_model – The FLModel that was just submitted.

submit_model(model: FLModel) None[source]

Submits a model to FLARE client.

Parameters:

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