Skip to content

Commit 7381d18

Browse files
committed
make entire tuple optional
1 parent 2b0ebdc commit 7381d18

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/viam/app/data_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,15 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes
308308
response: TabularDataByMQLResponse = await self._data_client.TabularDataByMQL(request, metadata=self._metadata)
309309
return [bson.decode(bson_bytes) for bson_bytes in response.raw_data]
310310

311-
async def get_latest_tabular_data(self, part_id: str, resource_name: str, resource_subtype: str, method_name: str) -> Tuple[ Optional[datetime], Optional[datetime], Dict[str, ValueTypes]]:
311+
async def get_latest_tabular_data(self, part_id: str, resource_name: str, resource_subtype: str, method_name: str) -> Optional[Tuple[datetime,datetime, Dict[str, ValueTypes]]]:
312312
"""Gets the most recent tabular data captured from the specified data source, as long as it was synced within the last year.
313313
314314
::
315315
316316
time_captured, time_synced, payload = await data_client.get_latest_tabular_data(
317317
part_id="<PART-ID>",
318318
resource_name="<RESOURCE-NAME>",
319+
resource_subtype="<RESOURCE-SUBTYPE>",
319320
method_name="<METHOD-NAME>"
320321
)
321322
@@ -327,17 +328,17 @@ async def get_latest_tabular_data(self, part_id: str, resource_name: str, resour
327328
method_name (str): The data capture method name.
328329
329330
Returns:
330-
Tuple[Dict[str, ValueTypes], Optional[datetime], Optional[datetime]: A tuple containing the following:
331-
Optional[datetime]: The time captured,
332-
Optional[datetime]: The time synced,
331+
Optional[Tuple[Dict[str, ValueTypes], datetime, datetime]: A tuple which is None data hasn't been synced yet for the data source, otherwise the tuple contains the following:
332+
datetime: The time captured,
333+
datetime: The time synced,
333334
Dict[str, ValueTypes]: The latest tabular data captured from the specified data source.
334335
For more information, see `Data Client API <https://docs.viam.com/appendix/apis/data-client/>`_.
335336
"""
336337

337338
request = GetLatestTabularDataRequest(part_id=part_id, resource_name=resource_name, resource_subtype=resource_subtype, method_name=method_name)
338339
response: GetLatestTabularDataResponse = await self._data_client.GetLatestTabularData(request, metadata=self._metadata)
339340
if not response.payload:
340-
return None, None, {}
341+
return None
341342
return response.time_captured.ToDatetime(), response.time_synced.ToDatetime(), struct_to_dict(response.payload)
342343

343344

tests/test_data_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ async def test_get_latest_tabular_data(self, service: MockData):
169169
client = DataClient(channel, DATA_SERVICE_METADATA)
170170
time = datetime(2024, 12, 25)
171171
response = await client.get_latest_tabular_data(PART_ID, COMPONENT_NAME, COMPONENT_TYPE, METHOD)
172+
assert response != None
172173
time_captured, time_synced, payload = response
173174
assert service.part_id == PART_ID
174175
assert service.resource_name == COMPONENT_NAME

0 commit comments

Comments
 (0)