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.

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.

set_task_name(task_name: str) None[source]

Sets the current task name.

This method is only used in multiprocess scenario in the lightning API. For non-rank 0 processes, they are not getting tasks from the FLARE side, thus they rely on the rank 0 process to tell them the current task name and will use this method to set it.

Parameters:

task_name (str) – current task name

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