diff --git a/examples/load-test/client/model.py b/examples/load-test/client/model.py index 4d6b89a3..6f61069c 100644 --- a/examples/load-test/client/model.py +++ b/examples/load-test/client/model.py @@ -1,12 +1,10 @@ # /bin/python -import sys -import time import numpy as np -from fedn.utils.helpers.helpers import get_helper, save_metadata, save_metrics +from fedn.utils.helpers.helpers import get_helper -HELPER_MODULE = 'numpyhelper' +HELPER_MODULE = "numpyhelper" ARRAY_SIZE = 20000000 @@ -35,7 +33,7 @@ def load_model(model_path): return weights -def init_seed(out_path='seed.npz'): +def init_seed(out_path="seed.npz"): """ Initialize seed model. :param out_path: The path to save the seed model to. diff --git a/examples/load-test/client/train.py b/examples/load-test/client/train.py index 5bfe38ed..bfd5f00b 100644 --- a/examples/load-test/client/train.py +++ b/examples/load-test/client/train.py @@ -5,9 +5,9 @@ import numpy as np from model import load_model, save_model -from fedn.utils.helpers.helpers import get_helper, save_metadata, save_metrics +from fedn.utils.helpers.helpers import save_metadata -HELPER_MODULE = 'numpyhelper' +HELPER_MODULE = "numpyhelper" ARRAY_SIZE = 10000 @@ -15,7 +15,6 @@ def train(in_model_path, out_model_path): """ Train model. """ - # Load model weights = load_model(in_model_path) @@ -24,7 +23,7 @@ def train(in_model_path, out_model_path): # Metadata needed for aggregation server side metadata = { - 'num_examples': ARRAY_SIZE, + "num_examples": ARRAY_SIZE, } # Save JSON metadata file diff --git a/examples/load-test/client/validate.py b/examples/load-test/client/validate.py index c79a0d16..8d710b54 100644 --- a/examples/load-test/client/validate.py +++ b/examples/load-test/client/validate.py @@ -1,13 +1,12 @@ # /bin/python import sys -import time import numpy as np -from model import load_model, save_model +from model import load_model -from fedn.utils.helpers.helpers import get_helper, save_metadata, save_metrics +from fedn.utils.helpers.helpers import save_metrics -HELPER_MODULE = 'numpyhelper' +HELPER_MODULE = "numpyhelper" ARRAY_SIZE = 1000000 diff --git a/fedn/network/combiner/aggregators/fedavg.py b/fedn/network/combiner/aggregators/fedavg.py index d3e1c513..7734a705 100644 --- a/fedn/network/combiner/aggregators/fedavg.py +++ b/fedn/network/combiner/aggregators/fedavg.py @@ -58,7 +58,7 @@ def combine_models(self, helper=None, delete_models=True, parameters=None): tic = time.time() model_next, metadata = self.update_handler.load_model_update( model_update, helper) - data['time_model_load'] += time.time()-tic + data["time_model_load"] += time.time()-tic logger.info("AGGREGATOR({}): Processing model update {}, metadata: {} ".format( self.name, model_update.model_update_id, metadata)) @@ -72,7 +72,7 @@ def combine_models(self, helper=None, delete_models=True, parameters=None): else: model = helper.increment_average( model, model_next, metadata["num_examples"], total_examples) - data['time_model_aggregation'] += time.time()-tic + data["time_model_aggregation"] += time.time()-tic nr_aggregated_models += 1 # Delete model from storage diff --git a/fedn/network/combiner/aggregators/fedopt.py b/fedn/network/combiner/aggregators/fedopt.py index 2c1ca698..6ed62e07 100644 --- a/fedn/network/combiner/aggregators/fedopt.py +++ b/fedn/network/combiner/aggregators/fedopt.py @@ -111,7 +111,7 @@ def combine_models(self, helper=None, delete_models=True, parameters=None): tic = time.time() model_next, metadata = self.update_handler.load_model_update( model_update, helper) - data['time_model_load'] += time.time()-tic + data["time_model_load"] += time.time()-tic logger.info("AGGREGATOR({}): Processing model update {}".format( self.name, model_update.model_update_id)) @@ -129,7 +129,7 @@ def combine_models(self, helper=None, delete_models=True, parameters=None): model_next, model_old) pseudo_gradient = helper.increment_average( pseudo_gradient, pseudo_gradient_next, metadata["num_examples"], total_examples) - data['time_model_aggregation'] += time.time()-tic + data["time_model_aggregation"] += time.time()-tic nr_aggregated_models += 1 # Delete model from storage