Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 86281ca
Author: Auguste Baum <[email protected]>
Date:   Wed Jan 8 12:00:46 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/tests/integration/ui/test_ui.py

commit 9f6f193
Author: Thomas S <[email protected]>
Date:   Wed Jan 8 11:52:12 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/tests/integration/ui/test_ui.py

commit cd385f6
Author: Auguste Baum <[email protected]>
Date:   Wed Jan 8 11:41:10 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/src/skore/persistence/item/sklearn_base_estimator_item.py

commit 41c5355
Author: Thomas S <[email protected]>
Date:   Wed Jan 8 11:27:16 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/tests/integration/sklearn/test_cross_validate.py

commit a7d956e
Author: Auguste Baum <[email protected]>
Date:   Wed Jan 8 11:14:59 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/tests/unit/view/test_view_repository.py

commit 38446cf
Author: Thomas S <[email protected]>
Date:   Wed Jan 8 11:01:43 2025 +0100

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:skore/src/skore/persistence/item/pickle_item.py

commit a6e2a79
Author: Thomas S <[email protected]>
Date:   Wed Jan 8 10:51:07 2025 +0100

    mob start [ci-skip] [ci skip] [skip ci]

# automatically added all co-authors from WIP commits
# add missing co-authors manually
Co-authored-by: Auguste Baum <[email protected]>
  • Loading branch information
thomass-dev committed Jan 8, 2025
1 parent f4552e9 commit 83747f7
Show file tree
Hide file tree
Showing 37 changed files with 142 additions and 100 deletions.
5 changes: 1 addition & 4 deletions skore/src/skore/persistence/item/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from contextlib import suppress
from typing import Any

import skrub_table_report_item as SkrubTableReportItem

from . import skrub_table_report_item as SkrubTableReportItem
from .cross_validation_item import CrossValidationItem
from .item import Item, ItemTypeError
from .item_repository import ItemRepository
from .media_item import MediaItem
from .numpy_array_item import NumpyArrayItem
from .pandas_dataframe_item import PandasDataFrameItem
Expand Down Expand Up @@ -72,7 +70,6 @@ def item_to_object(item: Item) -> Any:
__all__ = [
"CrossValidationItem",
"Item",
"ItemRepository",
"MediaItem",
"NumpyArrayItem",
"PandasDataFrameItem",
Expand Down
3 changes: 2 additions & 1 deletion skore/src/skore/persistence/item/cross_validation_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import plotly.graph_objects
import plotly.io

from skore.item.item import Item, ItemTypeError
from skore.sklearn.cross_validation import CrossValidationReporter

from .item import Item, ItemTypeError

if TYPE_CHECKING:
import sklearn.base

Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from io import BytesIO
from typing import TYPE_CHECKING, Any

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
from altair.vegalite.v5.schema.core import TopLevelSpec as Altair
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/numpy_array_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from json import dumps, loads
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import numpy
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/pandas_dataframe_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import pandas
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/pandas_series_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import pandas
Expand Down
4 changes: 3 additions & 1 deletion skore/src/skore/persistence/item/pickle_item.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

from functools import cached_property
from pickle import dumps, loads
from typing import Any

from skore.item.item import Item
from .item import Item


class PickleItem(Item):
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/polars_dataframe_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import polars
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/polars_series_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import polars
Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/persistence/item/primitive_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
from typing import Union
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from skore.item.item import Item, ItemTypeError
from .item import Item, ItemTypeError

if TYPE_CHECKING:
import sklearn.base
Expand Down Expand Up @@ -101,11 +101,14 @@ def factory(cls, estimator: sklearn.base.BaseEstimator) -> SklearnBaseEstimatorI
"""
import sklearn.base
import sklearn.utils
import skops.io

if not isinstance(estimator, sklearn.base.BaseEstimator):
raise ItemTypeError(f"Type '{estimator.__class__}' is not supported.")

# This line is only needed if we know `estimator` has the right type, so we do
# it after the type check
import skops.io

estimator_html_repr = sklearn.utils.estimator_html_repr(estimator)
estimator_skops = skops.io.dumps(estimator)
estimator_skops_untrusted_types = skops.io.get_untrusted_types(
Expand Down
4 changes: 2 additions & 2 deletions skore/src/skore/persistence/item/skrub_table_report_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from typing import TYPE_CHECKING

from skore.item.item import ItemTypeError
from skore.item.media_item import MediaItem
from .item import ItemTypeError
from .media_item import MediaItem

if TYPE_CHECKING:
from skrub import TableReport
Expand Down
7 changes: 7 additions & 0 deletions skore/src/skore/persistence/repository/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .item_repository import ItemRepository
from .view_repository import ViewRepository

__all__ = [
"ItemRepository",
"ViewRepository",
]
27 changes: 14 additions & 13 deletions skore/src/skore/persistence/repository/item_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@

from typing import TYPE_CHECKING

from skore.persistence.item import (
CrossValidationItem,
MediaItem,
NumpyArrayItem,
PandasDataFrameItem,
PandasSeriesItem,
PolarsDataFrameItem,
PolarsSeriesItem,
PrimitiveItem,
SklearnBaseEstimatorItem,
)

if TYPE_CHECKING:
from skore.item.item import Item
from skore.persistence.abstract_storage import AbstractStorage


from skore.item.cross_validation_item import CrossValidationItem
from skore.item.media_item import MediaItem
from skore.item.numpy_array_item import NumpyArrayItem
from skore.item.pandas_dataframe_item import PandasDataFrameItem
from skore.item.pandas_series_item import PandasSeriesItem
from skore.item.polars_dataframe_item import PolarsDataFrameItem
from skore.item.polars_series_item import PolarsSeriesItem
from skore.item.primitive_item import PrimitiveItem
from skore.item.sklearn_base_estimator_item import SklearnBaseEstimatorItem
from skore.persistence.item import Item
from skore.persistence.storage import AbstractStorage


class ItemRepository:
Expand Down
9 changes: 9 additions & 0 deletions skore/src/skore/persistence/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .abstract_storage import AbstractStorage
from .disk_cache_storage import DiskCacheStorage
from .in_memory_storage import InMemoryStorage

__all__ = [
"AbstractStorage",
"DiskCacheStorage",
"InMemoryStorage",
]
2 changes: 1 addition & 1 deletion skore/src/skore/project/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
ProjectCreationError,
ProjectPermissionError,
)
from skore.persistence.view.view import View
from skore.project.load import load
from skore.project.project import Project, logger
from skore.utils._logger import logger_context
from skore.view.view import View


def _validate_project_name(project_name: str) -> tuple[bool, Optional[Exception]]:
Expand Down
8 changes: 5 additions & 3 deletions skore/src/skore/project/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from pathlib import Path
from typing import Union

from skore.item import ItemRepository
from skore.persistence.disk_cache_storage import DirectoryDoesNotExist, DiskCacheStorage
from skore.persistence.repository import ItemRepository, ViewRepository
from skore.persistence.storage.disk_cache_storage import (
DirectoryDoesNotExist,
DiskCacheStorage,
)
from skore.project.project import Project
from skore.view.view_repository import ViewRepository


class ProjectLoadError(Exception):
Expand Down
7 changes: 6 additions & 1 deletion skore/src/skore/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any, Optional, Union

from skore.persistence import item_to_object, object_to_item
from skore.persistence.item import item_to_object, object_to_item

if TYPE_CHECKING:
from skore.persistence import (
Expand All @@ -15,6 +16,10 @@
)


logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler()) # Default to no output
logger.setLevel(logging.INFO)

MISSING = object()


Expand Down
4 changes: 2 additions & 2 deletions skore/src/skore/ui/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from fastapi import APIRouter, HTTPException, Request, status

from skore.item import Item
from skore.persistence.item import Item
from skore.persistence.view.view import Layout, View
from skore.project import Project
from skore.view.view import Layout, View

router = APIRouter(prefix="/project")

Expand Down
5 changes: 2 additions & 3 deletions skore/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from datetime import datetime, timezone

import pytest
from skore.item.item_repository import ItemRepository
from skore.persistence.in_memory_storage import InMemoryStorage
from skore.persistence.repository import ItemRepository, ViewRepository
from skore.persistence.storage import InMemoryStorage
from skore.project import Project
from skore.view.view_repository import ViewRepository


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions skore/tests/integration/sklearn/test_cross_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sklearn.multiclass import OneVsOneClassifier
from sklearn.svm import SVC
from skore import CrossValidationReporter
from skore.item.cross_validation_item import CrossValidationItem
from skore.persistence.item.cross_validation_item import CrossValidationItem
from skore.sklearn.cross_validation.cross_validation_helpers import _get_scorers_to_add


Expand Down Expand Up @@ -200,7 +200,7 @@ def test_cross_validation_reporter(in_memory_project, fixture_name, request):

in_memory_project.put("cross-validation", reporter)

retrieved_item = in_memory_project.get_item("cross-validation")
retrieved_item = in_memory_project.item_repository.get_item("cross-validation")
assert isinstance(retrieved_item, CrossValidationItem)


Expand Down
Loading

0 comments on commit 83747f7

Please sign in to comment.