nvflare.client.defs module¶
- class FlareAgent[source]¶
Bases:
ABC
- abstract get_task(timeout=None)[source]¶
Get a task from FLARE. This is a blocking call.
If timeout is specified, this call is blocked only for the specified amount of time. If timeout is not specified, this call is blocked forever until a task is received or agent is closed.
- Parameters:
timeout – amount of time to block
Returns: None if no task is available during before timeout; or a Task object if task is available. :raises AgentClosed exception if the agent is closed before timeout.: :raises CallStateError exception if the call is not made properly.:
Note: the application must make the call only when it is just started or after a previous task’s result has been submitted.
- submit_result(result: TaskResult) bool [source]¶
Submit the result of the current task. This is a blocking call. The agent will try to send the result to flare site until it is successfully sent or the task is aborted or the agent is closed.
- Parameters:
result – result to be submitted
Returns: whether the result is submitted successfully Raises: the CallStateError exception if the submit_result call is not made properly.
Notes: the application must only make this call after the received task is processed. The call can only be made a single time regardless whether the submission is successful.
- class MetaKey[source]¶
Bases:
object
- CURRENT_ROUND = 'current_round'¶
- DATA_KIND = 'data_kind'¶
- FILTER_HISTORY = 'filter_history'¶
- INITIAL_METRICS = 'initial_metrics'¶
- NUM_STEPS_CURRENT_ROUND = 'NUM_STEPS_CURRENT_ROUND'¶
- PROCESSED_ALGORITHM = 'PROCESSED_ALGORITHM'¶
- PROCESSED_KEYS = 'PROCESSED_KEYS'¶
- TOTAL_ROUND = 'total_round'¶