Skip to content

Commit

Permalink
Merge branch 'main' into bump-vers-1.15.1-post
Browse files Browse the repository at this point in the history
  • Loading branch information
tanertopal authored Feb 5, 2025
2 parents c0300b5 + 01ac3fb commit e4f6d03
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 30 deletions.
36 changes: 35 additions & 1 deletion framework/docs/source/ref-changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
# Changelog

## Unreleased
## v1.15.1 (2025-02-05)

### Thanks to our contributors

We would like to give our special thanks to all the contributors who made the new version of Flower possible (in `git shortlog` order):

`Dimitris Stripelis`, `Heng Pan`, `Javier`, `Taner Topal`, `Yan Gao` <!---TOKEN_v1.15.1-->

### What's new?

- **Improve time drift compensation in automatic SuperNode authentication** ([#4899](https://github.com/adap/flower/pull/4899))

In addition to allowing for a time delay (positive time difference), SuperLink now also accounts for time drift, which might result in negative time differences between timestamps in SuperLink and SuperNode during authentication.

- **Rename constants for gRPC metadata** ([#4902](https://github.com/adap/flower/pull/4902))

All metadata keys in gRPC messages that previously used underscores (`_`) have been replaced with hyphens (`-`). Using underscores is not recommended in setups where SuperLink may be deployed behind load balancers or reverse proxies.

- **Filtering out non-Fleet API requests at the `FleetServicer`** ([#4900](https://github.com/adap/flower/pull/4900))

The Fleet API endpoint will now reject gRPC requests that are not part of its API.

- **Fix exit handlers mechanism for Windows** ([#4907](https://github.com/adap/flower/pull/4907))

The `SIGQUIT` [Python signal](https://docs.python.org/3/library/signal.html) is not supported on Windows. This signal is now excluded when Flower is executed on Windows.

- **Updated Examples** ([#4895](https://github.com/adap/flower/pull/4895), [#4158](https://github.com/adap/flower/pull/4158), [#4879](https://github.com/adap/flower/pull/4879))

Examples have been updated to the latest version of Flower. Some examples have also had their dependencies upgraded. The [Federated Finetuning of a Whisper model example](https://github.com/adap/flower/tree/main/examples/whisper-federated-finetuning) has been updated to use the new Flower execution method: `flwr run`.

- **Update FlowerTuneLLM Leaderboard evaluation scripts** ([#4919](https://github.com/adap/flower/pull/4910))

We have updated the package versions used in the evaluation scripts. There is still time to participate in the [Flower LLM Leaderboard](https://flower.ai/benchmarks/llm-leaderboard/)!

- **Update Documentation** ([#4897](https://github.com/adap/flower/pull/4897), [#4896](https://github.com/adap/flower/pull/4896), [#4898](https://github.com/adap/flower/pull/4898), [#4909](https://github.com/adap/flower/pull/4909))

## v1.15.0 (2025-01-31)

Expand Down
46 changes: 17 additions & 29 deletions src/py/flwr/common/exit_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@
"""Common function to register exit handlers for server and client."""


from signal import SIGINT, SIGQUIT, SIGTERM, signal
import signal
from threading import Thread
from types import FrameType
from typing import Optional
from typing import Callable, Optional

from grpc import Server

from flwr.common.telemetry import EventType

from .exit import ExitCode, flwr_exit

SIGNAL_TO_EXIT_CODE = {
SIGINT: ExitCode.GRACEFUL_EXIT_SIGINT,
SIGQUIT: ExitCode.GRACEFUL_EXIT_SIGQUIT,
SIGTERM: ExitCode.GRACEFUL_EXIT_SIGTERM,
SIGNAL_TO_EXIT_CODE: dict[int, int] = {
signal.SIGINT: ExitCode.GRACEFUL_EXIT_SIGINT,
signal.SIGTERM: ExitCode.GRACEFUL_EXIT_SIGTERM,
}

# SIGQUIT is not available on Windows
if hasattr(signal, "SIGQUIT"):
SIGNAL_TO_EXIT_CODE[signal.SIGQUIT] = ExitCode.GRACEFUL_EXIT_SIGQUIT


def register_exit_handlers(
event_type: EventType,
Expand All @@ -54,23 +57,16 @@ def register_exit_handlers(
An optional list of threads that need to be gracefully
terminated before exiting.
"""
default_handlers = {
SIGINT: None,
SIGQUIT: None,
SIGTERM: None,
}

def graceful_exit_handler( # type: ignore
signalnum,
frame: FrameType, # pylint: disable=unused-argument
) -> None:
default_handlers: dict[int, Callable[[int, FrameType], None]] = {}

def graceful_exit_handler(signalnum: int, _frame: FrameType) -> None:
"""Exit handler to be registered with `signal.signal`.
When called will reset signal handler to original signal handler from
default_handlers.
"""
# Reset to default handler
signal(signalnum, default_handlers[signalnum])
signal.signal(signalnum, default_handlers[signalnum]) # type: ignore

if grpc_servers is not None:
for grpc_server in grpc_servers:
Expand All @@ -87,15 +83,7 @@ def graceful_exit_handler( # type: ignore
event_type=event_type,
)

default_handlers[SIGINT] = signal( # type: ignore
SIGINT,
graceful_exit_handler, # type: ignore
)
default_handlers[SIGQUIT] = signal( # type: ignore
SIGQUIT,
graceful_exit_handler, # type: ignore
)
default_handlers[SIGTERM] = signal( # type: ignore
SIGTERM,
graceful_exit_handler, # type: ignore
)
# Register signal handlers
for sig in SIGNAL_TO_EXIT_CODE:
default_handler = signal.signal(sig, graceful_exit_handler) # type: ignore
default_handlers[sig] = default_handler # type: ignore

0 comments on commit e4f6d03

Please sign in to comment.