diff --git a/fedn/common/config.py b/fedn/common/config.py index 517e57d94..ceb2fe65a 100644 --- a/fedn/common/config.py +++ b/fedn/common/config.py @@ -16,7 +16,6 @@ FEDN_CUSTOM_URL_PREFIX = os.environ.get("FEDN_CUSTOM_URL_PREFIX", "") -FEDN_ALLOW_LOCAL_PACKAGE = os.environ.get("FEDN_ALLOW_LOCAL_PACKAGE", False) FEDN_PACKAGE_EXTRACT_DIR = os.environ.get("FEDN_PACKAGE_EXTRACT_DIR", "package") diff --git a/fedn/network/api/interface.py b/fedn/network/api/interface.py index 3ffaadecf..1e31cb5eb 100644 --- a/fedn/network/api/interface.py +++ b/fedn/network/api/interface.py @@ -7,7 +7,7 @@ from werkzeug.security import safe_join from werkzeug.utils import secure_filename -from fedn.common.config import FEDN_ALLOW_LOCAL_PACKAGE, get_controller_config, get_network_config +from fedn.common.config import get_controller_config, get_network_config from fedn.common.log_config import logger from fedn.network.combiner.interfaces import CombinerUnavailableError from fedn.network.state import ReducerState, ReducerStateToString @@ -522,10 +522,6 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package): :return: A json response with combiner assignment config. :rtype: :class:`flask.Response` """ - local_package = FEDN_ALLOW_LOCAL_PACKAGE - if local_package: - local_package = True - if package == "remote": package_object = self.statestore.get_compute_package() if package_object is None: @@ -540,18 +536,8 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package): 203, ) helper_type = self.control.statestore.get_helper() - elif package == "local" and local_package is False: - print("Local package not allowed. Set FEDN_ALLOW_LOCAL_PACKAGE=True in controller config.") - return ( - jsonify( - { - "success": False, - "message": "Local package not allowed. Set FEDN_ALLOW_LOCAL_PACKAGE=True in controller config.", - } - ), - 400, - ) - elif package == "local" and local_package is True: + else: + # Else package is "local": helper_type = "" # Assign client to combiner @@ -582,6 +568,7 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package): "combiner": combiner.name, "ip": remote_addr, "status": "available", + "package": package, } # Add client to network self.control.network.add_client(client_config) diff --git a/fedn/network/storage/statestore/mongostatestore.py b/fedn/network/storage/statestore/mongostatestore.py index 3ef204b5c..3886a3db7 100644 --- a/fedn/network/storage/statestore/mongostatestore.py +++ b/fedn/network/storage/statestore/mongostatestore.py @@ -738,12 +738,22 @@ def set_client(self, client_data): """ client_data["updated_at"] = str(datetime.now()) try: - self.clients.update_one({"client_id": client_data["client_id"]}, {"$set": client_data}, True) + # self.clients.update_one({"client_id": client_data["client_id"]}, {"$set": client_data}, True) + self.clients.update_one( + {"client_id": client_data["client_id"]}, + {"$set": {k: v for k, v in client_data.items() if v is not None}}, + upsert=True + ) except KeyError: # If client_id is not present, use name as identifier, for backwards compatibility id = str(uuid.uuid4()) client_data["client_id"] = id - self.clients.update_one({"name": client_data["name"]}, {"$set": client_data}, True) + # self.clients.update_one({"name": client_data["name"]}, {"$set": client_data}, True) + self.clients.update_one( + {"client_id": client_data["client_id"]}, + {"$set": {k: v for k, v in client_data.items() if v is not None}}, + upsert=True + ) def get_client(self, client_id): """Get client by client_id.