diff --git a/src/py/flwr/common/constant.py b/src/py/flwr/common/constant.py index 664eb5a30cd7..9f2d97febd83 100644 --- a/src/py/flwr/common/constant.py +++ b/src/py/flwr/common/constant.py @@ -54,6 +54,7 @@ EXEC_API_DEFAULT_SERVER_ADDRESS = f"{SERVER_OCTET}:{EXEC_API_PORT}" SIMULATIONIO_API_DEFAULT_SERVER_ADDRESS = f"{SERVER_OCTET}:{SIMULATIONIO_PORT}" SIMULATIONIO_API_DEFAULT_CLIENT_ADDRESS = f"{CLIENT_OCTET}:{SIMULATIONIO_PORT}" +DEFAULT_LINKSTATE_TYPE = ":memory:" # Constants for ping PING_DEFAULT_INTERVAL = 30 diff --git a/src/py/flwr/server/app.py b/src/py/flwr/server/app.py index 079e4b8af80d..7dff1eb3dad5 100644 --- a/src/py/flwr/server/app.py +++ b/src/py/flwr/server/app.py @@ -42,6 +42,7 @@ from flwr.common.constant import ( AUTH_TYPE_KEY, CLIENT_OCTET, + DEFAULT_LINKSTATE_TYPE, EXEC_API_DEFAULT_SERVER_ADDRESS, FLEET_API_GRPC_BIDI_DEFAULT_ADDRESS, FLEET_API_GRPC_RERE_DEFAULT_ADDRESS, @@ -85,7 +86,6 @@ from .superlink.linkstate import LinkStateFactory from .superlink.simulation.simulationio_grpc import run_simulationio_api_grpc -DATABASE = ":flwr-in-memory-state:" BASE_DIR = get_flwr_dir() / "superlink" / "ffs" @@ -758,12 +758,11 @@ def _add_args_common(parser: argparse.ArgumentParser) -> None: ) parser.add_argument( "--database", - help="A string representing the path to the database " - "file that will be opened. Note that passing ':memory:' " - "will open a connection to a database that is in RAM, " - "instead of on disk. If nothing is provided, " - "Flower will just create a state in memory.", - default=DATABASE, + help="LinkState implementation. A string representing the path to the database " + "file that will be opened. If nothing is provided, Flower will create an " + 'in-memory SQLite database. Pass ":flwr-in-memory-state:" to configure an ' + "in-memory dictionary-based LinkState instead.", + default=DEFAULT_LINKSTATE_TYPE, ) parser.add_argument( "--storage-dir", diff --git a/src/py/flwr/server/superlink/linkstate/linkstate_factory.py b/src/py/flwr/server/superlink/linkstate/linkstate_factory.py index 403b9bf5b4cc..5cd0a7688ab0 100644 --- a/src/py/flwr/server/superlink/linkstate/linkstate_factory.py +++ b/src/py/flwr/server/superlink/linkstate/linkstate_factory.py @@ -47,11 +47,11 @@ def state(self) -> LinkState: if self.database == ":flwr-in-memory-state:": if self.state_instance is None: self.state_instance = InMemoryLinkState() - log(DEBUG, "Using InMemoryState") + log(DEBUG, "Using InMemoryLinkState") return self.state_instance # SqliteState state = SqliteLinkState(self.database) state.initialize() - log(DEBUG, "Using SqliteState") + log(DEBUG, "Using SqliteLinkState (%s)", self.database) return state