Skip to content

Commit

Permalink
Fix code scanning errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hellander committed Dec 4, 2023
1 parent 53745cb commit 7b581d4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 48 deletions.
4 changes: 1 addition & 3 deletions fedn/fedn/common/net/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@


class Server:
"""
"""
""" Class for configuring and launching the gRPC server."""

def __init__(self, servicer, modelservicer, config):

Expand Down
16 changes: 0 additions & 16 deletions fedn/fedn/common/storage/models/memorymodelstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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})
29 changes: 1 addition & 28 deletions fedn/fedn/common/storage/models/tempmodelstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion fedn/fedn/common/storage/s3/miniorepo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io
import logging

from minio import Minio
from minio.error import InvalidResponseError
Expand Down

0 comments on commit 7b581d4

Please sign in to comment.