This is the base FL API service. It is used to create instances of the FLIP federated learning API.
The FL API for FLARE wraps the NVIDIA Flare Session object. In particular, we created a child of Session called FLIP_Session that wraps some of the Session function calls. There is minimal functionality difference between Session and FLIP_Session; these two classes consist of NVFLARE code, while FL-API itself is a Fast-API instance. The API itself interacts with the Central Hub for job monitoring, job submission and check-up of status of federated components (clients and server).
Port 8000 is normally used by the FL API.
Some of the endpoints in the API do not call Session and are therefore not technically dependent of an NVFLARE object. In addition, whereas the FL API wraps some of the functionalities available in Session instances, they do not interact with any component other than the FL API and are merely there for debugging or interact with the FL services directly from the FL-API.
On the other hand, when a job is launched, the FLIP package functions (especially flip.py, which instances a class called Flip) communicate with the Central Hub directly.
This diagram is an overview of all endpoints available from the FL-API and the FLIP package itself.
- FL-API endpoints that do NOT call
Session
Method type: GET
Parameters: None
Returns: the response body contains “status”: state of the server Who calls it: Central Hub API
Although it does not call FLARE, this function configures a FLARE-dedicated app (with its configure_fed_server, configure_fed_client etc.) This is the method that uploads a ready-to-launch FLARE application.
Method type: POST
Parameters:
Model ID: UUID model ID which will be saved on the CentralHub database, which will be added to the config_fed_X.json filesBody: includes:Global rounds: Number of server roundsLocal rounds: Number of rounds per site before aggregationBundle URLS: URLS to the files that will be uploaded from the APP upload bucket into the application folder (app folder)Project ID: ID of the Central Hub project for this appCohort query: SQL query linked to this projectTrusts: list of participating trustsIgnore_result_error: boolAggregator: type of aggregator that will be used (FLARE aggregator name)Aggregation weights: {trust: weight} argument that will be passed to the aggregation during construction (will be added to config)
upload_dir: path where the apps are saved
Who calls it: Central Hub API (upload_app in fl_service)
- FL-API endpoints that call
Session
Calls FLARE's session.submit_job. Kicks the job.
Method type: POST
Parameters:
App folder(that has been previously configured in the FL-API). This folder is inside of FL-API’s upload_dir, and will send it over to the server and client.
Who calls it: Central Hub API (upload_app in fl_service)
This lists the NVFLARE jobs available on the server (including those that have failed).
Method type: GET
Parameters:
detailed: extensive description requiredlimit: maximum number of jobs to listid_prefix: prefix for the job ID (string)name_prefix: prefix for the job name search (string)reverse: order reverse to submission time
Returns: a list of dictionaries (with elements related to the job such as name, job_id, status etc.).
Who calls it: Central Hub (extract_current_job_data in fl_service), without arguments (it then filters by job_id). It’s only used to abort jobs.
Method type: DELETE
Parameters:
job_id
Who calls it: Central Hub API (abort_job in fl_service)
It provides the status of the Central Hub FL server, FL clients, or both, depending on the parameters.
Method type: GET
Parameters:
target_type: type of target (client or server)targets: list of specific targets
Who calls it: Central Hub API in fl_services
It provides the status of the Central Hub FL server.
Method type: GET
Who calls it: Central Hub API in fl_services
It provides the status of the FL clients.
Method type: GET
Parameters:
targets: list of specific targets (e.g. client-1)
Who calls it: Central Hub API in fl_services
- FL-API endpoints that are not used in FLIP
Shows errors for a specific job ID and, optionally, a list of clients.
Method type: POST
Parameters:
job_id: Job ID to show errors fortarget_type: (e.g. server, client, all)targets: (list of targets - e.g. server, client 1 etc.)
Shows statistics (status, ID etc.) for a specific job ID and, optionally, a list of clients.
Method type: POST
Parameters:
job_id: Job ID to show stats fortarget_type: (e.g. server, client, all)targets: (list of targets - e.g. server, client 1 etc.)
Resets errors for a specific job ID.
Method type: POST
Parameters:
job_id: Job ID to reset errors for
Deletes a job from the system.
Method type: DELETE
Parameters:
job_id: Job ID to delete
Lists available apps in the Session’s upload_dir.
Method type: GET
Parameters: None
Downloads model results (not used, as FLIP does this via the Central Hub and AWS using the model ID).
Method type: GET
Parameters:
job_id: NVFLARE job ID
Gets a list of connected clients.
Method type: GET
Parameters: None
Gets the working directory on the targets (runs pwd on the clients or server).
Method type: GET
Parameters:
target: target where you want to run this
Restarts the specified targets.
Method type: POST
Parameters:
target_type: targets that you want to restartclient_names: for target_type client, this is a list of specific clients you want to restart
Shuts down the specified targets.
Method type: POST
Parameters:
target_type: targets that you want to shut down (e.g. server, client, all)client_names: for target_type client, this is a list of specific clients you want to shut down
Shuts down the system.
Method type: POST
Parameters: None
The nvflare local and startup folders are created during the provisioning of each real network (server, client(s) and API). However, Python tests require fed_admin.json to exist within admin/startup. Therefore, this file is created dynamically in ./tests/utils/test_flip_session.py for testing purposes.
FL_ADMIN_DIRECTORY is set to a temporary directory in ./tests/conftest.py during testing to avoid conflicts with any existing admin directories.
