Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/SK-544 | Server side changes for c++ client #534

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to support both versions of the message? Why not just introduce the new config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of backward compability

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
Loading