Skip to content

refactor(framework): Create SuperLinkLifespanConfig#7497

Open
danieljanes wants to merge 1 commit into
mainfrom
create-superlink-lifespan-config
Open

refactor(framework): Create SuperLinkLifespanConfig#7497
danieljanes wants to merge 1 commit into
mainfrom
create-superlink-lifespan-config

Conversation

@danieljanes

Copy link
Copy Markdown
Member

No description provided.

@danieljanes danieljanes requested a review from tanertopal as a code owner June 26, 2026 19:23
Copilot AI review requested due to automatic review settings June 26, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the flower-superlink CLI startup flow by introducing a SuperLinkLifespanConfig dataclass and extracting CLI parsing/validation into a dedicated helper, with tests to ensure “final defaults” are applied consistently.

Changes:

  • Added SuperLinkLifespanConfig and _parse_superlink_lifespan_config() to centralize CLI parsing, validation, and derived defaults (e.g., Fleet API default address).
  • Updated flower_superlink() to consume the parsed config instead of reading directly from argparse args.
  • Added unit tests covering the new config parsing behavior (final defaults + deprecated --exec-api-address mapping).

Critical issues

  • None found.

Simplicity/readability suggestions

  • Replace cast(str, config.fleet_api_address) with an assertion to encode the invariant and avoid relying on a type-cast (comment added inline).

Consistency concerns

  • A module-level # pylint: disable=too-many-lines weakens linting as the file grows; consider splitting CLI parsing/config/startup into smaller modules rather than globally disabling the check.

Whether the PR should be split

  • Not required, but if follow-ups are planned, consider a separate PR to split flower_superlink.py into smaller files to remove the global pylint suppression.

Brief overall verdict

  • The refactor is directionally sound and tests help, but there’s a behavioral change around when the “Starting” log/telemetry event fires that should be confirmed as intended.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
framework/py/flwr/superlink/cli/flower_superlink.py Extracts CLI parsing into _parse_superlink_lifespan_config() and introduces SuperLinkLifespanConfig to drive server startup.
framework/py/flwr/superlink/cli/flower_superlink_test.py Adds tests verifying config parsing applies derived defaults and preserves deprecated address mapping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# ==============================================================================
"""`flower-superlink` command."""

# pylint: disable=too-many-lines
Comment on lines +451 to +455
config = _parse_superlink_lifespan_config()

log(INFO, "Starting Flower SuperLink")

event(EventType.RUN_SUPERLINK_ENTER)
Comment on lines 497 to +499
if not is_simulation:
if not args.fleet_api_address:
if args.fleet_api_type in [
TRANSPORT_TYPE_GRPC_RERE,
TRANSPORT_TYPE_GRPC_ADAPTER,
]:
args.fleet_api_address = FLEET_API_GRPC_RERE_DEFAULT_ADDRESS
elif args.fleet_api_type == TRANSPORT_TYPE_REST:
args.fleet_api_address = FLEET_API_REST_DEFAULT_ADDRESS

fleet_address, host, port = _format_address(args.fleet_api_address)

num_workers = args.fleet_api_num_workers
fleet_address, host, port = _format_address(cast(str, config.fleet_api_address))

@github-actions github-actions Bot added the Maintainer Used to determine what PRs (mainly) come from Flower maintainers. label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintainer Used to determine what PRs (mainly) come from Flower maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants