From 7b581d4aad4e14f305f17ebad8d491dcebe496b7 Mon Sep 17 00:00:00 2001 From: Andreas Hellander Date: Mon, 4 Dec 2023 15:56:29 +0100 Subject: [PATCH] Fix code scanning errors --- fedn/fedn/common/net/grpc/server.py | 4 +-- .../storage/models/memorymodelstorage.py | 16 ---------- .../common/storage/models/tempmodelstorage.py | 29 +------------------ fedn/fedn/common/storage/s3/miniorepo.py | 1 - 4 files changed, 2 insertions(+), 48 deletions(-) diff --git a/fedn/fedn/common/net/grpc/server.py b/fedn/fedn/common/net/grpc/server.py index db4e68c5a..03acb9610 100644 --- a/fedn/fedn/common/net/grpc/server.py +++ b/fedn/fedn/common/net/grpc/server.py @@ -6,9 +6,7 @@ class Server: - """ - - """ + """ Class for configuring and launching the gRPC server.""" def __init__(self, servicer, modelservicer, config): diff --git a/fedn/fedn/common/storage/models/memorymodelstorage.py b/fedn/fedn/common/storage/models/memorymodelstorage.py index 84cca4b3f..4f9bdfd83 100644 --- a/fedn/fedn/common/storage/models/memorymodelstorage.py +++ b/fedn/fedn/common/storage/models/memorymodelstorage.py @@ -20,21 +20,13 @@ def __init__(self): self.models_metadata = {} def exist(self, model_id): - """ - :param model_id: - :return: - """ if model_id in self.models.keys(): return True return False def get(self, model_id): - """ - :param model_id: - :return: - """ obj = self.models[model_id] obj.seek(0, 0) # Have to copy object to not mix up the file pointers when sending... fix in better way. @@ -50,17 +42,9 @@ def get_ptr(self, model_id): return self.models[model_id] def get_meta(self, model_id): - """ - :param model_id: - :return: - """ return self.models_metadata[model_id] def set_meta(self, model_id, model_metadata): - """ - :param model_id: - :param model_metadata: - """ self.models_metadata.update({model_id: model_metadata}) diff --git a/fedn/fedn/common/storage/models/tempmodelstorage.py b/fedn/fedn/common/storage/models/tempmodelstorage.py index 0fc76ab44..295f23278 100644 --- a/fedn/fedn/common/storage/models/tempmodelstorage.py +++ b/fedn/fedn/common/storage/models/tempmodelstorage.py @@ -10,7 +10,7 @@ class TempModelStorage(ModelStorage): """ Class for model storage using temporary files on local disk. - Models are stored as files on disk. + Models are stored as files on disk. """ @@ -26,22 +26,13 @@ def __init__(self): self.models_metadata = {} def exist(self, model_id): - """ - :param model_id: - :type model_id: str - :return: True if exists in storage, otherwise False. - """ if model_id in self.models.keys(): return True return False def get(self, model_id): - """ - :param model_id: - :return: - """ try: if self.models_metadata[model_id] != fedn.ModelStatus.OK: print("File not ready! Try again", flush=True) @@ -72,30 +63,16 @@ def get_ptr(self, model_id): return self.models[model_id]['file'] def get_meta(self, model_id): - """ - :param model_id: - :return: - """ return self.models_metadata[model_id] def set_meta(self, model_id, model_metadata): - """ - :param model_id: - :param model_metadata: - """ self.models_metadata.update({model_id: model_metadata}) # Delete model from disk def delete(self, model_id): - """ Delete model from temp disk/storage - :param model_id: model id - :type model_id: str - :return: True if successful, False otherwise - :rtype: bool - """ try: os.remove(os.path.join(self.default_dir, str(model_id))) print("TEMPMODELSTORAGE: Deleted model with id: {}".format(model_id), flush=True) @@ -109,11 +86,7 @@ def delete(self, model_id): # Delete all models from disk def delete_all(self): - """ Delete all models from temp disk/storage - :return: True if successful, False otherwise - :rtype: bool - """ ids_pop = [] for model_id in self.models.keys(): try: diff --git a/fedn/fedn/common/storage/s3/miniorepo.py b/fedn/fedn/common/storage/s3/miniorepo.py index fcc9491d3..40675416d 100644 --- a/fedn/fedn/common/storage/s3/miniorepo.py +++ b/fedn/fedn/common/storage/s3/miniorepo.py @@ -1,5 +1,4 @@ import io -import logging from minio import Minio from minio.error import InvalidResponseError