Skip to content

Commit

Permalink
typing changes for statuses and validations
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Feb 15, 2024
1 parent 00ff7c0 commit 24b254f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion fedn/fedn/network/api/v1/session_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_sessions():
@bp.route("/<string:id>", methods=["GET"])
def get_session(id: str):
try:
session = session_repository.get(id)
session = session_repository.get(id, use_typing=True)
response = session.__dict__

return jsonify(response), 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Status:
def __init__(self, id: str, status: str, timestamp: str, log_level: str, data: str, correlation_id: str, type: str, extra: str, sender: dict = None):
def __init__(self, id: str, status: str, timestamp: str, log_level: str, data: str, correlation_id: str, type: str, extra: str, session_id: str, sender: dict = None):
self.id = id
self.status = status
self.timestamp = timestamp
Expand All @@ -16,14 +16,10 @@ def __init__(self, id: str, status: str, timestamp: str, log_level: str, data: s
self.correlation_id = correlation_id
self.type = type
self.extra = extra
self.session_id = session_id
self.sender = sender

def from_dict(data: dict) -> 'Status':
sender = None
if 'sender' in data:
if 'role' in data['sender'] and 'name' in data['sender']:
sender = data['sender']

return Status(
id=str(data['_id']),
status=data['status'] if 'status' in data else None,
Expand All @@ -33,7 +29,8 @@ def from_dict(data: dict) -> 'Status':
correlation_id=data['correlationId'] if 'correlationId' in data else None,
type=data['type'] if 'type' in data else None,
extra=data['extra'] if 'extra' in data else None,
sender=sender
session_id=data['sessionId'] if 'sessionId' in data else None,
sender=data['sender'] if 'sender' in data else None
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ def __init__(self, id: str, model_id: str, data: str, correlation_id: str, times
self.timestamp = timestamp
self.session_id = session_id
self.meta = meta
self.sender = sender
self.receiver = receiver

def from_dict(data: dict) -> 'Validation':
sender = None
if 'sender' in data:
if 'role' in data['sender'] and 'name' in data['sender']:
sender = data['sender']

receiver = None
if 'receiver' in data:
if 'role' in data['receiver'] and 'name' in data['receiver']:
receiver = data['receiver']

return Validation(
id=str(data['_id']),
model_id=data['modelId'] if 'modelId' in data else None,
Expand All @@ -35,8 +27,8 @@ def from_dict(data: dict) -> 'Validation':
timestamp=data['timestamp'] if 'timestamp' in data else None,
session_id=data['sessionId'] if 'sessionId' in data else None,
meta=data['meta'] if 'meta' in data else None,
sender=sender,
receiver=receiver
sender=data['sender'] if 'sender' in data else None,
receiver=data['receiver'] if 'receiver' in data else None
)


Expand Down

0 comments on commit 24b254f

Please sign in to comment.