Skip to content

Commit

Permalink
mob next [ci-skip] [ci skip] [skip ci]
Browse files Browse the repository at this point in the history
lastFile:src/skore/api/routes/stores.py
  • Loading branch information
thomass-dev committed Sep 10, 2024
1 parent 5debda4 commit 5b4e4e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/skore/api/routes/stores.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The definition of API routes to list stores and get them."""

import os
import josn
from pathlib import Path
from typing import Any, Iterable

Expand Down Expand Up @@ -128,3 +129,20 @@ async def put_layout(uri: str, payload: Layout):
return serialize_store(store)

raise HTTPException(status_code=404, detail=f"No store found in '{uri}'")


@SKORES_ROUTER.get("/")
async def get_items(uri: str):
directory = None
project = load(directory)
serialized = {}

for key in project.list_keys():
item = project.get_item(key)
serialized[key] = {
"serialized": json.loads(item.serialized),
"raw_class_name": item.raw_class_name,
"media_type": item.media_type,
}

return serialized
9 changes: 6 additions & 3 deletions src/skore/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import base64
import json
from pathlib import Path
from dataclasses import dataclass
from io import StringIO
from typing import Any, List
Expand Down Expand Up @@ -148,6 +149,8 @@ def delete_item(self, key: str):
self.storage.delitem(key)


def load(project_name: str) -> Project:
"""Load a project from a file."""
filepath = get_filepath_from_project_name(project_name)
def load(directory: str | Path) -> Project:
storage = FileSystem(directory=directory)
project = Project(storage=storage)

return project

0 comments on commit 5b4e4e6

Please sign in to comment.