nvflare.app_opt.job_launcher.k8s_launcher module

class ClientK8sJobLauncher(config_file_path: str, study_data_pvc_file_path: str, timeout=None, namespace='default', pending_timeout=120, python_path=None, security_context: dict | None = None, ephemeral_storage: str = '1Gi', default_python_path: str | None = None, workspace_mount_path: str = '/var/tmp/nvflare/workspace', image_pull_secrets: list[str] | None = None)[source]

Bases: K8sJobLauncher

Init FLComponent.

The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)

FLComponents have the capability to handle and fire events and contain various methods for logging.

get_module_args(_job_id, fl_ctx: FLContext)[source]

To get the args to run the launcher

Parameters:
  • job_id – run job_id

  • fl_ctx – FLContext

Returns:

class JobState(value)[source]

Bases: Enum

An enumeration.

RUNNING = 'running'
STARTING = 'starting'
SUCCEEDED = 'succeeded'
TERMINATED = 'terminated'
UNKNOWN = 'unknown'
class K8sJobHandle(job_id: str, api_instance, job_config: dict, namespace='default', timeout=None, pending_timeout=120, python_path='/usr/local/bin/python', workspace_transfer: WorkspaceTransferManager | None = None, workspace_job_id: str = '', pod_name: str | None = None)[source]

Bases: JobHandleSpec

enter_states(job_states_to_enter: list)[source]
get_manifest()[source]
poll()[source]

To get the return code of the job run.

Returns: return_code

terminate()[source]

To terminate the job run.

Returns: None

wait()[source]

To wait until the job run complete.

Returns: returns until the job run complete.

class K8sJobLauncher(config_file_path: str, study_data_pvc_file_path: str, timeout=None, namespace='default', pending_timeout=120, python_path=None, security_context: dict | None = None, ephemeral_storage: str = '1Gi', default_python_path: str | None = None, workspace_mount_path: str = '/var/tmp/nvflare/workspace', image_pull_secrets: list[str] | None = None)[source]

Bases: JobLauncherSpec

Init FLComponent.

The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)

FLComponents have the capability to handle and fire events and contain various methods for logging.

abstract get_module_args(job_id, fl_ctx: FLContext)[source]

To get the args to run the launcher

Parameters:
  • job_id – run job_id

  • fl_ctx – FLContext

Returns:

handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

launch_job(job_meta: dict, fl_ctx: FLContext) JobHandleSpec[source]

To launch a job run.

Parameters:
  • job_meta – job metadata

  • fl_ctx – FLContext

Returns: a JobHandle instance.

class PodPhase(value)[source]

Bases: Enum

An enumeration.

FAILED = 'Failed'
PENDING = 'Pending'
RUNNING = 'Running'
SUCCEEDED = 'Succeeded'
UNKNOWN = 'Unknown'
class ServerK8sJobLauncher(config_file_path: str, study_data_pvc_file_path: str, timeout=None, namespace='default', pending_timeout=120, python_path=None, security_context: dict | None = None, ephemeral_storage: str = '1Gi', default_python_path: str | None = None, workspace_mount_path: str = '/var/tmp/nvflare/workspace', image_pull_secrets: list[str] | None = None)[source]

Bases: K8sJobLauncher

Init FLComponent.

The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)

FLComponents have the capability to handle and fire events and contain various methods for logging.

get_module_args(_job_id, fl_ctx: FLContext)[source]

To get the args to run the launcher

Parameters:
  • job_id – run job_id

  • fl_ctx – FLContext

Returns:

job_pod_name(job_id: str, site_name: str) str[source]

Build a site-scoped Kubernetes pod name for a FL job.

site_name_to_rfc1123(site_name: str, max_length: int = 47) str[source]

Convert a site name into a stable RFC1123-safe label with a hash suffix.

study_dataset_volume_name(study: str, dataset: str) str[source]
uuid4_to_rfc1123(uuid_str: str) str[source]