-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Common functions and definitions for clients.""" | ||
from enum import Enum | ||
from typing import List | ||
|
||
from fl4health.clients.basic_client import BasicClient | ||
|
||
from florist.api.clients.mnist import MnistClient | ||
|
||
|
||
class Clients(Enum): | ||
"""Enumeration of supported clients.""" | ||
|
||
MNIST = "MNIST" | ||
|
||
@classmethod | ||
def class_for_client(cls, client: "Clients") -> type[BasicClient]: | ||
""" | ||
Return the class for a given client. | ||
:param client: The client enumeration object. | ||
:return: A subclass of BasicClient corresponding to the given client. | ||
:raises ValueError: if the client is not supported. | ||
""" | ||
if client == Clients.MNIST: | ||
return MnistClient | ||
|
||
raise ValueError(f"Client {client.value} not supported.") | ||
|
||
@classmethod | ||
def list(cls) -> List[str]: | ||
""" | ||
List all the supported clients. | ||
:return: a list of supported clients. | ||
""" | ||
return [client.value for client in Clients] |