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

feat(framework) Add internal flwr-clientapp command #3973

Merged
merged 19 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ flower-supernode = "flwr.client:run_supernode"
flower-client-app = "flwr.client:run_client_app"
flower-server-app = "flwr.server:run_server_app"
flower-simulation = "flwr.simulation.run_simulation:run_simulation_from_cli"
flower-exec-client-app = "flwr.client.supernode:exec_client_app"

[tool.poetry.dependencies]
python = "^3.8"
Expand Down
2 changes: 2 additions & 0 deletions src/py/flwr/client/supernode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
"""Flower SuperNode."""


from .app import exec_client_app as exec_client_app
from .app import run_client_app as run_client_app
from .app import run_supernode as run_supernode

__all__ = [
"exec_client_app",
"run_client_app",
"run_supernode",
]
35 changes: 35 additions & 0 deletions src/py/flwr/client/supernode/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ def run_client_app() -> None:
register_exit_handlers(event_type=EventType.RUN_CLIENT_APP_LEAVE)


def exec_client_app() -> None:
chongshenng marked this conversation as resolved.
Show resolved Hide resolved
"""Run process-isolated Flower client app."""
danieljanes marked this conversation as resolved.
Show resolved Hide resolved
log(INFO, "Starting Flower ClientApp")

event(EventType.RUN_CLIENT_APP_ENTER)

# args = _parse_args_exec_client_app().parse_args()

register_exit_handlers(event_type=EventType.RUN_CLIENT_APP_LEAVE)


def _warn_deprecated_server_arg(args: argparse.Namespace) -> None:
"""Warn about the deprecated argument `--server`."""
if args.server != ADDRESS_FLEET_API_GRPC_RERE:
Expand Down Expand Up @@ -275,6 +286,13 @@ def _parse_args_run_supernode() -> argparse.ArgumentParser:
- `$HOME/.flwr/` in all other cases
""",
)
parser.add_argument(
"--isolate",
action="store_true",
help="Run the ClientApp in an isolated process from the SuperNode."
"In this mode, the ClientApp and SuperNode communicate via gRPC."
"By default, both SuperNode and ClientApp run in the same process.",
danieljanes marked this conversation as resolved.
Show resolved Hide resolved
)

return parser

Expand All @@ -294,6 +312,23 @@ def _parse_args_run_client_app() -> argparse.ArgumentParser:
return parser


def _parse_args_exec_client_app() -> argparse.ArgumentParser:
"""Parse exec-client-app command line arguments."""
parser = argparse.ArgumentParser(
description="Run a Flower client app",
)
parser.add_argument(
"--address",
help="Address of SuperNode",
)
parser.add_argument(
"--token",
help="Unique token generated by SuperNode for each client app execution",
)

return parser


def _parse_args_common(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"--insecure",
Expand Down