From 87567fee4c6b06de9ab1de607d8f88902ac9e126 Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Tue, 1 Aug 2023 13:57:47 -0700 Subject: [PATCH] Support for setting a 'from cursor for dataset.data_rows() --- labelbox/pagination.py | 2 +- tests/integration/test_data_rows.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/labelbox/pagination.py b/labelbox/pagination.py index 98f74cc07..a173505c9 100644 --- a/labelbox/pagination.py +++ b/labelbox/pagination.py @@ -134,7 +134,7 @@ class _CursorPagination(_Pagination): def __init__(self, cursor_path: List[str], *args, **kwargs): super().__init__(*args, **kwargs) self.cursor_path = cursor_path - self.next_cursor: Optional[Any] = None + self.next_cursor: Optional[Any] = kwargs.get('params', {}).get('from') def increment_page(self, results: Dict[str, Any]): for path in self.cursor_path: diff --git a/tests/integration/test_data_rows.py b/tests/integration/test_data_rows.py index d0f023b8e..a70c1c41b 100644 --- a/tests/integration/test_data_rows.py +++ b/tests/integration/test_data_rows.py @@ -173,6 +173,9 @@ def test_data_row_bulk_creation(dataset, rand_gen, image_url): assert {data_row.row_data for data_row in data_rows} == {image_url} assert {data_row.global_key for data_row in data_rows} == {None} + data_rows = list(dataset.data_rows(from_cursor=data_rows[0].uid)) + assert len(data_rows) == 1 + # Test creation using file name with NamedTemporaryFile() as fp: data = rand_gen(str).encode()