nvflare.job_config.script_runner module¶
- class BaseScriptRunner(script: str, script_args: str = '', launch_external_process: bool = False, command: str = 'python3 -u', framework: FrameworkType = 'pytorch', params_transfer_type: str = 'FULL', executor: ClientAPILauncherExecutor | InProcessClientAPIExecutor | None = None, task_pipe: Pipe | None = None, launcher: Launcher | None = None, metric_relay: MetricRelay | None = None, metric_pipe: Pipe | None = None)[source]¶
Bases:
object
BaseScriptRunner is used with FedJob API to run or launch a script.
- If executor is not provided,
launch_external_process=False uses InProcessClientAPIExecutor. launch_external_process=True uses ClientAPILauncherExecutor.
else the provided executor will be used.
If some components are passed in, it is user’s responsibility to make sure they are consistent with each other. For example, if user provide a task_pipe, the default task_pipe_id is “task_pipe”, please make sure the ClientAPILauncherExecutor is created using the matching pipe_id.
- Parameters:
script (str) – Script to run. For in-process must be a python script path. For ex-process can be any script support by command.
script_args (str) – Optional arguments for script (appended to script).
launch_external_process (bool) – Whether to launch the script in external process. Defaults to False.
command (str) – If launch_external_process=True, command to run script (preprended to script). Defaults to “python3”.
framework (str) – Framework type to connfigure converter and params exchange formats. Defaults to FrameworkType.PYTORCH.
params_transfer_type (str) – How to transfer the parameters. FULL means the whole model parameters are sent. DIFF means that only the difference is sent. Defaults to TransferType.FULL.
executor (Union[ClientAPILauncherExecutor, InProcessClientAPIExecutor, None], optional) – The executor to use in client process. Can be an instance of ClientAPILauncherExecutor, InProcessClientAPIExecutor, or None. Defaults to None. If specified, the script and script_args and command will be ignored.
task_pipe (Optional[Pipe], optional) – An optional Pipe instance for passing task between ClientAPILauncherExecutor and client api, this is only used if launch_external_process is True.
launcher (Optional[Launcher], optional) – The launcher to use with ClientAPILauncherExecutor, only used if launch_external_process is True. Defaults to None.
metric_relay (Optional[MetricRelay], optional) – An optional MetricRelay instance that can be used to relay metrics to the server. Defaults to None.
metric_pipe (Optional[Pipe], optional) – An optional Pipe instance for passing metric data between components. This allows for real-time metric handling during execution. Defaults to None.
- class FrameworkType[source]¶
Bases:
object
- NUMPY = 'numpy'¶
- PYTORCH = 'pytorch'¶
- RAW = 'raw'¶
- TENSORFLOW = 'tensorflow'¶
- class ScriptRunner(script: str, script_args: str = '', launch_external_process: bool = False, command: str = 'python3 -u', framework: FrameworkType = 'pytorch', params_transfer_type: str = 'FULL')[source]¶
Bases:
BaseScriptRunner
ScriptRunner is used with FedJob API to run or launch a script.
in-process launch_external_process=False uses InProcessClientAPIExecutor (default). ex-process launch_external_process=True uses ClientAPILauncherExecutor.
- Parameters:
script (str) – Script to run. For in-process must be a python script path. For ex-process can be any script support by command.
script_args (str) – Optional arguments for script (appended to script).
launch_external_process (bool) – Whether to launch the script in external process. Defaults to False.
command (str) – If launch_external_process=True, command to run script (preprended to script). Defaults to “python3”.
framework (str) – Framework type to connfigure converter and params exchange formats. Defaults to FrameworkType.PYTORCH.
params_transfer_type (str) – How to transfer the parameters. FULL means the whole model parameters are sent. DIFF means that only the difference is sent. Defaults to TransferType.FULL.