From dc157e955a16b89b4d9ee1d795013da3448f5a32 Mon Sep 17 00:00:00 2001 From: thiagobomfin-galileo Date: Tue, 3 Mar 2026 16:34:57 -0300 Subject: [PATCH 1/2] refactor: adjust get_version and get_version_history method name --- AGENTS.md | 4 ++-- src/galileo/__future__/dataset.py | 12 ++++++------ src/galileo/datasets.py | 6 +++--- src/galileo/prompts.py | 2 +- tests/future/test_dataset.py | 8 +++++--- tests/test_api_headers.py | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a2c2ad787..106ee7d07 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -413,10 +413,10 @@ Configuration exists in three places: API uses **1-based** version indexing, not 0-based: ```python # Correct: first version is index 1 -version_content = dataset.get_version(index=1) +version_content = dataset.load_version(index=1) # Wrong: index 0 doesn't exist -version_content = dataset.get_version(index=0) # Returns None +version_content = dataset.load_version(index=0) # Returns None ``` ### 5. Experiment-Playground Conflation diff --git a/src/galileo/__future__/dataset.py b/src/galileo/__future__/dataset.py index 8398f3982..de09d61ad 100644 --- a/src/galileo/__future__/dataset.py +++ b/src/galileo/__future__/dataset.py @@ -59,7 +59,7 @@ class Dataset(StateManagementMixin): ]) # Get version history - history = dataset.get_version_history() + history = dataset.load_version_history() # Delete dataset dataset.delete() @@ -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. @@ -375,7 +375,7 @@ 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.") @@ -383,9 +383,9 @@ def get_version_history(self) -> list[dict[str, Any]]: # type: ignore[valid-typ 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. @@ -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.") diff --git a/src/galileo/datasets.py b/src/galileo/datasets.py index f058e7e1d..c4cc5854f 100644 --- a/src/galileo/datasets.py +++ b/src/galileo/datasets.py @@ -148,7 +148,7 @@ def add_rows(self, row_data: list[dict[str, Any]]) -> "Dataset": return self - def get_version_history(self) -> Optional[Union[HTTPValidationError, ListDatasetVersionResponse]]: + def load_version_history(self) -> Optional[Union[HTTPValidationError, ListDatasetVersionResponse]]: return query_dataset_versions_datasets_dataset_id_versions_query_post.sync( dataset_id=self.dataset.id, client=self.config.api_client, body=ListDatasetVersionParams() ) @@ -855,12 +855,12 @@ def get_dataset_version_history( dataset = Datasets().get(name=dataset_name) if dataset is None: raise ValueError(f"Dataset '{dataset_name}' not found") - return dataset.get_version_history() + return dataset.load_version_history() 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.get_version_history() + return dataset.load_version_history() raise ValueError("Either dataset_name or dataset_id must be provided.") diff --git a/src/galileo/prompts.py b/src/galileo/prompts.py index 38c280d79..7ede3f7ff 100644 --- a/src/galileo/prompts.py +++ b/src/galileo/prompts.py @@ -232,7 +232,7 @@ def delete(self, *, template_id: Optional[str] = None, name: Optional[str] = Non client=self.config.api_client, template_id=template_id ) - def get_version(self, *, template_id: str, version: int) -> Optional[PromptTemplateVersion]: + def load_version(self, *, template_id: str, version: int) -> Optional[PromptTemplateVersion]: _logger.debug(f"Get global template {template_id} version {version}") template_version = get_global_template_version_templates_template_id_versions_version_get.sync( template_id=template_id, version=version, client=self.config.api_client diff --git a/tests/future/test_dataset.py b/tests/future/test_dataset.py index 20dd0decd..772f63f11 100644 --- a/tests/future/test_dataset.py +++ b/tests/future/test_dataset.py @@ -157,7 +157,9 @@ 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") @@ -165,8 +167,8 @@ def test_content_methods_raise_error_for_local_only(self, method_name: str, rese 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: diff --git a/tests/test_api_headers.py b/tests/test_api_headers.py index 1b3196a26..ab18039ac 100644 --- a/tests/test_api_headers.py +++ b/tests/test_api_headers.py @@ -46,9 +46,9 @@ def test_generated_api_method_header_format(self) -> None: assert isinstance(version_part, str) @patch("galileo.utils.headers_data.get_package_version") - def test_generated_api_method_with_mocked_version(self, mock_get_version) -> None: + def test_generated_api_method_with_mocked_version(self, mock_load_version) -> None: """Test header includes mocked version and method name.""" - mock_get_version.return_value = "1.2.3" + mock_load_version.return_value = "1.2.3" dataset_id = "test-dataset-id" kwargs = dataset_get_kwargs(dataset_id=dataset_id) From b101f00add44808013cf563848bbd7e7e94f6d0e Mon Sep 17 00:00:00 2001 From: thiagobomfin-galileo Date: Wed, 4 Mar 2026 12:25:36 -0300 Subject: [PATCH 2/2] refactor: revert changes outside __future__ --- AGENTS.md | 4 ++-- src/galileo/datasets.py | 12 ++++++------ src/galileo/prompts.py | 2 +- tests/test_api_headers.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 106ee7d07..a2c2ad787 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -413,10 +413,10 @@ Configuration exists in three places: API uses **1-based** version indexing, not 0-based: ```python # Correct: first version is index 1 -version_content = dataset.load_version(index=1) +version_content = dataset.get_version(index=1) # Wrong: index 0 doesn't exist -version_content = dataset.load_version(index=0) # Returns None +version_content = dataset.get_version(index=0) # Returns None ``` ### 5. Experiment-Playground Conflation diff --git a/src/galileo/datasets.py b/src/galileo/datasets.py index c4cc5854f..d05b16d6b 100644 --- a/src/galileo/datasets.py +++ b/src/galileo/datasets.py @@ -148,12 +148,12 @@ def add_rows(self, row_data: list[dict[str, Any]]) -> "Dataset": return self - def load_version_history(self) -> Optional[Union[HTTPValidationError, ListDatasetVersionResponse]]: + def get_version_history(self) -> Optional[Union[HTTPValidationError, ListDatasetVersionResponse]]: return query_dataset_versions_datasets_dataset_id_versions_query_post.sync( 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 ) @@ -855,12 +855,12 @@ def get_dataset_version_history( dataset = Datasets().get(name=dataset_name) if dataset is None: raise ValueError(f"Dataset '{dataset_name}' not found") - return dataset.load_version_history() + return dataset.get_version_history() 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_history() + return dataset.get_version_history() raise ValueError("Either dataset_name or dataset_id must be provided.") @@ -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.") diff --git a/src/galileo/prompts.py b/src/galileo/prompts.py index 7ede3f7ff..38c280d79 100644 --- a/src/galileo/prompts.py +++ b/src/galileo/prompts.py @@ -232,7 +232,7 @@ def delete(self, *, template_id: Optional[str] = None, name: Optional[str] = Non client=self.config.api_client, template_id=template_id ) - def load_version(self, *, template_id: str, version: int) -> Optional[PromptTemplateVersion]: + def get_version(self, *, template_id: str, version: int) -> Optional[PromptTemplateVersion]: _logger.debug(f"Get global template {template_id} version {version}") template_version = get_global_template_version_templates_template_id_versions_version_get.sync( template_id=template_id, version=version, client=self.config.api_client diff --git a/tests/test_api_headers.py b/tests/test_api_headers.py index ab18039ac..1b3196a26 100644 --- a/tests/test_api_headers.py +++ b/tests/test_api_headers.py @@ -46,9 +46,9 @@ def test_generated_api_method_header_format(self) -> None: assert isinstance(version_part, str) @patch("galileo.utils.headers_data.get_package_version") - def test_generated_api_method_with_mocked_version(self, mock_load_version) -> None: + def test_generated_api_method_with_mocked_version(self, mock_get_version) -> None: """Test header includes mocked version and method name.""" - mock_load_version.return_value = "1.2.3" + mock_get_version.return_value = "1.2.3" dataset_id = "test-dataset-id" kwargs = dataset_get_kwargs(dataset_id=dataset_id)