Skip to content

Commit

Permalink
do not overwrite version with None in DatasetQuery constructor (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored Jul 19, 2024
1 parent ecad0b7 commit e8eabfd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/datachain/query/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,16 +1090,14 @@ def __init__(
self.feature_schema = indexing_feature_schema
self.column_types = indexing_column_types
elif name:
self.name = name
ds = self.catalog.get_dataset(name)
self.version = version or ds.latest_version
self.feature_schema = ds.get_version(self.version).feature_schema
self.column_types = copy(ds.schema)
if "sys__id" in self.column_types:
self.column_types.pop("sys__id")
self.starting_step = QueryStep(self.catalog, name, self.version)
# attaching to specific dataset
self.name = name
self.version = version
else:
raise ValueError("must provide path or name")

Expand Down
17 changes: 17 additions & 0 deletions tests/unit/lib/test_datachain.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,23 @@ def test_select_restore_from_saving(catalog):
assert n == len(features_nested)


def test_from_dataset_name_version(catalog):
name = "test-version"
DataChain.from_values(
first_name=["Alice", "Bob", "Charlie"],
age=[40, 30, None],
city=[
"Houston",
"Los Angeles",
None,
],
).save(name)

dc = DataChain.from_dataset(name)
assert dc.name == name
assert dc.version


def test_chain_of_maps(catalog):
dc = (
DataChain.from_values(my_n=features_nested)
Expand Down

0 comments on commit e8eabfd

Please sign in to comment.