Skip to content

Commit

Permalink
Introduce experimental feature warning (#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljanes authored Nov 21, 2023
1 parent 10bfc33 commit 8bcc4bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/py/flwr/client/grpc_rere_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


from contextlib import contextmanager
from logging import DEBUG, ERROR, WARN
from logging import DEBUG, ERROR
from pathlib import Path
from typing import Callable, Dict, Iterator, Optional, Tuple, Union, cast

Expand All @@ -28,7 +28,7 @@
)
from flwr.common import GRPC_MAX_MESSAGE_LENGTH
from flwr.common.grpc import create_channel
from flwr.common.logger import log
from flwr.common.logger import log, warn_experimental_feature
from flwr.proto.fleet_pb2 import (
CreateNodeRequest,
DeleteNodeRequest,
Expand Down Expand Up @@ -88,6 +88,8 @@ def grpc_request_response(
create_node : Optional[Callable]
delete_node : Optional[Callable]
"""
warn_experimental_feature("`grpc-rere`")

if isinstance(root_certificates, str):
root_certificates = Path(root_certificates).read_bytes()

Expand All @@ -99,14 +101,6 @@ def grpc_request_response(
channel.subscribe(on_channel_state_change)
stub = FleetStub(channel)

log(
WARN,
"""
EXPERIMENTAL: `grpc-rere` is an experimental transport layer, it might change
considerably in future versions of Flower
""",
)

# Necessary state to link TaskRes to TaskIns
state: Dict[str, Optional[TaskIns]] = {KEY_TASK_INS: None}

Expand Down
16 changes: 15 additions & 1 deletion src/py/flwr/common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


import logging
from logging import LogRecord
from logging import WARN, LogRecord
from logging.handlers import HTTPHandler
from typing import Any, Dict, Optional, Tuple

Expand Down Expand Up @@ -97,3 +97,17 @@ def configure(

logger = logging.getLogger(LOGGER_NAME) # pylint: disable=invalid-name
log = logger.log # pylint: disable=invalid-name


def warn_experimental_feature(name: str) -> None:
"""Warn the user when they use an experimental feature."""
log(
WARN,
"""
EXPERIMENTAL FEATURE: %s
This is an experimental feature. It could change significantly or be removed
entirely in future versions of Flower.
""",
name,
)

0 comments on commit 8bcc4bd

Please sign in to comment.