diff --git a/fedn/network/api/interface.py b/fedn/network/api/interface.py index d81af66bf..3ffaadecf 100644 --- a/fedn/network/api/interface.py +++ b/fedn/network/api/interface.py @@ -512,7 +512,7 @@ def add_combiner(self, combiner_id, secure_grpc, address, remote_addr, fqdn, por return jsonify(payload) - def add_client(self, client_id, preferred_combiner, remote_addr, name, package="remote"): + def add_client(self, client_id, preferred_combiner, remote_addr, name, package): """Add a client to the network. :param client_id: The client id to add. @@ -522,6 +522,10 @@ 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: @@ -535,7 +539,9 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package=" ), 203, ) - elif package == "local" and FEDN_ALLOW_LOCAL_PACKAGE is False: + 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( { @@ -545,8 +551,8 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package=" ), 400, ) - elif package == "local" and FEDN_ALLOW_LOCAL_PACKAGE: - pass + elif package == "local" and local_package is True: + helper_type = "" # Assign client to combiner if preferred_combiner: @@ -587,7 +593,7 @@ def add_client(self, client_id, preferred_combiner, remote_addr, name, package=" "package": package, "ip": combiner.ip, "port": combiner.port, - "helper_type": self.control.statestore.get_helper(), + "helper_type": helper_type, } return jsonify(payload) diff --git a/fedn/network/api/server.py b/fedn/network/api/server.py index d56c3ab0b..d2b3c82b8 100644 --- a/fedn/network/api/server.py +++ b/fedn/network/api/server.py @@ -591,9 +591,11 @@ def add_client(): remote_addr = request.remote_addr try: response = api.add_client(**json_data, remote_addr=remote_addr) - except TypeError: + except TypeError as e: + print(e) return jsonify({"success": False, "message": "Invalid data provided"}), 400 - except Exception: + except Exception as e: + print(e) return jsonify({"success": False, "message": "An unexpected error occurred"}), 500 return response