Skip to content

Commit

Permalink
Updates after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hellander committed Oct 30, 2023
1 parent 26fe052 commit 06cd806
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
21 changes: 16 additions & 5 deletions fedn/fedn/common/tracer/mongotracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions fedn/fedn/network/controller/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions fedn/fedn/network/controller/controlbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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. """
Expand Down

0 comments on commit 06cd806

Please sign in to comment.