Skip to content

Commit

Permalink
Revert API changes to keep frontend compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
auguste-probabl committed Sep 23, 2024
1 parent cdece0c commit 4375f0e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/skore/ui/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SerializedItem:
class SerializedProject:
"""Serialized project, to be sent to the frontend."""

layout: Layout
views: dict[str, Layout]
items: dict[str, SerializedItem]

Expand Down Expand Up @@ -77,7 +78,16 @@ def __serialize_project(project: Project) -> SerializedProject:
created_at=item.created_at,
)

return SerializedProject(views=views, items=items)
try:
layout = project.get_view("layout").layout
except KeyError:
layout = []

return SerializedProject(
layout=layout,
views=views,
items=items,
)


@router.get("/items")
Expand Down Expand Up @@ -119,12 +129,12 @@ def read_asset_content(filename: str):
)


@router.put("/report/layout/{key:path}", status_code=201)
async def set_view_layout(request: Request, key: str, layout: Layout):
@router.put("/report/layout", status_code=201)
async def set_view_layout(request: Request, layout: Layout):
"""Set the view layout."""
project: Project = request.app.state.project

view = View(layout=layout)
project.put_view(key, view)
project.put_view("layout", view)

return __serialize_project(project)

0 comments on commit 4375f0e

Please sign in to comment.