Skip to content

Commit

Permalink
Feature/SK-521 | Global model not created if the combiner terminates …
Browse files Browse the repository at this point in the history
…based on timeout (#478)
  • Loading branch information
ahellander authored Nov 9, 2023
1 parent 1166f31 commit ae06b84
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 159 deletions.
6 changes: 3 additions & 3 deletions .ci/tests/examples/wait_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _retry(try_func, **func_args):
for _ in range(RETRIES):
is_success = try_func(**func_args)
if is_success:
_eprint('Sucess.')
_eprint('Success.')
return True
_eprint(f'Sleeping for {SLEEP}.')
sleep(SLEEP)
Expand All @@ -30,7 +30,7 @@ def _test_rounds(n_rounds):
client = pymongo.MongoClient(
"mongodb://fedn_admin:password@localhost:6534")
collection = client['fedn-network']['control']['rounds']
query = {'reducer.status': 'Success'}
query = {'status': 'Finished'}
n = collection.count_documents(query)
client.close()
_eprint(f'Succeded rounds: {n}.')
Expand Down Expand Up @@ -60,7 +60,7 @@ def _test_nodes(n_nodes, node_type, reducer_host='localhost', reducer_port='8092
return count == n_nodes

except Exception as e:
_eprint(f'Reques exception econuntered: {e}.')
_eprint(f'Request exception enconuntered: {e}.')
return False


Expand Down
2 changes: 1 addition & 1 deletion examples/mnist-keras/bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e
client/entrypoint init_seed

# Make compute package
tar -czvf package.tgz client
tar -czvf package.tgz client
6 changes: 4 additions & 2 deletions fedn/fedn/common/storage/s3/miniorepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def __init__(self, config):
self.create_bucket(self.bucket)

def create_bucket(self, bucket_name):
"""
""" Create a new bucket. If bucket exists, do nothing.
:param bucket_name:
:param bucket_name: The name of the bucket
:type bucket_name: str
"""
found = self.client.bucket_exists(bucket_name)

if not found:
try:
self.client.make_bucket(bucket_name)
Expand Down
45 changes: 35 additions & 10 deletions fedn/fedn/common/tracer/mongotracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,26 @@ 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, id):
""" Create a new session. """
def create_round(self, round_data):
""" Create a new round.
data = {'round_id': str(id)}
self.rounds.insert_one(data)
: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):
self.sessions.update_one({'session_id': str(id)}, {
Expand All @@ -72,18 +80,35 @@ 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)

def set_round_data(self, round_data):
def set_round_config(self, round_id, round_config):
"""
:param round_meta:
"""
self.rounds.update_one({'round_id': round_id}, {
'$set': {'round_config': round_config}}, True)

def set_round_status(self, round_id, round_status):
"""
:param round_meta:
"""
self.rounds.update_one({'round_id': round_id}, {
'$set': {'status': round_status}}, True)

def set_round_data(self, round_id, round_data):
"""
:param round_meta:
"""
self.rounds.update_one({'round_id': str(round_data['round_id'])}, {
'$push': {'reducer': round_data}}, True)
self.rounds.update_one({'round_id': round_id}, {
'$set': {'round_data': round_data}}, True)

def update_client_status(self, client_name, status):
""" Update client status in statestore.
Expand Down
5 changes: 2 additions & 3 deletions fedn/fedn/network/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,8 @@ def get_round(self, round_id):
if round_object is None:
return jsonify({"success": False, "message": "Round not found."})
payload = {
"round_id": round_object["round_id"],
"reducer": round_object["reducer"],
"combiners": round_object["combiners"],
'round_id': round_object['round_id'],
'combiners': round_object['combiners'],
}
return jsonify(payload)

Expand Down
Loading

0 comments on commit ae06b84

Please sign in to comment.