Skip to content

Commit 5a7e4f8

Browse files
committed
Update export method to accept separate start/end datetimes #DATA-3443
1 parent 571108b commit 5a7e4f8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/viam/app/data_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ async def get_latest_tabular_data(
340340
return response.time_captured.ToDatetime(), response.time_synced.ToDatetime(), struct_to_dict(response.payload)
341341

342342
async def export_tabular_data(
343-
self, part_id: str, resource_name: str, resource_subtype: str, method_name: str, interval: Optional[CaptureInterval] = None
343+
self, part_id: str, resource_name: str, resource_subtype: str, method_name: str, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None
344344
) -> List[ExportTabularDataResponse]:
345345
"""Obtain unified tabular data and metadata from the specified data source.
346346
@@ -361,20 +361,20 @@ async def export_tabular_data(
361361
resource_name (str): The name of the requested resource that captured the data.
362362
resource_subtype (str): The subtype of the requested resource that captured the data.
363363
method_name (str): The data capture method name.
364-
interval (CaptureInterval): Optional time interval to retrieve data for. Contains start and end fields as protobuf
365-
Timestamps defining the time range to query.
364+
start_time (datetime): Optional start time for requesting a specific range of data.
365+
end_time (datetime): Optional end time for requesting a specific range of data.
366366
367367
Returns:
368368
List[ExportTabularDataResponse]: The unified tabular data and metadata.
369369
370370
For more information, see `Data Client API <https://docs.viam.com/appendix/apis/data-client/>`_.
371371
"""
372372

373+
interval=CaptureInterval(start=datetime_to_timestamp(start_time), end=datetime_to_timestamp(end_time))
373374
request = ExportTabularDataRequest(
374375
part_id=part_id, resource_name=resource_name, resource_subtype=resource_subtype, method_name=method_name, interval=interval
375376
)
376-
response: List[ExportTabularDataResponse] = await self._data_client.ExportTabularData(request, metadata=self._metadata)
377-
return response
377+
return await self._data_client.ExportTabularData(request, metadata=self._metadata)
378378

379379
async def binary_data_by_filter(
380380
self,

tests/test_data_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ async def test_get_latest_tabular_data(self, service: MockData):
199199
async def test_export_tabular_data(self, service: MockData):
200200
async with ChannelFor([service]) as channel:
201201
client = DataClient(channel, DATA_SERVICE_METADATA)
202-
tabular_data = await client.export_tabular_data(PART_ID, COMPONENT_NAME, COMPONENT_TYPE, METHOD, INTERVAL)
202+
tabular_data = await client.export_tabular_data(PART_ID, COMPONENT_NAME, COMPONENT_TYPE, METHOD, START_DATETIME, END_DATETIME)
203203
assert tabular_data is not None
204204
for tabular_datum in tabular_data:
205205
assert tabular_datum is not None

0 commit comments

Comments
 (0)