Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Hide view functions from project #1013

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion skore/src/skore/project/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def create(
) from e

p = load(project_directory)
p.put_view("default", View(layout=[]))
p._put_view("default", View(layout=[]))

logger.info(f"Project file '{project_directory}' was successfully created.")
return p
8 changes: 4 additions & 4 deletions skore/src/skore/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ def delete_item(self, key: str):
"""
self.item_repository.delete_item(key)

def put_view(self, key: str, view: View):
def _put_view(self, key: str, view: View):
"""Add a view to the Project."""
self.view_repository.put_view(key, view)

def get_view(self, key: str) -> View:
def _get_view(self, key: str) -> View:
"""Get the view corresponding to ``key`` from the Project.

Parameters
Expand All @@ -276,7 +276,7 @@ def get_view(self, key: str) -> View:
"""
return self.view_repository.get_view(key)

def delete_view(self, key: str):
def _delete_view(self, key: str):
"""Delete the view corresponding to ``key`` from the Project.

Parameters
Expand All @@ -291,7 +291,7 @@ def delete_view(self, key: str):
"""
return self.view_repository.delete_view(key)

def list_view_keys(self) -> list[str]:
def _list_view_keys(self) -> list[str]:
"""List all view keys in the Project.

Returns
Expand Down
6 changes: 3 additions & 3 deletions skore/src/skore/ui/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __project_as_serializable(project: Project) -> SerializableProject:
for key in project.list_item_keys()
}

views = {key: project.get_view(key).layout for key in project.list_view_keys()}
views = {key: project._get_view(key).layout for key in project._list_view_keys()}

return SerializableProject(
items=items,
Expand All @@ -78,7 +78,7 @@ async def put_view(request: Request, key: str, layout: Layout):
project: Project = request.app.state.project

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

return __project_as_serializable(project)

Expand All @@ -89,7 +89,7 @@ async def delete_view(request: Request, key: str):
project: Project = request.app.state.project

try:
project.delete_view(key)
project._delete_view(key)
except KeyError:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="View not found"
Expand Down
2 changes: 1 addition & 1 deletion skore/tests/integration/ui/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_put_view_layout(client):


def test_delete_view(client, in_memory_project):
in_memory_project.put_view("hello", View(layout=[]))
in_memory_project._put_view("hello", View(layout=[]))
response = client.delete("/api/project/views?key=hello")
assert response.status_code == 202

Expand Down
8 changes: 4 additions & 4 deletions skore/tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ def test_view(in_memory_project):

view = View(layout=layout)

in_memory_project.put_view("view", view)
assert in_memory_project.get_view("view") == view
in_memory_project._put_view("view", view)
assert in_memory_project._get_view("view") == view


def test_list_view_keys(in_memory_project):
view = View(layout=[])

in_memory_project.put_view("view", view)
assert in_memory_project.list_view_keys() == ["view"]
in_memory_project._put_view("view", view)
assert in_memory_project._list_view_keys() == ["view"]


def test_put_several_happy_path(in_memory_project):
Expand Down
Loading