nvflare.collab.api.group_call_context module

class GroupCallContext(app, target_name: str, call_opt: CallOption, func_name: str, process_cb, cb_kwargs, context: Context, waiter: ResultWaiter)[source]

Bases: object

GroupCallContext contains contextual information about a group call to a target.

Parameters:
  • app – the calling app.

  • target_name – name of the target to be called in the remote app.

  • call_opt – call options.

  • func_name – name of the function to be called in the remote app.

  • process_cb – the callback function to be called to process response from the remote app.

  • cb_kwargs – kwargs passed to the callback function.

  • context – call context.

  • waiter – the waiter to wait for result

add_partial_result(partial_result)[source]
call_completed()[source]
set_completion_cb(cb, **cb_kwargs)[source]
set_exception(ex)[source]

This is called by the backend to set the exception received from the remote app. The process_cb will NOT be called.

Parameters:

ex – the exception received from the remote app.

Returns:

set_result(result)[source]

This is called by the backend to set the result received from the remote app. If process_cb is available, it will be called with the result from the remote app.

Parameters:

result – the result received from the remote app.

Returns: None

class ResultQueue(limit: int)[source]

Bases: object

append(item, is_whole=True)[source]

Append an item to the result queue.

Parameters:
  • item – the item to be appended.

  • is_whole – whether the item is whole.

Returns: whether the queue has received all whole items.

append_failure(site_name: str, error: CollabCallError)[source]

Record a terminal failure without yielding it as a successful result.

class ResultWaiter(sites: list[str])[source]

Bases: Event

add_partial_result(target_name: str, partial_result)[source]
dec_call_count()[source]

Decrease standing call count by 1, and notify other threads waiting for call count decreased.

Returns: None

inc_call_count()[source]

Increment standing call count by 1.

Returns: None

set_failure(target_name: str, error: CollabCallError)[source]
set_result(target_name: str, result)[source]
wait_for_call_permission(limit, abort_signal)[source]

Wait for the permission to make next call. The permission is granted when parallel call count is lower than the specified limit.

Parameters:
  • limit – to limit to check

  • abort_signal – abort signal

Returns: None

wait_for_responses(abort_signal)[source]