Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MessageType #3005

Merged
merged 11 commits into from
Mar 5, 2024
2 changes: 2 additions & 0 deletions src/py/flwr/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Common components shared between server and client."""


from .constant import MessageType as MessageType
from .context import Context as Context
from .date import now as now
from .grpc import GRPC_MAX_MESSAGE_LENGTH
Expand Down Expand Up @@ -83,6 +84,7 @@
"GRPC_MAX_MESSAGE_LENGTH",
"log",
"Message",
"MessageType",
"Metadata",
"Metrics",
"MetricsAggregationFn",
Expand Down
11 changes: 11 additions & 0 deletions src/py/flwr/common/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
MESSAGE_TYPE_EVALUATE = "evaluate"


class MessageType:
"""Message type."""

TRAIN = "train"
EVALUATE = "evaluate"

def __new__(cls) -> MessageType:
"""Prevent instantiation."""
raise TypeError(f"{cls.__name__} cannot be instantiated.")


class SType:
"""Serialisation type."""

Expand Down