GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: fix list failing without order_by and local sorting (#320) · ivanmkc/python-aiplatform@b897c3b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • google/cloud/aiplatform
    • base.py
  • tests/unit/aiplatform
    • test_datasets.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google/cloud/aiplatform/base.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform/base.py
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,14 +923,15 @@ def _list_with_local_order(
923923
credentials=credentials,
924924
)
925925

926-
desc = "desc" in order_by
927-
order_by = order_by.replace("desc", "")
928-
order_by = order_by.split(",")
926+
if order_by:
927+
desc = "desc" in order_by
928+
order_by = order_by.replace("desc", "")
929+
order_by = order_by.split(",")
929930

930-
li.sort(
931-
key=lambda x: tuple(getattr(x, field.strip()) for field in order_by),
932-
reverse=desc,
933-
)
931+
li.sort(
932+
key=lambda x: tuple(getattr(x, field.strip()) for field in order_by),
933+
reverse=desc,
934+
)
934935

935936
return li
936937

Collapse file

‎tests/unit/aiplatform/test_datasets.py‎

Copy file name to clipboardExpand all lines: tests/unit/aiplatform/test_datasets.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,20 @@ def test_list_dataset(self, list_datasets_mock):
849849
for ds in ds_list:
850850
assert type(ds) == aiplatform.TabularDataset
851851

852+
def test_list_dataset_no_order_or_filter(self, list_datasets_mock):
853+
854+
ds_list = aiplatform.TabularDataset.list()
855+
856+
list_datasets_mock.assert_called_once_with(
857+
request={"parent": _TEST_PARENT, "filter": None}
858+
)
859+
860+
# Ensure returned list is smaller since it filtered out non-tabular datasets
861+
assert len(ds_list) < len(_TEST_DATASET_LIST)
862+
863+
for ds in ds_list:
864+
assert type(ds) == aiplatform.TabularDataset
865+
852866

853867
class TestTextDataset:
854868
def setup_method(self):

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.