florist.api.client module

FLorist client FastAPI endpoints.

check_status(client_uuid, redis_host, redis_port)[source]

Retrieve value at key client_uuid in redis if it exists.

Parameters:
  • client_uuid (str) – (str) the uuid of the client to fetch from redis.

  • redis_host (str) – (str) the host name for the Redis instance for metrics reporting.

  • redis_port (str) – (str) the port for the Redis instance for metrics reporting.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns 200 with JSON containing the val at client_uuid. If not successful, returns the appropriate error code with a JSON with the format below:

{“error”: <error message>}

connect()[source]

Confirm the client is up and ready to accept instructions.

Return type:

JSONResponse

Returns:

JSON {“status”: “ok”}

get_log(uuid)[source]

Return the contents of the logs for the given client uuid.

Parameters:

uuid (str) – (str) the uuid of the client.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns the contents of the file as a string. If not successful, returns the appropriate error code with a JSON with the format below:

{“error”: <error message>}

start(server_address, client, data_path, redis_host, redis_port)[source]

Start a client.

Parameters:
  • server_address (str) – (str) the address of the FL server the FL client should report to. It should be comprised of the host name and port separated by colon (e.g. “localhost:8080”).

  • client (Client) – (Client) the client to be used for training.

  • data_path (str) – (str) the path where the training data is located.

  • redis_host (str) – (str) the host name for the Redis instance for metrics reporting.

  • redis_port (str) – (str) the port for the Redis instance for metrics reporting.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns 200 with a JSON containing the UUID for the client in the format below, which can be used to pull metrics from Redis.

{

“uuid”: (str) The client’s uuid, which can be used to pull metrics from Redis,

}

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

“error”: (str) The error message,

}

stop(uuid)[source]

Stop the client with given UUID.

Parameters:

uuid (str) – (str) the UUID of the client to be stopped.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns 200. If not successful, returns the appropriate error code with a JSON with the format below:

{“error”: <error message>}