nvflare.fuel.flare_api.api_spec module

exception AuthenticationError[source]

Bases: Exception

exception AuthorizationError[source]

Bases: Exception

class ClientInfo(name: str, last_connect_time)[source]

Bases: object

exception InternalError[source]

Bases: Exception

exception InvalidArgumentError[source]

Bases: Exception

exception InvalidJobDefinition[source]

Bases: Exception

class JobInfo(job_id: str, app_name: str)[source]

Bases: object

exception JobNotDone[source]

Bases: Exception

exception JobNotFound[source]

Bases: Exception

class MonitorReturnCode(value)[source]

Bases: int, Enum

An enumeration.

ENDED_BY_CB = 2
JOB_FINISHED = 0
TIMEOUT = 1
exception NoConnection[source]

Bases: Exception

class ServerInfo(status, start_time)[source]

Bases: object

exception SessionClosed[source]

Bases: Exception

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 close()[source]

Close the session

Returns:

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.

abstract submit_job(job_definition_path: str) str[source]

Submit a predefined job to the NVFLARE system

Parameters:

job_definition_path – path to the folder that defines a NVFLARE job

Returns: the job id if accepted by the system

If the submission fails, exception will be raised:

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: