1
1
from pathlib import Path
2
2
from typing import Any , List , Mapping , Optional
3
3
4
- from grpclib .client import Channel
5
- from google .protobuf .timestamp_pb2 import Timestamp
6
4
from google .protobuf .struct_pb2 import Struct
5
+ from google .protobuf .timestamp_pb2 import Timestamp
6
+ from grpclib .client import Channel
7
7
8
8
from viam import logging
9
- from viam .utils import struct_to_dict
10
9
from viam .proto .app .data import (
11
10
AddTagsToBinaryDataByFilterRequest ,
12
11
AddTagsToBinaryDataByFilterResponse ,
38
37
TagsByFilterResponse ,
39
38
)
40
39
from viam .proto .app .datasync import (
41
- DataSyncServiceStub ,
42
- FileData ,
43
- SensorData ,
44
- UploadMetadata ,
45
40
DataCaptureUploadRequest ,
46
41
DataCaptureUploadResponse ,
42
+ DataSyncServiceStub ,
43
+ DataType ,
44
+ FileData ,
47
45
FileUploadRequest ,
48
46
FileUploadResponse ,
49
- DataType ,
50
- SensorMetadata
47
+ SensorData ,
48
+ SensorMetadata ,
49
+ UploadMetadata ,
51
50
)
51
+ from viam .utils import struct_to_dict
52
52
53
53
LOGGER = logging .getLogger (__name__ )
54
54
@@ -267,8 +267,7 @@ async def remove_tags_from_binary_data_by_ids(self, tags: List[str], binary_ids:
267
267
"""
268
268
request = RemoveTagsFromBinaryDataByIDsRequest (binary_ids = binary_ids , tags = tags )
269
269
response : RemoveTagsFromBinaryDataByIDsResponse = await self ._data_client .RemoveTagsFromBinaryDataByIDs (
270
- request ,
271
- metadata = self ._metadata
270
+ request , metadata = self ._metadata
272
271
)
273
272
return response .deleted_count
274
273
@@ -288,8 +287,7 @@ async def remove_tags_from_binary_data_by_filter(self, tags: List[str], filter:
288
287
filter = filter if filter else Filter ()
289
288
request = RemoveTagsFromBinaryDataByFilterRequest (filter = filter , tags = tags )
290
289
response : RemoveTagsFromBinaryDataByFilterResponse = await self ._data_client .RemoveTagsFromBinaryDataByFilter (
291
- request ,
292
- metadata = self ._metadata
290
+ request , metadata = self ._metadata
293
291
)
294
292
return response .deleted_count
295
293
@@ -338,7 +336,7 @@ async def binary_data_capture_upload(
338
336
method_parameters : Optional [Mapping [str , Any ]],
339
337
tags : Optional [List [str ]],
340
338
timestamps : Optional [tuple [Timestamp , Timestamp ]],
341
- binary_data : bytes
339
+ binary_data : bytes ,
342
340
) -> None :
343
341
"""Upload binary sensor data.
344
342
@@ -365,7 +363,7 @@ async def binary_data_capture_upload(
365
363
time_received = timestamps [1 ] if timestamps [1 ] else None ,
366
364
),
367
365
struct = None , # Used for tabular data.
368
- binary = binary_data
366
+ binary = binary_data ,
369
367
)
370
368
metadata = UploadMetadata (
371
369
part_id = part_id ,
@@ -389,7 +387,7 @@ async def tabular_data_capture_upload(
389
387
method_parameters : Optional [Mapping [str , Any ]],
390
388
tags : Optional [List [str ]],
391
389
timestamps : Optional [List [tuple [Timestamp , Timestamp ]]],
392
- tabular_data : List [Mapping [str , Any ]]
390
+ tabular_data : List [Mapping [str , Any ]],
393
391
) -> None :
394
392
"""Upload tabular sensor data.
395
393
@@ -425,9 +423,9 @@ async def tabular_data_capture_upload(
425
423
sensor_contents [i ] = SensorData (
426
424
metadata = SensorMetadata (
427
425
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 ,
429
427
),
430
- struct = s
428
+ struct = s ,
431
429
)
432
430
433
431
metadata = UploadMetadata (
@@ -458,7 +456,7 @@ async def file_upload(
458
456
method_parameters : Optional [Mapping [str , Any ]],
459
457
file_extension : Optional [str ],
460
458
tags : Optional [List [str ]],
461
- data : Optional [bytes ]
459
+ data : Optional [bytes ],
462
460
) -> None :
463
461
"""Upload arbitrary file data.
464
462
@@ -501,7 +499,7 @@ async def file_upload_from_path(
501
499
method_name : Optional [str ],
502
500
method_parameters : Optional [Mapping [str , Any ]],
503
501
tags : Optional [List [str ]],
504
- filepath : str
502
+ filepath : str ,
505
503
) -> None :
506
504
"""Upload arbitrary file data.
507
505
0 commit comments