Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/galileo/__future__/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Dataset(StateManagementMixin):
])

# Get version history
history = dataset.get_version_history()
history = dataset.load_version_history()

# Delete dataset
dataset.delete()
Expand Down Expand Up @@ -364,7 +364,7 @@ def add_rows(self, rows: list[dict[str, Any]]) -> Dataset: # type: ignore[valid
self._set_state(SyncState.FAILED_SYNC, error=e)
raise

def get_version_history(self) -> list[dict[str, Any]]: # type: ignore[valid-type]
def load_version_history(self) -> list[dict[str, Any]]: # type: ignore[valid-type]
"""
Get the version history of this dataset.

Expand All @@ -375,17 +375,17 @@ def get_version_history(self) -> list[dict[str, Any]]: # type: ignore[valid-typ
Examples
--------
dataset = Dataset.get(name="my-dataset")
history = dataset.get_version_history()
history = dataset.load_version_history()
"""
if self.id is None:
raise ValueError("Dataset ID is not set. Cannot get version history for a local-only dataset.")
datasets_service = Datasets()
dataset = datasets_service.get(id=self.id)
if dataset is None:
return []
return dataset.get_version_history()
return dataset.load_version_history()

def get_version(self, *, index: int) -> DatasetContent | None:
def load_version(self, *, index: int) -> DatasetContent | None:
"""
Get a specific version of this dataset.

Expand All @@ -399,7 +399,7 @@ def get_version(self, *, index: int) -> DatasetContent | None:
Examples
--------
dataset = Dataset.get(name="my-dataset")
version = dataset.get_version(index=0)
version = dataset.load_version(index=0)
"""
if self.id is None:
raise ValueError("Dataset ID is not set. Cannot get version for a local-only dataset.")
Expand Down
6 changes: 3 additions & 3 deletions src/galileo/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_version_history(self) -> Optional[Union[HTTPValidationError, ListDataset
dataset_id=self.dataset.id, client=self.config.api_client, body=ListDatasetVersionParams()
)

def load_version(self, version_index: int) -> DatasetContent:
def get_version(self, version_index: int) -> DatasetContent:
return get_dataset_version_content_datasets_dataset_id_versions_version_index_content_get.sync(
dataset_id=self.dataset.id, version_index=version_index, client=self.config.api_client
)
Comment on lines +156 to 159
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dataset.load_version was removed/renamed to Dataset.get_version without providing a compatibility shim, so any external client still calling load_version now gets AttributeError and the public SDK API is broken; can we keep load_version (e.g. alias it to get_version or leave both names) or document/deprecate before removal?

Finding type: Breaking Changes


Want Baz to fix this for you? Activate Fixer

Other fix methods

Fix in Cursor

Prompt for AI Agents:

In src/galileo/datasets.py around lines 156-159, the Dataset.load_version method was
removed/renamed to get_version which breaks external clients. Restore backward
compatibility by adding a load_version method that delegates to get_version (for
example: def load_version(self, version_index: int) -> DatasetContent: return
self.get_version(version_index)) and include a DeprecationWarning in the method
docstring or via warnings.warn to signal the rename. This will keep the public SDK API
stable while allowing consumers to migrate.

Expand Down Expand Up @@ -889,13 +889,13 @@ def get_dataset_version(
dataset = Datasets().get(name=dataset_name)
if dataset is None:
raise ValueError(f"Dataset '{dataset_name}' not found")
return dataset.load_version(version_index)
return dataset.get_version(version_index)

if dataset_id is not None:
dataset = Datasets().get(id=dataset_id)
if dataset is None:
raise ValueError(f"Dataset '{dataset_id}' not found")
return dataset.load_version(version_index)
return dataset.get_version(version_index)
raise ValueError("Either dataset_name or dataset_id must be provided.")


Expand Down
8 changes: 5 additions & 3 deletions tests/future/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,18 @@ def test_get_content(
assert content == mock_content
mock_dataset.get_content.assert_called_once()

@pytest.mark.parametrize("method_name", ["get_content", "add_rows", "get_version_history", "get_version", "extend"])
@pytest.mark.parametrize(
"method_name", ["get_content", "add_rows", "load_version_history", "load_version", "extend"]
)
def test_content_methods_raise_error_for_local_only(self, method_name: str, reset_configuration: None) -> None:
"""Test content methods raise ValueError for local-only dataset."""
dataset = Dataset(name="Test Dataset")

with pytest.raises(ValueError, match="Dataset ID is not set"):
if method_name == "add_rows":
dataset.add_rows([{"input": "test"}])
elif method_name == "get_version":
dataset.get_version(index=0)
elif method_name == "load_version":
dataset.load_version(index=0)
elif method_name == "extend":
dataset.extend(prompt="Test", count=2)
else:
Expand Down
Loading