Skip to content

Commit

Permalink
list models update
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Oct 18, 2023
1 parent a064506 commit 7b525e8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions fedn/fedn/network/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,22 +632,30 @@ def get_latest_model(self):
)

def get_models(self, session_id=None, limit=None, skip=None):
result = self.statestore.list_models(session_id, limit, skip)
models_object = self.statestore.list_models(session_id, limit, skip)

if result is None:
if models_object is None:
return (
jsonify({"success": False, "message": "No models found."}),
404,
)

json_docs = []
for doc in result["result"]:
json_doc = json.dumps(doc, default=json_util.default)
json_docs.append(json_doc)
payload = {}
for object in models_object["result"]:
model = object["model"]
session_id = object["session_id"]
commited_at = object["commited_at"]

obj = {
"session_id": session_id,
"commited_at": commited_at,
"model": model,
}
payload[model] = obj

json_docs.reverse()
result = {"result": payload, "count": models_object["count"]}

return jsonify({"result": json_docs, "count": result["count"]})
return jsonify(result)

def get_model_trail(self):
"""Get the model trail for a given session.
Expand Down

0 comments on commit 7b525e8

Please sign in to comment.