From 2880e51d2c2bcd9760b936f23c6369249e4e3244 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 17 Nov 2023 11:54:01 +0100 Subject: [PATCH 1/2] if session id is None or empty guid should be generated --- fedn/fedn/network/api/client.py | 5 ----- fedn/fedn/network/controller/controlbase.py | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/fedn/fedn/network/api/client.py b/fedn/fedn/network/api/client.py index 0e0a48a52..58fc27304 100644 --- a/fedn/fedn/network/api/client.py +++ b/fedn/fedn/network/api/client.py @@ -1,5 +1,3 @@ -import uuid - import requests __all__ = ['APIClient'] @@ -137,9 +135,6 @@ def start_session(self, session_id=None, round_timeout=180, rounds=5, round_buff :return: A dict with success or failure message and session config. :rtype: dict """ - # If session id is None, generate a random session id. - if session_id is None: - session_id = str(uuid.uuid4()) response = requests.post(self._get_url('start_session'), json={ 'session_id': session_id, 'round_timeout': round_timeout, diff --git a/fedn/fedn/network/controller/controlbase.py b/fedn/fedn/network/controller/controlbase.py index fab6a2027..08766b69b 100644 --- a/fedn/fedn/network/controller/controlbase.py +++ b/fedn/fedn/network/controller/controlbase.py @@ -203,7 +203,7 @@ def create_session(self, config): session_id = uuid.uuid4() config["session_id"] = str(session_id) else: - session_id = config["session_id"] + session_id = config["session_id"] if config["session_id"] else uuid.uuid4() self.tracer.create_session(id=session_id) self.tracer.set_session_config(session_id, config) From 19b04feb73cbfac4cec00b4b02deb2fa6e96767f Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 17 Nov 2023 14:08:46 +0100 Subject: [PATCH 2/2] set session_id if empty earlier in start session process. --- fedn/fedn/network/api/interface.py | 3 ++- fedn/fedn/network/controller/controlbase.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fedn/fedn/network/api/interface.py b/fedn/fedn/network/api/interface.py index 0821ed176..e56462493 100644 --- a/fedn/fedn/network/api/interface.py +++ b/fedn/fedn/network/api/interface.py @@ -2,6 +2,7 @@ import copy import os import threading +import uuid from io import BytesIO from flask import jsonify, send_from_directory @@ -863,7 +864,7 @@ def start_session( # Setup session config session_config = { - "session_id": session_id, + "session_id": session_id if session_id else str(uuid.uuid4()), "round_timeout": round_timeout, "buffer_size": round_buffer_size, "model_id": model_id, diff --git a/fedn/fedn/network/controller/controlbase.py b/fedn/fedn/network/controller/controlbase.py index 08766b69b..fab6a2027 100644 --- a/fedn/fedn/network/controller/controlbase.py +++ b/fedn/fedn/network/controller/controlbase.py @@ -203,7 +203,7 @@ def create_session(self, config): session_id = uuid.uuid4() config["session_id"] = str(session_id) else: - session_id = config["session_id"] if config["session_id"] else uuid.uuid4() + session_id = config["session_id"] self.tracer.create_session(id=session_id) self.tracer.set_session_config(session_id, config)