nvflare.client.task_registry module

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

Bases: object

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

For multi-process scenarios: - Only rank 0 process communicates with the FL server - Other ranks get task information through their training framework - Each rank maintains its own task state

clear() None[source]

Clears the cached received task.

get_sys_info() Dict[source]

Gets NVFlare system information.

Returns:

A dict of system information.

get_task(timeout: float | None = None) Task | None[source]

Gets the cached received task.

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 a Task object if task is available within timeout.

property is_rank0: bool

Whether this is the rank 0 process.

submit_task(data: Any, return_code: str = 'OK') bool[source]

Submits result of the current task.

Parameters:
  • data – task result

  • return_code (str) – return code of the task execution

Returns:

whether the result is submitted successfully