diff --git a/fedn/fedn/common/tracer/mongotracer.py b/fedn/fedn/common/tracer/mongotracer.py index 57cfd07c8..8d53f60b4 100644 --- a/fedn/fedn/common/tracer/mongotracer.py +++ b/fedn/fedn/common/tracer/mongotracer.py @@ -50,15 +50,25 @@ def drop_status(self): if self.status: self.status.drop() - def new_session(self, id=None): - """ Create a new session. """ + def create_session(self, id=None): + """ Create a new session. + + :param id: The ID of the created session. + :type id: uuid, str + + """ if not id: id = uuid.uuid4() data = {'session_id': str(id)} self.sessions.insert_one(data) - def new_round(self, round_data): - """ Create a new session. """ + def create_round(self, round_data): + """ Create a new round. + + :param round_data: Dictionary with round data. + :type round_data: dict + """ + # TODO: Add check if round_id already exists self.rounds.insert_one(round_data) def set_session_config(self, id, config): @@ -68,7 +78,8 @@ def set_session_config(self, id, config): def set_round_combiner_data(self, data): """ - :param round_meta: + :param data: The combiner data + :type data: dict """ self.rounds.update_one({'round_id': str(data['round_id'])}, { '$push': {'combiners': data}}, True) diff --git a/fedn/fedn/network/controller/control.py b/fedn/fedn/network/controller/control.py index 88b95f44a..3bc16b114 100644 --- a/fedn/fedn/network/controller/control.py +++ b/fedn/fedn/network/controller/control.py @@ -99,7 +99,7 @@ def session(self, config): self._state = ReducerState.instructing # Must be called to set info in the db config['committed_at'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - self.new_session(config) + self.create_session(config) if not self.statestore.get_latest_model(): print("No model in model chain, please provide a seed model!", flush=True) @@ -140,7 +140,7 @@ def round(self, session_config, round_id): """ - self.new_round({'round_id': round_id, 'status': "Pending"}) + self.create_round({'round_id': round_id, 'status': "Pending"}) if len(self.network.get_combiners()) < 1: print("CONTROLLER: Round cannot start, no combiners connected!", flush=True) diff --git a/fedn/fedn/network/controller/controlbase.py b/fedn/fedn/network/controller/controlbase.py index aa6b1c456..b58952837 100644 --- a/fedn/fedn/network/controller/controlbase.py +++ b/fedn/fedn/network/controller/controlbase.py @@ -180,7 +180,7 @@ def get_compute_package(self, compute_package=''): else: return None - def new_session(self, config): + def create_session(self, config): """ Initialize a new session in backend db. """ if "session_id" not in config.keys(): @@ -189,13 +189,13 @@ def new_session(self, config): else: session_id = config['session_id'] - self.tracer.new_session(id=session_id) + self.tracer.create_session(id=session_id) self.tracer.set_session_config(session_id, config) - def new_round(self, round_data): + def create_round(self, round_data): """Initialize a new round in backend db. """ - self.tracer.new_round(round_data) + self.tracer.create_round(round_data) def set_round_data(self, round_id, round_data): """ Upate round in backend db. """