nvflare.apis.impl.task_manager module

class TaskCheckStatus(value)[source]

Bases: Enum

An enumeration.

BLOCK = 2
NO_BLOCK = 3
SEND = 1
class TaskManager[source]

Bases: object

Manages tasks for clients.

Programming Conventions: A TaskManager should be implemented as a state-free object. All task processing state info should be stored in the Task’s props dict. Name the keys in the props dict with prefix “__” to avoid potential conflict with app-defined props.

check_task_exit(task: Task) Tuple[bool, TaskCompletionStatus][source]

Determine whether the task should exit.

Parameters:

task (Task) – an instance of Task

Returns:

first entry in the tuple means whether to exit the task or not. If it’s True, the task should exit. second entry in the tuple indicates the TaskCompletionStatus.

Return type:

Tuple[bool, TaskCompletionStatus]

check_task_result(result: Shareable, client_task: ClientTask, fl_ctx: FLContext)[source]

Check the result received from the client.

The manager can set appropriate headers into the result to indicate certain conditions (e.g. late response).

Parameters:
  • result (Shareable) – the result to be checked

  • client_task (ClientTask) – the task processing state of the client

  • fl_ctx (FLContext) – fl context that comes with the task request

check_task_send(client_task: ClientTask, fl_ctx: FLContext) TaskCheckStatus[source]

Determine whether the task should be sent to the client.

Default logic: If the client already did the task, don’t send again (BLOCK). If the client is in the task’s target list or the task’s target list is None (meaning all clients), then send the task (SEND). Otherwise, do not block the task checking (NO_BLOCK), so next task will be checked.

Parameters:
  • client_task (ClientTask) – the task processing state of the client

  • fl_ctx (FLContext) – fl context that comes with the task request

Returns:

NO_BLOCK for not sending the task, BLOCK for waiting, SEND for OK to send

Return type:

TaskCheckStatus