11from pathlib import Path
22from typing import Any , List , Mapping , Optional
33
4- from grpclib .client import Channel
5- from google .protobuf .timestamp_pb2 import Timestamp
64from google .protobuf .struct_pb2 import Struct
5+ from google .protobuf .timestamp_pb2 import Timestamp
6+ from grpclib .client import Channel
77
88from viam import logging
9- from viam .utils import struct_to_dict
109from viam .proto .app .data import (
1110 AddTagsToBinaryDataByFilterRequest ,
1211 AddTagsToBinaryDataByFilterResponse ,
3837 TagsByFilterResponse ,
3938)
4039from viam .proto .app .datasync import (
41- DataSyncServiceStub ,
42- FileData ,
43- SensorData ,
44- UploadMetadata ,
4540 DataCaptureUploadRequest ,
4641 DataCaptureUploadResponse ,
42+ DataSyncServiceStub ,
43+ DataType ,
44+ FileData ,
4745 FileUploadRequest ,
4846 FileUploadResponse ,
49- DataType ,
50- SensorMetadata
47+ SensorData ,
48+ SensorMetadata ,
49+ UploadMetadata ,
5150)
51+ from viam .utils import struct_to_dict
5252
5353LOGGER = logging .getLogger (__name__ )
5454
@@ -267,8 +267,7 @@ async def remove_tags_from_binary_data_by_ids(self, tags: List[str], binary_ids:
267267 """
268268 request = RemoveTagsFromBinaryDataByIDsRequest (binary_ids = binary_ids , tags = tags )
269269 response : RemoveTagsFromBinaryDataByIDsResponse = await self ._data_client .RemoveTagsFromBinaryDataByIDs (
270- request ,
271- metadata = self ._metadata
270+ request , metadata = self ._metadata
272271 )
273272 return response .deleted_count
274273
@@ -288,8 +287,7 @@ async def remove_tags_from_binary_data_by_filter(self, tags: List[str], filter:
288287 filter = filter if filter else Filter ()
289288 request = RemoveTagsFromBinaryDataByFilterRequest (filter = filter , tags = tags )
290289 response : RemoveTagsFromBinaryDataByFilterResponse = await self ._data_client .RemoveTagsFromBinaryDataByFilter (
291- request ,
292- metadata = self ._metadata
290+ request , metadata = self ._metadata
293291 )
294292 return response .deleted_count
295293
@@ -338,7 +336,7 @@ async def binary_data_capture_upload(
338336 method_parameters : Optional [Mapping [str , Any ]],
339337 tags : Optional [List [str ]],
340338 timestamps : Optional [tuple [Timestamp , Timestamp ]],
341- binary_data : bytes
339+ binary_data : bytes ,
342340 ) -> None :
343341 """Upload binary sensor data.
344342
@@ -365,7 +363,7 @@ async def binary_data_capture_upload(
365363 time_received = timestamps [1 ] if timestamps [1 ] else None ,
366364 ),
367365 struct = None , # Used for tabular data.
368- binary = binary_data
366+ binary = binary_data ,
369367 )
370368 metadata = UploadMetadata (
371369 part_id = part_id ,
@@ -389,7 +387,7 @@ async def tabular_data_capture_upload(
389387 method_parameters : Optional [Mapping [str , Any ]],
390388 tags : Optional [List [str ]],
391389 timestamps : Optional [List [tuple [Timestamp , Timestamp ]]],
392- tabular_data : List [Mapping [str , Any ]]
390+ tabular_data : List [Mapping [str , Any ]],
393391 ) -> None :
394392 """Upload tabular sensor data.
395393
@@ -425,9 +423,9 @@ async def tabular_data_capture_upload(
425423 sensor_contents [i ] = SensorData (
426424 metadata = SensorMetadata (
427425 time_requested = timestamps [i ][0 ] if timestamps and timestamps [i ][0 ] else None ,
428- time_received = timestamps [i ][1 ] if timestamps and timestamps [i ][1 ] else None
426+ time_received = timestamps [i ][1 ] if timestamps and timestamps [i ][1 ] else None ,
429427 ),
430- struct = s
428+ struct = s ,
431429 )
432430
433431 metadata = UploadMetadata (
@@ -458,7 +456,7 @@ async def file_upload(
458456 method_parameters : Optional [Mapping [str , Any ]],
459457 file_extension : Optional [str ],
460458 tags : Optional [List [str ]],
461- data : Optional [bytes ]
459+ data : Optional [bytes ],
462460 ) -> None :
463461 """Upload arbitrary file data.
464462
@@ -501,7 +499,7 @@ async def file_upload_from_path(
501499 method_name : Optional [str ],
502500 method_parameters : Optional [Mapping [str , Any ]],
503501 tags : Optional [List [str ]],
504- filepath : str
502+ filepath : str ,
505503 ) -> None :
506504 """Upload arbitrary file data.
507505
0 commit comments