Skip to content

Commit

Permalink
statuses added
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Dec 20, 2024
1 parent a29f0a1 commit 750cf3a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Empty file.
44 changes: 43 additions & 1 deletion fedn/network/api/v1/graphql/schema.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import graphene
import pymongo

from fedn.network.api.v1.shared import model_store, session_store, validation_store
from fedn.network.api.v1.shared import model_store, session_store, status_store, validation_store


class ActorType(graphene.ObjectType):
name = graphene.String()
role = graphene.String()


class StatusType(graphene.ObjectType):
data = graphene.String()
extra = graphene.String()
id = graphene.String()
logLevel = graphene.String() # noqa: N815
sender = graphene.Field(ActorType)
sessionId = graphene.String() # noqa: N815
status = graphene.String()
timestamp = graphene.String()
type = graphene.String()


class ValidationType(graphene.ObjectType):
correlationId = graphene.String() # noqa: N815
data = graphene.String()
Expand Down Expand Up @@ -65,6 +77,7 @@ class SessionType(graphene.ObjectType):
session_config = graphene.Field(SessionConfigType)
model = graphene.List(ModelType)
validation = graphene.List(ValidationType)
status = graphene.List(StatusType)

def resolve_session_config(self, info):
return self["session_config"]
Expand All @@ -83,6 +96,13 @@ def resolve_validation(self, info):

return result

def resolve_status(self, info):
kwargs = {"sessionId": self["session_id"]}
response = status_store.list(0, 0, None, sort_order=pymongo.DESCENDING, use_typing=False, **kwargs)
result = response["result"]

return result


class Query(graphene.ObjectType):
session = graphene.List(
Expand All @@ -103,6 +123,12 @@ class Query(graphene.ObjectType):
session_id=graphene.String(),
)

status = graphene.List(
StatusType,
id=graphene.String(),
session_id=graphene.String(),
)

def resolve_session(root, info, id: str = None, name: str = None):
result = None
if id:
Expand Down Expand Up @@ -151,5 +177,21 @@ def resolve_validation(root, info, id: str = None, session_id: str = None):

return result

def resolve_status(root, info, id: str = None, session_id: str = None):
result = None
if id:
response = status_store.get(id)
result = []
result.append(response)
elif session_id:
kwargs = {"sessionId": session_id}
response = status_store.list(0, 0, None, sort_order=pymongo.DESCENDING, use_typing=False, **kwargs)
result = response["result"]
else:
response = status_store.list(0, 0, None)
result = response["result"]

return result


schema = graphene.Schema(query=Query)

0 comments on commit 750cf3a

Please sign in to comment.