Skip to content

Commit

Permalink
chore(dataset): remove dataset origin field (#2020)
Browse files Browse the repository at this point in the history
remove dataset origin field
  • Loading branch information
tianweidut authored Mar 30, 2023
1 parent 3158e86 commit 9adab60
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 45 deletions.
6 changes: 0 additions & 6 deletions client/starwhale/base/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ class ObjectStoreType(Enum):
UNDEFINED = "undefined"


@unique
class DataOriginType(Enum):
NEW = "+"
INHERIT = "~"


@unique
class DependencyType(Enum):
PIP_PKG = "pip_pkg"
Expand Down
19 changes: 1 addition & 18 deletions client/starwhale/core/dataset/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
from starwhale.utils import validate_obj_name
from starwhale.consts import ENV_POD_NAME, STANDALONE_INSTANCE
from starwhale.base.uri import URI
from starwhale.base.type import (
URIType,
InstanceType,
DataFormatType,
DataOriginType,
ObjectStoreType,
)
from starwhale.base.type import URIType, InstanceType, DataFormatType, ObjectStoreType
from starwhale.base.mixin import ASDictMixin, _do_asdict_convert
from starwhale.consts.env import SWEnv
from starwhale.utils.error import (
Expand Down Expand Up @@ -102,12 +96,10 @@ class TabularDatasetRow(ASDictMixin):
def __init__(
self,
id: t.Union[str, int],
origin: DataOriginType = DataOriginType.NEW,
features: t.Optional[t.Dict[str, t.Any]] = None,
**kw: t.Union[str, int, float],
) -> None:
self.id = id
self.origin = origin
self.features = features or {}
self.extra_kw = kw
# TODO: add non-starwhale object store related fields, such as address, authority
Expand All @@ -118,7 +110,6 @@ def __init__(
def from_datastore(
cls,
id: t.Union[str, int],
origin: str = DataOriginType.NEW.value,
**kw: t.Any,
) -> TabularDatasetRow:
_content = {}
Expand All @@ -132,17 +123,13 @@ def from_datastore(

return cls(
id=id,
origin=DataOriginType(origin),
features=_content,
**_extra_kw,
)

def __eq__(self, o: object) -> bool:
s = deepcopy(self.__dict__)
o = deepcopy(o.__dict__)

s.pop("origin", None)
o.pop("origin", None)
return s == o

def _do_validate(self) -> None:
Expand All @@ -155,9 +142,6 @@ def _do_validate(self) -> None:
if not isinstance(self.features, dict) or not self.features:
raise FieldTypeOrValueError("no data field")

if not isinstance(self.origin, DataOriginType):
raise NoSupportError(f"data origin: {self.origin}")

def __str__(self) -> str:
return f"row-{self.id}"

Expand Down Expand Up @@ -192,7 +176,6 @@ def artifacts(self) -> t.List[BaseArtifact]:
class TabularDataset:
_map_types = {
"data_format": DataFormatType,
"origin": DataOriginType,
"object_store_type": ObjectStoreType,
}

Expand Down
4 changes: 1 addition & 3 deletions client/tests/core/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from starwhale.base.uri import URI
from starwhale.utils.fs import ensure_dir, ensure_file
from starwhale.api._impl import data_store
from starwhale.base.type import URIType, BundleType, DataOriginType
from starwhale.base.type import URIType, BundleType
from starwhale.utils.config import SWCliConfigMixed
from starwhale.core.dataset.cli import _list as list_cli
from starwhale.core.dataset.cli import _build as build_cli
Expand Down Expand Up @@ -301,7 +301,6 @@ def test_head(
),
"label": 0,
},
origin=DataOriginType.NEW,
),
TabularDatasetRow(
id="label-1",
Expand All @@ -317,7 +316,6 @@ def test_head(
),
"label": 1,
},
origin=DataOriginType.NEW,
),
]
content = b"\x00_\xfe\xc3\x00\x00\x00\x00"
Expand Down
3 changes: 0 additions & 3 deletions client/tests/sdk/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ def test_download(self, rm: Mocker) -> None:
},
],
},
{"type": "STRING", "name": "origin"},
{"type": "INT64", "name": "_append_seq_id"},
{
"type": "OBJECT",
Expand Down Expand Up @@ -374,7 +373,6 @@ def test_download(self, rm: Mocker) -> None:
"width": "0000000000000003",
"height": "0000000000000004",
},
"origin": "+",
}
],
}
Expand Down Expand Up @@ -1155,7 +1153,6 @@ def test_row(self) -> None:
"id": 0,
"features/l": Image(link=Link("abcdef"), shape=[1, 2, 3]),
"features/a": 1,
"origin": "+",
}

u_row_dict = u_row.asdict()
Expand Down
3 changes: 1 addition & 2 deletions client/tests/sdk/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from starwhale.consts import DEFAULT_PROJECT
from starwhale.base.uri import URI
from starwhale.utils.fs import ensure_dir, ensure_file
from starwhale.base.type import URIType, RunSubDirType, DataOriginType
from starwhale.base.type import URIType, RunSubDirType
from starwhale.utils.error import ParameterError
from starwhale.core.eval.store import EvaluationStorage
from starwhale.core.job.context import Context
Expand Down Expand Up @@ -263,7 +263,6 @@ def cmp(self, _data_loader: t.Any) -> t.Any:
),
"label": label_data,
},
origin=DataOriginType.NEW,
id=0,
).asdict(),
],
Expand Down
14 changes: 1 addition & 13 deletions client/tests/sdk/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from starwhale.consts import HTTPMethod, SWDSBackendType
from starwhale.base.uri import URI
from starwhale.utils.fs import ensure_dir
from starwhale.base.type import URIType, DataOriginType
from starwhale.base.type import URIType
from starwhale.consts.env import SWEnv
from starwhale.utils.error import ParameterError
from starwhale.core.dataset.type import Link, Image, DatasetSummary, GrayscaleImage
Expand Down Expand Up @@ -99,7 +99,6 @@ def test_user_raw_local_store(
),
"label": 0,
},
origin=DataOriginType.NEW,
id="path/0",
)
]
Expand Down Expand Up @@ -220,7 +219,6 @@ def test_user_raw_remote_store(
),
"label": 0,
},
origin=DataOriginType.NEW,
id=0,
),
TabularDatasetRow(
Expand All @@ -234,7 +232,6 @@ def test_user_raw_remote_store(
),
"label": 1,
},
origin=DataOriginType.NEW,
id=1,
),
TabularDatasetRow(
Expand All @@ -248,7 +245,6 @@ def test_user_raw_remote_store(
),
"label": 1,
},
origin=DataOriginType.NEW,
id=2,
),
TabularDatasetRow(
Expand All @@ -262,7 +258,6 @@ def test_user_raw_remote_store(
),
"label": 1,
},
origin=DataOriginType.NEW,
id=3,
),
]
Expand Down Expand Up @@ -366,7 +361,6 @@ def test_swds_bin_s3(
),
"label": 0,
},
origin=DataOriginType.NEW,
id=0,
)
]
Expand Down Expand Up @@ -443,7 +437,6 @@ def test_swds_bin_local_fs(self, m_scan: MagicMock, m_summary: MagicMock) -> Non
),
"label": 0,
},
origin=DataOriginType.NEW,
id=0,
),
TabularDatasetRow(
Expand All @@ -459,7 +452,6 @@ def test_swds_bin_local_fs(self, m_scan: MagicMock, m_summary: MagicMock) -> Non
),
"label": 1,
},
origin=DataOriginType.NEW,
id=1,
),
]
Expand Down Expand Up @@ -544,7 +536,6 @@ def test_remote_batch_sign(
)
),
},
origin=DataOriginType.NEW,
),
TabularDatasetRow(
id="b",
Expand All @@ -568,7 +559,6 @@ def test_remote_batch_sign(
)
),
},
origin=DataOriginType.NEW,
),
],
[
Expand All @@ -594,7 +584,6 @@ def test_remote_batch_sign(
)
),
},
origin=DataOriginType.NEW,
),
TabularDatasetRow(
id="d",
Expand All @@ -618,7 +607,6 @@ def test_remote_batch_sign(
)
),
},
origin=DataOriginType.NEW,
),
],
]
Expand Down

0 comments on commit 9adab60

Please sign in to comment.