From dfd860aa45486ceca022180d22f92e9c171ef48b Mon Sep 17 00:00:00 2001 From: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:28:34 -0800 Subject: [PATCH] fix: tests (incremental) Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> --- pyproject.toml | 1 - src/bentoml/_internal/io_descriptors/image.py | 2 -- src/bentoml/_internal/io_descriptors/pandas.py | 10 +--------- tests/unit/_internal/io/test_base.py | 5 ++++- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b342bc001f6..18b251f1d75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,6 @@ dependencies = [ "backports.cached-property;python_version<'3.8'", "backports.shutil_copytree;python_version<'3.8'", "importlib-metadata;python_version<'3.8'", - "singledispatchmethod;python_version<'3.8'", ] dynamic = ["version"] diff --git a/src/bentoml/_internal/io_descriptors/image.py b/src/bentoml/_internal/io_descriptors/image.py index 8a3b156b999..f7e540a20b7 100644 --- a/src/bentoml/_internal/io_descriptors/image.py +++ b/src/bentoml/_internal/io_descriptors/image.py @@ -231,8 +231,6 @@ def from_sample( if LazyType["ext.NpNDArray"]("numpy.ndarray").isinstance(sample): sample = PIL.Image.fromarray(sample, mode=pilmode) - elif LazyType["PIL.Image.Image"]("PIL.Image.Image").isinstance(sample): - sample = sample elif isinstance(sample, str): p = resolve_user_filepath(sample, ctx=None) try: diff --git a/src/bentoml/_internal/io_descriptors/pandas.py b/src/bentoml/_internal/io_descriptors/pandas.py index 91a58a4eb31..cacb1d1e90d 100644 --- a/src/bentoml/_internal/io_descriptors/pandas.py +++ b/src/bentoml/_internal/io_descriptors/pandas.py @@ -469,20 +469,12 @@ def _convert_dtype( return None def to_spec(self) -> dict[str, t.Any]: - # TODO: support extension dtypes - dtype = None - if self._dtype is not None: - if isinstance(self._dtype, bool): - dtype = self._dtype - else: - dtype = self._dtype.name - return { "id": self.descriptor_id, "args": { "orient": self._orient, "columns": self._columns, - "dtype": self._convert_dtype(dtype), + "dtype": self._convert_dtype(self._dtype), "shape": self._shape, "enforce_dtype": self._enforce_dtype, "enforce_shape": self._enforce_shape, diff --git a/tests/unit/_internal/io/test_base.py b/tests/unit/_internal/io/test_base.py index ddf91714006..ca2065290da 100644 --- a/tests/unit/_internal/io/test_base.py +++ b/tests/unit/_internal/io/test_base.py @@ -2,12 +2,15 @@ import typing as t from typing import TYPE_CHECKING -from bentoml.io import IODescriptor + import pytest +from bentoml.io import IODescriptor + if TYPE_CHECKING: from typing_extensions import Self + from bentoml._internal.context import InferenceApiContext as Context