nvflare.apis.job_def_manager_spec module

class JobDefManagerSpec[source]

Bases: FLComponent, ABC

Job Definition Management API.

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 clone(from_jid: str, meta: dict, fl_ctx: FLContext) Dict[str, Any][source]

Create a new job by cloning an existing job.

Parameters:
  • from_jid – the job to be cloned

  • meta – meta info for the new job

  • fl_ctx – FLContext info

Returns:

A dict containing meta info. Additional meta info are added, especially a unique Job ID (jid) which has been created.

abstract create(meta: dict, uploaded_content: str | bytes, fl_ctx: FLContext) Dict[str, Any][source]

Create a new job permanently.

The caller must have validated the content already and created initial meta. Receives bytes of uploaded folder, uploading to permanent store, create unique Job ID (jid) and return meta.

Parameters:
  • meta – caller-provided meta info

  • uploaded_content – data of the job definition: data bytes or file name that contains the data bytes

  • fl_ctx (FLContext) – FLContext information

Returns:

A dict containing meta info. Additional meta info are added, especially a unique Job ID (jid) which has been created.

abstract delete(jid: str, fl_ctx: FLContext)[source]

Deletes the specified Job.

Parameters:
  • jid (str) – Job ID

  • fl_ctx (FLContext) – FLContext information

abstract get_all_jobs(fl_ctx: FLContext) List[Job][source]

Gets all Jobs in the system.

Parameters:

fl_ctx (FLContext) – FLContext information

Returns:

A list of all jobs

abstract get_app(job: Job, app_name: str, fl_ctx: FLContext) bytes[source]

Get the contents of the specified app in bytes.

Parameters:
  • job – Job object

  • app_name – name of the app to get

  • fl_ctx (FLContext) – FLContext information

Returns:

Content of the specified app in bytes

abstract get_content(meta: dict, fl_ctx: FLContext) bytes | None[source]

Gets the entire uploaded content for a Job.

Parameters:
  • meta (dict) – the meta info of the job

  • fl_ctx (FLContext) – FLContext information

Returns:

Uploaded content of the job in bytes

abstract get_job(jid: str, fl_ctx: FLContext) Job[source]

Gets the Job object through the job ID.

Parameters:
  • jid (str) – Job ID

  • fl_ctx (FLContext) – FLContext information

Returns:

A Job object

abstract get_jobs_by_status(run_status: RunStatus | List[RunStatus], fl_ctx: FLContext) List[Job][source]

Gets Jobs of a specified status.

Parameters:
  • run_status – status to filter for: a single or a list of status values

  • fl_ctx (FLContext) – FLContext information

Returns:

A list of Jobs of the specified status

abstract get_jobs_to_schedule(fl_ctx: FLContext) List[Job][source]

Get job candidates for scheduling.

Parameters:

fl_ctx – FL context

Returns: list of jobs for scheduling

abstract get_jobs_waiting_for_review(reviewer_name: str, fl_ctx: FLContext) List[Job][source]

Gets Jobs waiting for review for the specified user.

Parameters:
  • reviewer_name (str) – reviewer name

  • fl_ctx (FLContext) – FLContext information

Returns:

A list of Jobs waiting for review for the specified user.

abstract get_storage_component(jid: str, component: str, fl_ctx: FLContext)[source]

Get the workspace data from the job storage.

Parameters:
  • jid (str) – Job ID

  • component – storage component name

  • fl_ctx (FLContext) – FLContext information

abstract get_storage_for_download(jid: str, download_dir: str, component: str, download_file: str, fl_ctx: FLContext)[source]

Get the workspace data from the job storage.

Parameters:
  • jid (str) – Job ID

  • download_dir – download folder

  • component – storage component name

  • download_file – download file name

  • fl_ctx (FLContext) – FLContext information

abstract refresh_meta(job: Job, meta_keys: list, fl_ctx: FLContext)[source]

Refresh meta of the job as specified in the meta keys Save the values of the specified keys into job store

Parameters:
  • job – job object

  • meta_keys – meta keys need to updated

  • fl_ctx – FLContext

abstract save_workspace(jid: str, data: bytes | str, fl_ctx: FLContext)[source]

Save the job workspace to the job storage.

Parameters:
  • jid (str) – Job ID

  • data – Job workspace data or name of data file

  • fl_ctx (FLContext) – FLContext information

abstract set_approval(jid: str, reviewer_name: str, approved: bool, note: str, fl_ctx: FLContext) Dict[str, Any][source]

Sets the approval for the specified user for a certain Job.

Parameters:
  • jid (str) – job id

  • reviewer_name (str) – reviewer name

  • approved (bool) – whether job is approved

  • note (str) – any note message

  • fl_ctx (FLContext) – FLContext information

Returns:

A dictionary of Job metadata.

abstract set_status(jid: str, status: RunStatus, fl_ctx: FLContext)[source]

Set status of an existing Job.

Parameters:
  • jid (str) – Job ID

  • status (RunStatus) – status to set

  • fl_ctx (FLContext) – FLContext information

abstract update_meta(jid: str, meta, fl_ctx: FLContext)[source]

Update the meta of an existing Job.

Parameters:
  • jid (str) – Job ID

  • meta – dictionary of metadata for the job

  • fl_ctx (FLContext) – FLContext information