nvflare.apis.impl.job_def_manager module¶
- 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.
- create(meta: dict, uploaded_content: 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
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_apps(job: Job, fl_ctx: FLContext) Dict[str, bytes] [source]¶
Get the all the apps of a Job.
- Parameters
job – Job object
fl_ctx (FLContext) – FLContext information
- Returns
A dictionary of app names with the content of the corresponding app encoded in bytes
- get_content(jid: str, fl_ctx: FLContext) Optional[bytes] [source]¶
Gets the entire uploaded content for a Job.
- Parameters
jid (str) – Job ID
fl_ctx (FLContext) – FLContext information
- Returns
Uploaded content of the job in bytes
- get_job(jid: str, fl_ctx: FLContext) Optional[Job] [source]¶
Gets the Job object through the job ID.
- Parameters
jid (str) – Job ID
fl_ctx (FLContext) – FLContext information
- Returns
A Job object
- get_job_data(jid: str, fl_ctx: FLContext) dict [source]¶
Gets the entire uploaded content and workspace for a job.
- Parameters
jid (str) – Job ID
fl_ctx (FLContext) – FLContext information
- Returns
a dict to hold the job data and workspace. Format: {
JobDataKey.JOB_DATA.value: stored_data, JobDataKey.WORKSPACE_DATA: workspace_data
}
- get_jobs_by_status(status, fl_ctx: FLContext) List[Job] [source]¶
Gets Jobs of a specified status.
- Parameters
run_status (RunStatus) – status to filter for
fl_ctx (FLContext) – FLContext information
- Returns
A list of Jobs of the specified status
- 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.
- save_workspace(jid: str, data: bytes, fl_ctx: FLContext)[source]¶
Save the job workspace to the job storage.
- Parameters
jid (str) – Job ID
data – Job workspace data
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.