florist.api.routes.server.training module

FastAPI routes for training.

async client_training_listener(job, client_info)[source]

Listen to the Redis’ channel that reports updates on the training process of a FL client.

Keeps consuming updates to the channel until it finds shutdown in the client metrics.

Parameters:
  • job (Job) – (Job) The job that has this client’s metrics.

  • client_info (ClientInfo) – (ClientInfo) The ClientInfo with the client_uuid to listen to.

Return type:

None

async server_training_listener(job)[source]

Listen to the Redis’ channel that reports updates on the training process of a FL server.

Keeps consuming updates to the channel until it finds fit_end in the server metrics, then closes the job with FINISHED_SUCCESSFULLY and saves both the clients and server’s metrics to the job in the database.

Parameters:

job (Job) – (Job) The job with the server_uuid to listen to.

Return type:

None

async start(job_id, request)[source]

Start FL training for a job id by starting a FL server and its clients.

Parameters:
  • job_id (str) – (str) The id of the Job record in the DB which contains the information necessary to start training.

  • request (Request) – (fastapi.Request) the FastAPI request object.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns 200 with a JSON containing the UUID for the server and the clients in the format below. The UUIDs can be used to pull metrics from Redis.

{

“server_uuid”: <client uuid>, “client_uuids”: [<client_uuid_1>, <client_uuid_2>, …, <client_uuid_n>],

}

If not successful, returns the appropriate error code with a JSON with the format below:

{“error”: <error message>}