Skip to content

Commit

Permalink
both cpp and py client works
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrede committed Feb 26, 2024
1 parent d5bcfba commit d1cd77f
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 103 deletions.
16 changes: 11 additions & 5 deletions fedn/fedn/network/combiner/aggregators/aggregatorbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ def load_model_update(self, model_update, helper):
model_id = model_update.model_update_id
model = self.round_handler.load_model_update(helper, model_id)
# Get relevant metadata
data = json.loads(model_update.meta)['training_metadata']
config = json.loads(json.loads(model_update.meta)['config'])
data['round_id'] = config['round_id']

return model, data
metadata = json.loads(model_update.meta)
if 'config' in metadata.keys():
# Used in Python client
config = json.loads(metadata['config'])
else:
# Used in C++ client
config = json.loads(model_update.config)
training_metadata = metadata['training_metadata']
training_metadata['round_id'] = config['round_id']

return model, training_metadata

def get_state(self):
""" Get the state of the aggregator's queue, including the number of model updates."""
Expand Down
2 changes: 2 additions & 0 deletions fedn/fedn/network/combiner/aggregators/fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ def combine_models(self, helper=None, delete_models=True):
while not self.model_updates.empty():
try:
# Get next model from queue
logger.info("AGGREGATOR({}): Getting next model update from queue.".format(self.name))
model_update = self.next_model_update()

# Load model parameters and metadata
logger.info("AGGREGATOR({}): Loading model metadata {}.".format(self.name, model_update.model_update_id))
model_next, metadata = self.load_model_update(model_update, helper)

logger.info(
Expand Down
4 changes: 3 additions & 1 deletion fedn/fedn/network/grpc/fedn.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package grpc;
package fedn;

import "google/protobuf/timestamp.proto";

Expand Down Expand Up @@ -49,6 +49,7 @@ message TaskRequest {
Client sender = 1;
Client receiver = 2;
string model_id = 3;
// data is round_config when type is MODEL_UPDATE
string data = 4;
string correlation_id = 5;
string timestamp = 6;
Expand All @@ -65,6 +66,7 @@ message ModelUpdate {
string correlation_id = 5;
string timestamp = 6;
string meta = 7;
string config = 8;
}

message ModelValidation {
Expand Down
Loading

0 comments on commit d1cd77f

Please sign in to comment.