florist.api.db.entities module¶
Definitions for the MongoDB database entities.
- class ClientInfo(**data)[source]¶
Bases:
BaseModel
Define the information of an FL client.
- class Config[source]¶
Bases:
object
MongoDB config for the ClientInfo DB entity.
- allow_population_by_field_name = True¶
- schema_extra = {'example': {'client': 'MNIST', 'data_path': 'path/to/data', 'metrics': '{"host_type": "client", "initialized": "2024-03-25 11:20:56.819569", "rounds": {"1": {"fit_start": "2024-03-25 11:20:56.827081"}}}', 'redis_host': 'localhost', 'redis_port': '6380', 'service_address': 'localhost:8001', 'uuid': '0c316680-1375-4e07-84c3-a732a2e6d03f'}}¶
- class Job(**data)[source]¶
Bases:
BaseModel
Define the Job DB entity.
- class Config[source]¶
Bases:
object
MongoDB config for the Job DB entity.
- allow_population_by_field_name = True¶
- schema_extra = {'example': {'_id': '066de609-b04a-4b30-b46c-32537c7f1f6e', 'clients_info': [{'client': 'MNIST', 'client_uuid': '0c316680-1375-4e07-84c3-a732a2e6d03f', 'data_path': 'path/to/data', 'redis_host': 'localhost', 'redis_port': '6380', 'service_address': 'localhost:8001'}], 'model': 'MNIST', 'redis_host': 'localhost', 'redis_port': '6379', 'server_address': 'localhost:8000', 'server_config': '{"n_server_rounds": 3, "batch_size": 8, "local_epochs": 1}', 'server_metrics': '{"host_type": "server", "fit_start": "2024-04-23 15:33:12.865604", "rounds": {"1": {"fit_start": "2024-04-23 15:33:12.869001"}}}', 'server_uuid': 'd73243cf-8b89-473b-9607-8cd0253a101d', 'status': 'NOT_STARTED'}}¶
-
clients_info:
Optional
[Annotated
[List
[ClientInfo
]]]¶
-
config_parser:
Optional
[Annotated
[ConfigParser
]]¶
- async create(database)[source]¶
Save this instance under a new record in the database.
- Parameters:
database (
AsyncIOMotorDatabase
) – (motor.motor_asyncio.AsyncIOMotorDatabase) The database where the job collection is stored.- Return type:
- Returns:
(str) the new job record’s id.
- async classmethod find_by_id(job_id, database)[source]¶
Find a job in the database by its id.
- Parameters:
job_id (
str
) – (str) the job’s id.database (
AsyncIOMotorDatabase
) – (motor.motor_asyncio.AsyncIOMotorDatabase) The database where the job collection is stored.
- Return type:
- Returns:
(Optional[Job]) An instance of the job record with the given ID, or None if it can’t be found.
- async classmethod find_by_status(status, limit, database)[source]¶
Return all jobs with the given status.
- Parameters:
- Return type:
- Returns:
(List[Job]) The list of jobs with the given status in the database.
- async set_client_metrics(client_uuid, client_metrics, database)[source]¶
Save a client’s metrics in the database under the current job’s id.
- Parameters:
- Return type:
- async set_server_metrics(server_metrics, database)[source]¶
Save the server’s metrics in the database under the current job’s id.
- async set_status(status, database)[source]¶
Save the status in the database under the current job’s id.