-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Heng Pan <[email protected]>
- Loading branch information
1 parent
8b11180
commit 3c86a57
Showing
7 changed files
with
145 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Flower Labs GmbH. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
"""Flower SuperNode.""" | ||
|
||
|
||
from .app import run_supernode as run_supernode | ||
|
||
__all__ = [ | ||
"run_supernode", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Copyright 2024 Flower Labs GmbH. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
"""Flower SuperNode.""" | ||
|
||
import argparse | ||
from logging import DEBUG, INFO | ||
|
||
from flwr.common import EventType, event | ||
from flwr.common.exit_handlers import register_exit_handlers | ||
from flwr.common.logger import log | ||
|
||
|
||
def run_supernode() -> None: | ||
"""Run Flower SuperNode.""" | ||
log(INFO, "Starting Flower SuperNode") | ||
|
||
event(EventType.RUN_SUPERNODE_ENTER) | ||
|
||
args = _parse_args_run_supernode().parse_args() | ||
|
||
log( | ||
DEBUG, | ||
"Flower will load ClientApp `%s`", | ||
getattr(args, "client-app"), | ||
) | ||
|
||
# Graceful shutdown | ||
register_exit_handlers( | ||
event_type=EventType.RUN_SUPERNODE_LEAVE, | ||
) | ||
|
||
|
||
def _parse_args_run_supernode() -> argparse.ArgumentParser: | ||
"""Parse flower-supernode command line arguments.""" | ||
parser = argparse.ArgumentParser( | ||
description="Start a Flower SuperNode", | ||
) | ||
|
||
parse_args_run_client_app(parser=parser) | ||
|
||
return parser | ||
|
||
|
||
def parse_args_run_client_app(parser: argparse.ArgumentParser) -> None: | ||
"""Parse command line arguments.""" | ||
parser.add_argument( | ||
"client-app", | ||
help="For example: `client:app` or `project.package.module:wrapper.app`", | ||
) | ||
parser.add_argument( | ||
"--insecure", | ||
action="store_true", | ||
help="Run the client without HTTPS. By default, the client runs with " | ||
"HTTPS enabled. Use this flag only if you understand the risks.", | ||
) | ||
parser.add_argument( | ||
"--rest", | ||
action="store_true", | ||
help="Use REST as a transport layer for the client.", | ||
) | ||
parser.add_argument( | ||
"--root-certificates", | ||
metavar="ROOT_CERT", | ||
type=str, | ||
help="Specifies the path to the PEM-encoded root certificate file for " | ||
"establishing secure HTTPS connections.", | ||
) | ||
parser.add_argument( | ||
"--server", | ||
default="0.0.0.0:9092", | ||
help="Server address", | ||
) | ||
parser.add_argument( | ||
"--max-retries", | ||
type=int, | ||
default=None, | ||
help="The maximum number of times the client will try to connect to the" | ||
"server before giving up in case of a connection error. By default," | ||
"it is set to None, meaning there is no limit to the number of tries.", | ||
) | ||
parser.add_argument( | ||
"--max-wait-time", | ||
type=float, | ||
default=None, | ||
help="The maximum duration before the client stops trying to" | ||
"connect to the server in case of connection error. By default, it" | ||
"is set to None, meaning there is no limit to the total time.", | ||
) | ||
parser.add_argument( | ||
"--dir", | ||
default="", | ||
help="Add specified directory to the PYTHONPATH and load Flower " | ||
"app from there." | ||
" Default: current working directory.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters