Skip to content

Commit 8a733a6

Browse files
authored
python(fix): Allow normal pagination for fetching data. (#399)
1 parent 9d15b0d commit 8a733a6

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

python/lib/sift_client/_internal/low_level_wrappers/data.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import asyncio
44
import logging
55
from datetime import datetime, timezone
6-
from math import ceil
76
from typing import TYPE_CHECKING, Any, cast
87

98
import pandas as pd
@@ -231,7 +230,8 @@ async def get_channel_data(
231230
run_id: str | None = None,
232231
start_time: datetime | None = None,
233232
end_time: datetime | None = None,
234-
limit: int | None = None,
233+
max_results: int | None = None,
234+
page_size: int | None = None,
235235
ignore_cache: bool = False,
236236
) -> dict[str, pd.DataFrame]:
237237
"""Get the data for a channel during a run."""
@@ -247,10 +247,11 @@ async def get_channel_data(
247247
)
248248

249249
tasks = []
250-
page_size = limit if limit and limit < 1000 else 1000
251-
limit = ceil(limit / page_size) if limit else 10
252250
# Queue up calls for non-cached channels in batches.
253251
batch_size = REQUEST_BATCH_SIZE
252+
page_size = None
253+
if max_results is not None and max_results <= CHANNELS_DEFAULT_PAGE_SIZE:
254+
page_size = max_results
254255
for i in range(0, len(not_cached_channels), batch_size): # type: ignore
255256
batch = not_cached_channels[i : i + batch_size] # type: ignore
256257

@@ -264,7 +265,7 @@ async def get_channel_data(
264265
"end_time": end_time,
265266
},
266267
page_size=page_size,
267-
max_results=limit,
268+
max_results=max_results,
268269
)
269270
)
270271
tasks.append(task)
@@ -294,7 +295,7 @@ async def get_channel_data(
294295
"end_time": new_end_time or end_time,
295296
},
296297
page_size=page_size,
297-
max_results=limit,
298+
max_results=max_results,
298299
)
299300
)
300301
tasks.append(task)

python/lib/sift_client/resources/channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ async def get_data(
199199
run_id=run_id,
200200
start_time=start_time,
201201
end_time=end_time,
202-
limit=limit,
202+
max_results=limit,
203203
)
204204

205205
async def get_data_as_arrow(

0 commit comments

Comments
 (0)