Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Add non-implemented batch functions
Browse files Browse the repository at this point in the history
  • Loading branch information
terryyylim committed May 8, 2022
1 parent fca1b89 commit bfce0c0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mlem/contrib/lightgbm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import posixpath
import tempfile
from typing import Any, ClassVar, List, Optional, Tuple, Type
from typing import Any, ClassVar, Iterator, List, Optional, Tuple, Type

import lightgbm as lgb
from pydantic import BaseModel
Expand Down Expand Up @@ -114,6 +114,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
)
)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class LightGBMModelIO(ModelIO):
"""
Expand Down
5 changes: 5 additions & 0 deletions mlem/contrib/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data = self.dataset_type.actual_type(res)
return self.dataset_type.copy().bind(data)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class NumpyArrayWriter(DatasetWriter):
"""DatasetWriter implementation for numpy ndarray"""
Expand Down
5 changes: 5 additions & 0 deletions mlem/contrib/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data.index.name = None
return self.dataset_type.copy().bind(data)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class PandasSeriesWriter(DatasetWriter, _PandasIO):
"""DatasetWriter for pandas series"""
Expand Down
7 changes: 6 additions & 1 deletion mlem/contrib/torch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, ClassVar, Optional, Tuple
from typing import Any, ClassVar, Iterator, Optional, Tuple

import torch

Expand Down Expand Up @@ -100,6 +100,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data = torch.load(f)
return self.dataset_type.copy().bind(data)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class TorchModelIO(ModelIO):
"""
Expand Down
20 changes: 20 additions & 0 deletions mlem/core/dataset_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data = self.dataset_type.to_type(res)
return self.dataset_type.copy().bind(data)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class ListDatasetType(DatasetType, DatasetSerializer):
"""
Expand Down Expand Up @@ -295,6 +300,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data_list.append(elem_dtype.data)
return self.dataset_type.copy().bind(data_list)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class _TupleLikeDatasetType(DatasetType, DatasetSerializer):
"""
Expand Down Expand Up @@ -393,6 +403,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data_list = self.dataset_type.actual_type(data_list)
return self.dataset_type.copy().bind(data_list)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


class TupleLikeListDatasetType(_TupleLikeDatasetType):
"""
Expand Down Expand Up @@ -548,6 +563,11 @@ def read(self, artifacts: Artifacts) -> DatasetType:
data_dict[key] = v_dataset_type.data
return self.dataset_type.copy().bind(data_dict)

def read_batch(
self, artifacts: Artifacts, batch: int
) -> Iterator[DatasetType]:
raise NotImplementedError


#
#
Expand Down

0 comments on commit bfce0c0

Please sign in to comment.