Skip to content

Commit

Permalink
Replace ExceptionGroup with new ProjectPutError
Browse files Browse the repository at this point in the history
  • Loading branch information
auguste-probabl committed Sep 24, 2024
1 parent 5bf8dcb commit b19ccd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies = [
"skops",
"uvicorn",
]
requires-python = ">= 3.11"

[project.optional-dependencies]
test = [
Expand Down
9 changes: 7 additions & 2 deletions src/skore/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
logger = logging.getLogger(__name__)


class ProjectPutError(Exception):
"""One more key-value pairs could not be saved in the Project."""


class Project:
"""A project is a collection of items that are stored in a storage."""

Expand Down Expand Up @@ -94,8 +98,9 @@ def put_several(

if errors:
if on_error == "raise":
raise ExceptionGroup(
"Several items could not be inserted in the Project", errors
raise ProjectPutError(
"Several items could not be inserted in the Project "
f"due to the following errors: {errors}"
)

logger.warning(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from skore.layout import LayoutRepository
from skore.layout.layout import LayoutItem, LayoutItemSize
from skore.persistence.in_memory_storage import InMemoryStorage
from skore.project import Project, ProjectLoadError, load
from skore.project import Project, ProjectLoadError, ProjectPutError, load


@pytest.fixture
Expand Down Expand Up @@ -215,5 +215,5 @@ def test_put_key_is_a_set(project):

def test_put_wrong_key_and_value_raise(project):
"""When `on_error` is "raise", raise."""
with pytest.raises(ExceptionGroup):
with pytest.raises(ProjectPutError):
project.put(0, (lambda: "unsupported object"), on_error="raise")

0 comments on commit b19ccd3

Please sign in to comment.