nvflare.collab.api package
Submodules
- nvflare.collab.api.app module
AppApp.add_collab_object()App.backendApp.client_hierarchyApp.client_proxiesApp.finalize()App.find_collab_method()App.find_method()App.fqnApp.get_children()App.get_collab_interface()App.get_collab_objects()App.get_leaf_clients()App.get_prop()App.get_props()App.get_target_object_publish_interface()App.has_children()App.initialize()App.my_siteApp.new_context()App.server_proxyApp.set_fqn()App.set_prop()App.setup()App.update_props()App.workspace
ClientAppServerApp
- nvflare.collab.api.call_opt module
- nvflare.collab.api.call_utils module
- nvflare.collab.api.constants module
- nvflare.collab.api.context module
- nvflare.collab.api.decorators module
- nvflare.collab.api.exceptions module
- nvflare.collab.api.facade module
FacadeFacade.call_infoFacade.calleeFacade.callerFacade.child_clientsFacade.clientsFacade.contextFacade.final()Facade.fl_ctxFacade.get_app_prop()Facade.get_clients()Facade.get_prop()Facade.get_result()Facade.has_childrenFacade.init()Facade.is_abortedFacade.leaf_clientsFacade.main()Facade.other_clientsFacade.publish()Facade.serverFacade.set_app_prop()Facade.set_prop()Facade.site_nameFacade.workspace
get_call_context()
- nvflare.collab.api.group module
- nvflare.collab.api.group_call_context module
- nvflare.collab.api.module_wrapper module
- nvflare.collab.api.proxy module
- nvflare.collab.api.proxy_list module
- nvflare.collab.api.publish_interface module
Module contents
Public programming surface of the collab API layer.
User code should import these names from this package rather than from the implementation modules. Exports are resolved lazily (PEP 562).
- class App(obj, name: str)[source]
Bases:
object- property backend
- property client_hierarchy
- property client_proxies
- property fqn
- property server_proxy
- property workspace
- class CallOption(expect_result: bool = True, blocking: bool = True, timeout: float = 60.0, secure: bool = False, optional: bool = False, target=None, parallel=0)[source]
Bases:
objectCallOption defines behavior of a collab call.
- Parameters:
expect_result – whether result is expected from the remote object.
blocking – whether the call is blocking. Only for group calls.
timeout – when expecting result, the max number of secs to wait for result.
secure – whether to use P2P secure messaging.
optional – whether the call is optional.
target – name of the collab object to be called.
parallel – maximum number of calls that may remain in flight at once.
- exception CollabCallError(site: str, func_name: str, cause, cause_type: str | None = None, remote_traceback: str | None = None)[source]
Bases:
ExceptionRaised when a call to a Collab function fails.
- class Context(app, caller: str, callee: str, abort_signal: Signal, target_group=None)[source]
Bases:
object- property backend
- property client_hierarchy
- property clients
- property server
- property target_group_size
- property workspace
- class GroupCallContext(app, target_name: str, call_opt: CallOption, func_name: str, process_cb, cb_kwargs, context: Context, waiter: ResultWaiter)[source]
Bases:
objectGroupCallContext 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
- class ModuleWrapper(module: ModuleType | str | None = None)[source]
Bases:
objectWrap a module’s publish, main, init, and final functions for Collab.
Collab creates this wrapper automatically whenever a module is supplied as a primary or named app object. This allows callers to pass modules containing standalone functions anywhere they could pass class instances:
# my_module.py from nvflare.collab import collab
@collab.publish def train(weights=None):
…
@collab.main def fed_avg():
…
# main.py import my_module
recipe = CollabRecipe(server=my_module, client=my_module, …)
For a distributed deployment, the module must be importable on all client machines (i.e., part of the installed package or included in job resources).
Initialize wrapper with a module containing @collab.publish/@collab.main functions.
- Parameters:
module – A Python module object OR a fully qualified module name string. When a string is passed, the module will be imported. When no argument is passed (None), the wrapper is in an uninitialized state and will be set up by __setstate__ during unpickling.
Note
For job config serialization, we store the module name as self._module which matches the ‘module’ parameter. FLARE’s _get_args() looks for param or _param in __dict__, so _module matches ‘module’.
When running as __main__, we convert to an importable module path so that remote processes can import the same module.
- property module_name: str
Get the module name.
- class PublishInterface(methods: Mapping[str, Sequence] | None = None)[source]
Bases:
Mapping[str,MethodInterface]Immutable description of an object’s published Collab methods.
- classmethod from_dict(methods: Mapping[str, Sequence] | None) PublishInterface[source]
- get_method(method_name: str) MethodInterface | None[source]
Return a method interface, preserving an empty interface for zero-argument methods.