nvflare.fuel.flare_api.api_spec module¶
- class MonitorReturnCode(value)[source]¶
Bases:
int
,Enum
An enumeration.
- ENDED_BY_CB = 2¶
- JOB_FINISHED = 0¶
- TIMEOUT = 1¶
- class SessionSpec[source]¶
Bases:
ABC
- abstract abort_job(job_id: str)[source]¶
Abort the specified job
- Parameters:
job_id – job to be aborted
Returns: None
If the job is already done, no effect; If job is not started yet, it will be cancelled and won’t be scheduled. If the job is being executed, it will be aborted
- abstract clone_job(job_id: str) str [source]¶
Create a new job by cloning a specified job
- Parameters:
job_id – job to be cloned
Returns: ID of the new job
- abstract delete_job(job_id: str)[source]¶
Delete the specified job completely from the system
- Parameters:
job_id – job to be deleted
Returns: None
If the job is being executed, the job will be stopped first. Everything of the job will be deleted from the job store, as well as workspaces on the FL server and clients.
- abstract download_job_result(job_id: str) str [source]¶
Download result of the job
- Parameters:
job_id – ID of the job
Returns: folder path to the location of the job result
If the job size is smaller than the maximum size set on the server, the job will download to the download_dir set in Session through the admin config, and the path to the downloaded result will be returned. If the size of the job is larger than the maximum size, the location to download the job will be returned.
- abstract get_job_meta(job_id: str) dict [source]¶
Get the meta info of the specified job
- Parameters:
job_id – ID of the job
Returns: a dict of job meta data
- abstract get_system_info() SystemInfo [source]¶
- abstract list_jobs(detailed: bool = False, all: bool = False) List[dict] [source]¶
Get the job info from the server
- Parameters:
detailed – True to get the detailed information for each job, False by default
all – True to get jobs submitted by all users (default is to only list jobs submitted by the same user)
Returns: a list of of job meta data
- abstract monitor_job(job_id: str, timeout: int = 0, poll_interval: float = 2.0, cb=None, *cb_args, **cb_kwargs) MonitorReturnCode [source]¶
- Monitor the job progress until one of the conditions occurs:
job is done
timeout
the status_cb returns False
- Parameters:
job_id – the job to be monitored
timeout – how long to monitor. If 0, never time out.
poll_interval – how often to poll job status
cb – if provided, callback to be called after each poll
Returns: a MonitorReturnCode
Every time the cb is called, it must return a bool indicating whether the monitor should continue. If False, this method ends.
- class SystemInfo(server_info: ServerInfo, client_info: List[ClientInfo], job_info: List[JobInfo])[source]¶
Bases:
object
- job_monitor_cb_signature(session: SessionSpec, job_id: str, job_mea: dict, *args, **kwargs) bool [source]¶
- Parameters:
session – the session
job_id – ID of the job being monitored
job_mea – meta info of the job
*args –
**kwargs –
Returns: