nvflare.apis.impl.job_def_manager module

class JobInfo(meta: dict, job_id: str, uri: str)[source]

Bases: object

class SimpleJobDefManager(uri_root: str = 'jobs', job_store_id: str = 'job_store')[source]

Bases: JobDefManagerSpec

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.

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.

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.

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

Deletes the specified Job.

Parameters:
  • jid (str) – Job ID

  • fl_ctx (FLContext) – FLContext information

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

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

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

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

Gets the Job object through the job ID.

Parameters:
  • jid (str) – Job ID

  • fl_ctx (FLContext) – FLContext information

Returns:

A Job object

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

Get jobs that are in the specified status

Parameters:
  • status – a single status value or a list of status values

  • fl_ctx – the FL context

Returns: list of jobs that are in specified status

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

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.

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

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

job_uri(jid: str)[source]
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

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

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.

set_results_uri(jid: str, result_uri: str, fl_ctx: FLContext)[source]
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

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