nvflare.apis.fl_context module

class FLContext[source]

Bases: object

Init the FLContext.

The FLContext is used to passed data between FL Components. It can be thought of as a dictionary that stores key/value pairs called props (properties).

Visibility: private props are only visible to local components,

public props are also visible to remote components

Stickiness: sticky props become available in all future FL Contexts,

non-sticky props will only be available in the current FL Context

MASK_PRIVATE = 2
MASK_STICKY = 1
clone_sticky()[source]
get_all_public_props()[source]
get_engine()[source]
get_identity_name()[source]
get_job_id()[source]
get_peer_context()[source]
get_prop(key, default=None)[source]
get_prop_detail(key)[source]
get_run_abort_signal()[source]
public_key_exists(key)[source]
remove_prop(key: str)[source]
set_peer_context(ctx)[source]
set_prop(key: str, value, private=True, sticky=True)[source]
set_public_props(metadata: dict)[source]
sync_sticky()[source]
class FLContextManager(engine, identity_name: str, job_id: str, public_stickers, private_stickers)[source]

Bases: object

FLContextManager manages the creation and updates of FLContext objects for a run.

NOTE: The engine may create a new FLContextManager object for each RUN!

Init the FLContextManager.

Parameters
  • engine – the engine that created this FLContextManager object

  • identity_name (str) – identity name

  • job_id – the job id

  • public_stickers – public sticky properties that are copied into or copied from

  • private_stickers – private sticky properties that are copied into or copied from

finalize_context(ctx: FLContext)[source]

Finalize the context by copying/updating sticky props into stickers.

Parameters

ctx – the context to be finalized

new_context() FLContext[source]

Create a new FLContext object.

Sticky properties are copied from the stickers into the new context.

Returns: a FLContext object