Skip to content
Open
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
11 changes: 7 additions & 4 deletions src/viam/app/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2400,32 +2400,35 @@ async def sequences_by_dataset_id(
dataset_id: str,
page_token: Optional[str] = None,
page_size: Optional[int] = None,
count_only: bool = False,
timeout: Optional[float] = None,
) -> Tuple[TSequence[Sequence], str]:
) -> Tuple[TSequence[Sequence], str, int]:
"""Get sequences in a dataset by dataset ID.

Args:
dataset_id (str): The ID of the dataset.
page_token (Optional[str]): Optional page token for pagination.
page_size (Optional[int]): Optional page size for pagination.
count_only (bool): If True, only return the count of sequences without fetching the actual sequences. Defaults to False.
timeout (Optional[float]): An optional deadline for the call to complete in seconds.

Returns:
Tuple[List[Sequence], str]: A tuple containing:
Tuple[List[Sequence], str, int]: A tuple containing:
- A list of sequences in the dataset.
- The next page token (empty string if no more pages).
- The total count of sequences in the dataset.

For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#sequencesbydatasetid>`_.
"""
request = SequencesByDatasetIDRequest(dataset_id=dataset_id)
request = SequencesByDatasetIDRequest(dataset_id=dataset_id, count_only=count_only)
if page_token is not None:
request.page_token = page_token
if page_size is not None:
request.page_size = page_size
response: SequencesByDatasetIDResponse = await self._data_client.SequencesByDatasetID(
request, metadata=self._metadata, timeout=timeout
)
return list(response.sequences), response.next_page_token
return list(response.sequences), response.next_page_token, response.count

async def get_sequence_binary_data(
self,
Expand Down
42 changes: 21 additions & 21 deletions src/viam/gen/app/data/v1/data_pb2.py

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/viam/gen/app/data/v1/data_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2497,13 +2497,15 @@ class SequencesByDatasetIDRequest(_message.Message):
DATASET_ID_FIELD_NUMBER: _builtins.int
PAGE_TOKEN_FIELD_NUMBER: _builtins.int
PAGE_SIZE_FIELD_NUMBER: _builtins.int
COUNT_ONLY_FIELD_NUMBER: _builtins.int
dataset_id: _builtins.str
page_token: _builtins.str
page_size: _builtins.int
count_only: _builtins.bool

def __init__(self, *, dataset_id: _builtins.str=..., page_token: _builtins.str=..., page_size: _builtins.int=...) -> None:
def __init__(self, *, dataset_id: _builtins.str=..., page_token: _builtins.str=..., page_size: _builtins.int=..., count_only: _builtins.bool=...) -> None:
...
_ClearFieldArgType: _TypeAlias = _typing.Literal['dataset_id', b'dataset_id', 'page_size', b'page_size', 'page_token', b'page_token']
_ClearFieldArgType: _TypeAlias = _typing.Literal['count_only', b'count_only', 'dataset_id', b'dataset_id', 'page_size', b'page_size', 'page_token', b'page_token']

def ClearField(self, field_name: _ClearFieldArgType) -> None:
...
Expand All @@ -2514,15 +2516,17 @@ class SequencesByDatasetIDResponse(_message.Message):
DESCRIPTOR: _descriptor.Descriptor
SEQUENCES_FIELD_NUMBER: _builtins.int
NEXT_PAGE_TOKEN_FIELD_NUMBER: _builtins.int
COUNT_FIELD_NUMBER: _builtins.int
next_page_token: _builtins.str
count: _builtins.int

@_builtins.property
def sequences(self) -> _containers.RepeatedCompositeFieldContainer[Global___Sequence]:
...

def __init__(self, *, sequences: _abc.Iterable[Global___Sequence] | None=..., next_page_token: _builtins.str=...) -> None:
def __init__(self, *, sequences: _abc.Iterable[Global___Sequence] | None=..., next_page_token: _builtins.str=..., count: _builtins.int=...) -> None:
...
_ClearFieldArgType: _TypeAlias = _typing.Literal['next_page_token', b'next_page_token', 'sequences', b'sequences']
_ClearFieldArgType: _TypeAlias = _typing.Literal['count', b'count', 'next_page_token', b'next_page_token', 'sequences', b'sequences']

def ClearField(self, field_name: _ClearFieldArgType) -> None:
...
Expand Down
2 changes: 1 addition & 1 deletion src/viam/version_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.79.2"

API_VERSION = "v0.1.574"
API_VERSION = "v0.1.575"
SDK_VERSION = __version__
3 changes: 2 additions & 1 deletion tests/mocks/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,9 @@ async def SequencesByDatasetID(self, stream: Stream[SequencesByDatasetIDRequest,
self.dataset_id = request.dataset_id
self.page_token = request.page_token
self.page_size = request.page_size
self.count_only = request.count_only
# Return empty list for testing - tests can override this behavior
await stream.send_message(SequencesByDatasetIDResponse(sequences=[], next_page_token=""))
await stream.send_message(SequencesByDatasetIDResponse(sequences=[], next_page_token="", count=0))

async def GetSequenceBinaryData(self, stream: Stream[GetSequenceBinaryDataRequest, GetSequenceBinaryDataResponse]) -> None:
request = await stream.recv_message()
Expand Down
6 changes: 5 additions & 1 deletion tests/test_data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,16 @@ async def test_remove_sequences_from_dataset(self, service: MockData):
async def test_sequences_by_dataset_id(self, service: MockData):
async with ChannelFor([service]) as channel:
client = DataClient(channel, DATA_SERVICE_METADATA)
sequences, next_page_token = await client.sequences_by_dataset_id(dataset_id=DATASET_ID, page_token="page1", page_size=10)
sequences, next_page_token, count = await client.sequences_by_dataset_id(
dataset_id=DATASET_ID, page_token="page1", page_size=10, count_only=True
)
assert service.dataset_id == DATASET_ID
assert service.page_token == "page1"
assert service.page_size == 10
assert service.count_only is True
assert sequences == []
assert next_page_token == ""
assert count == 0

async def test_get_sequence_binary_data(self, service: MockData):
async with ChannelFor([service]) as channel:
Expand Down
Loading