nvflare.app_common.tie.py_applet module¶
- class PyApplet(in_process: bool)[source]¶
Bases:
Applet
,ABC
Constructor of PyApplet, which runs the applet’s Python code in a separate thread or subprocess.
- Parameters:
in_process – whether to run the applet code as separate thread within the same process or as a separate subprocess.
- abstract get_runner(app_ctx: dict) PyRunner [source]¶
Subclass must implement this method to return a PyRunner. The returned PyRunner must be pickleable since it could be run in a separate subprocess!
- Parameters:
app_ctx – the app context for the runner
Returns: a PyRunner object
- is_stopped() -> (<class 'bool'>, <class 'int'>)[source]¶
Called to check whether the applet is already stopped.
Returns: whether the applet is stopped, and the exit code if stopped.
- class PyRunner[source]¶
Bases:
ABC
A PyApplet must return a light-weight PyRunner object to run the Python code of the external app. Since the runner could be running in a separate subprocess, the runner object must be pickleable!
- abstract is_stopped() -> (<class 'bool'>, <class 'int'>)[source]¶
Check whether the app code is stopped
Returns: a tuple of: whether the app is stopped, and exit code if stopped