Skip to content
Merged
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
13 changes: 7 additions & 6 deletions python/lib/sift_client/_internal/low_level_wrappers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
import logging
from datetime import datetime, timezone
from math import ceil
from typing import TYPE_CHECKING, Any, cast

import pandas as pd
Expand Down Expand Up @@ -231,7 +230,8 @@ async def get_channel_data(
run_id: str | None = None,
start_time: datetime | None = None,
end_time: datetime | None = None,
limit: int | None = None,
max_results: int | None = None,
page_size: int | None = None,
ignore_cache: bool = False,
) -> dict[str, pd.DataFrame]:
"""Get the data for a channel during a run."""
Expand All @@ -247,10 +247,11 @@ async def get_channel_data(
)

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

Expand All @@ -264,7 +265,7 @@ async def get_channel_data(
"end_time": end_time,
},
page_size=page_size,
max_results=limit,
max_results=max_results,
)
)
tasks.append(task)
Expand Down Expand Up @@ -294,7 +295,7 @@ async def get_channel_data(
"end_time": new_end_time or end_time,
},
page_size=page_size,
max_results=limit,
max_results=max_results,
)
)
tasks.append(task)
Expand Down
2 changes: 1 addition & 1 deletion python/lib/sift_client/resources/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def get_data(
run_id=run_id,
start_time=start_time,
end_time=end_time,
limit=limit,
max_results=limit,
)

async def get_data_as_arrow(
Expand Down
Loading