From cf90ba444d9a365a1ed3584808b869bf19595c45 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Tue, 22 Oct 2024 15:04:28 -0700 Subject: [PATCH] delete dataset_utils --- .../meta_reference/datasetio/datasetio.py | 27 +++++++++++++++- .../utils/datasetio/dataset_utils.py | 31 ------------------- 2 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 llama_stack/providers/utils/datasetio/dataset_utils.py diff --git a/llama_stack/providers/impls/meta_reference/datasetio/datasetio.py b/llama_stack/providers/impls/meta_reference/datasetio/datasetio.py index c3309ca18..404e5c887 100644 --- a/llama_stack/providers/impls/meta_reference/datasetio/datasetio.py +++ b/llama_stack/providers/impls/meta_reference/datasetio/datasetio.py @@ -10,12 +10,37 @@ import pandas from llama_models.llama3.api.datatypes import * # noqa: F403 from llama_stack.apis.datasetio import * # noqa: F403 +from abc import ABC, abstractmethod +from dataclasses import dataclass + from llama_stack.providers.datatypes import DatasetsProtocolPrivate -from llama_stack.providers.utils.datasetio.dataset_utils import BaseDataset, DatasetInfo from .config import MetaReferenceDatasetIOConfig +class BaseDataset(ABC): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + @abstractmethod + def __len__(self) -> int: + raise NotImplementedError() + + @abstractmethod + def __getitem__(self, idx): + raise NotImplementedError() + + @abstractmethod + def load(self): + raise NotImplementedError() + + +@dataclass +class DatasetInfo: + dataset_def: DatasetDef + dataset_impl: BaseDataset + + class PandasDataframeDataset(BaseDataset): def __init__(self, dataset_def: DatasetDef, *args, **kwargs) -> None: super().__init__(*args, **kwargs) diff --git a/llama_stack/providers/utils/datasetio/dataset_utils.py b/llama_stack/providers/utils/datasetio/dataset_utils.py deleted file mode 100644 index fd56d2424..000000000 --- a/llama_stack/providers/utils/datasetio/dataset_utils.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. -from abc import ABC, abstractmethod -from dataclasses import dataclass -from llama_stack.apis.datasetio import * # noqa: F403 - - -class BaseDataset(ABC): - def __init__(self, *args, **kwargs) -> None: - super().__init__(*args, **kwargs) - - @abstractmethod - def __len__(self) -> int: - raise NotImplementedError() - - @abstractmethod - def __getitem__(self, idx): - raise NotImplementedError() - - @abstractmethod - def load(self): - raise NotImplementedError() - - -@dataclass -class DatasetInfo: - dataset_def: DatasetDef - dataset_impl: BaseDataset