viam-sdk 0.45.2__py3-none-win_amd64.whl → 0.47.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of viam-sdk might be problematic. Click here for more details.
- viam/app/app_client.py +178 -9
- viam/app/data_client.py +430 -150
- viam/gen/app/mltraining/v1/ml_training_pb2.py +30 -24
- viam/gen/app/mltraining/v1/ml_training_pb2.pyi +21 -2
- viam/gen/app/v1/app_pb2.py +511 -511
- viam/gen/app/v1/app_pb2.pyi +37 -18
- viam/gen/module/v1/module_pb2.py +4 -4
- viam/gen/module/v1/module_pb2.pyi +7 -2
- viam/gen/robot/v1/robot_pb2.pyi +1 -1
- viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
- viam/module/module.py +24 -2
- viam/resource/easy_resource.py +4 -4
- viam/resource/registry.py +2 -2
- viam/resource/types.py +2 -2
- viam/rpc/libviam_rust_utils.dll +0 -0
- viam/version_metadata.py +2 -2
- {viam_sdk-0.45.2.dist-info → viam_sdk-0.47.0.dist-info}/METADATA +1 -1
- {viam_sdk-0.45.2.dist-info → viam_sdk-0.47.0.dist-info}/RECORD +20 -20
- {viam_sdk-0.45.2.dist-info → viam_sdk-0.47.0.dist-info}/WHEEL +0 -0
- {viam_sdk-0.45.2.dist-info → viam_sdk-0.47.0.dist-info}/licenses/LICENSE +0 -0
viam/app/data_client.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union, c
|
|
|
7
7
|
import bson
|
|
8
8
|
from google.protobuf.struct_pb2 import Struct
|
|
9
9
|
from grpclib.client import Channel, Stream
|
|
10
|
+
from typing_extensions import Self
|
|
10
11
|
|
|
11
12
|
from viam import logging
|
|
12
13
|
from viam.proto.app.data import (
|
|
@@ -54,9 +55,30 @@ from viam.proto.app.data import (
|
|
|
54
55
|
TabularDataByMQLResponse,
|
|
55
56
|
TabularDataBySQLRequest,
|
|
56
57
|
TabularDataBySQLResponse,
|
|
58
|
+
TabularDataSource,
|
|
59
|
+
TabularDataSourceType,
|
|
57
60
|
TagsByFilterRequest,
|
|
58
61
|
TagsByFilterResponse,
|
|
59
62
|
)
|
|
63
|
+
from viam.proto.app.datapipelines import (
|
|
64
|
+
CreateDataPipelineRequest,
|
|
65
|
+
CreateDataPipelineResponse,
|
|
66
|
+
DataPipelineRunStatus,
|
|
67
|
+
DataPipelinesServiceStub,
|
|
68
|
+
DeleteDataPipelineRequest,
|
|
69
|
+
GetDataPipelineRequest,
|
|
70
|
+
GetDataPipelineResponse,
|
|
71
|
+
ListDataPipelineRunsRequest,
|
|
72
|
+
ListDataPipelineRunsResponse,
|
|
73
|
+
ListDataPipelinesRequest,
|
|
74
|
+
ListDataPipelinesResponse,
|
|
75
|
+
)
|
|
76
|
+
from viam.proto.app.datapipelines import (
|
|
77
|
+
DataPipeline as ProtoDataPipeline,
|
|
78
|
+
)
|
|
79
|
+
from viam.proto.app.datapipelines import (
|
|
80
|
+
DataPipelineRun as ProtoDataPipelineRun,
|
|
81
|
+
)
|
|
60
82
|
from viam.proto.app.dataset import (
|
|
61
83
|
CreateDatasetRequest,
|
|
62
84
|
CreateDatasetResponse,
|
|
@@ -92,10 +114,10 @@ LOGGER = logging.getLogger(__name__)
|
|
|
92
114
|
class DataClient:
|
|
93
115
|
"""gRPC client for uploading and retrieving data from app.
|
|
94
116
|
|
|
95
|
-
|
|
96
|
-
|
|
117
|
+
This class's constructor instantiates relevant service stubs. Always make :class:`DataClient` method calls through an instance of
|
|
118
|
+
:class:`ViamClient`.
|
|
97
119
|
|
|
98
|
-
Establish a
|
|
120
|
+
Establish a connection::
|
|
99
121
|
|
|
100
122
|
import asyncio
|
|
101
123
|
|
|
@@ -159,10 +181,10 @@ class DataClient:
|
|
|
159
181
|
"""The resource name"""
|
|
160
182
|
|
|
161
183
|
resource_api: str
|
|
162
|
-
"""The resource API.
|
|
184
|
+
"""The resource API. For example, rdk:component:sensor"""
|
|
163
185
|
|
|
164
186
|
method_name: str
|
|
165
|
-
"""The method used for data capture.
|
|
187
|
+
"""The method used for data capture. For example, Readings"""
|
|
166
188
|
|
|
167
189
|
time_captured: datetime
|
|
168
190
|
"""The time at which the data point was captured"""
|
|
@@ -220,8 +242,123 @@ class DataClient:
|
|
|
220
242
|
)
|
|
221
243
|
return self.resource_api
|
|
222
244
|
|
|
245
|
+
@dataclass
|
|
246
|
+
class DataPipeline:
|
|
247
|
+
"""Represents a data pipeline and its associated metadata."""
|
|
248
|
+
|
|
249
|
+
id: str
|
|
250
|
+
"""The ID of the data pipeline"""
|
|
251
|
+
|
|
252
|
+
organization_id: str
|
|
253
|
+
"""The organization ID"""
|
|
254
|
+
|
|
255
|
+
name: str
|
|
256
|
+
"""The name of the data pipeline"""
|
|
257
|
+
|
|
258
|
+
mql_binary: List[Dict[str, Any]]
|
|
259
|
+
"""The MQL binary of the data pipeline"""
|
|
260
|
+
|
|
261
|
+
schedule: str
|
|
262
|
+
"""The schedule of the data pipeline"""
|
|
263
|
+
|
|
264
|
+
created_on: datetime
|
|
265
|
+
"""The time the data pipeline was created"""
|
|
266
|
+
|
|
267
|
+
updated_at: datetime
|
|
268
|
+
"""The time the data pipeline was last updated"""
|
|
269
|
+
|
|
270
|
+
enabled: bool
|
|
271
|
+
"""Whether the data pipeline is enabled"""
|
|
272
|
+
|
|
273
|
+
@classmethod
|
|
274
|
+
def from_proto(cls, data_pipeline: ProtoDataPipeline) -> Self:
|
|
275
|
+
return cls(
|
|
276
|
+
id=data_pipeline.id,
|
|
277
|
+
organization_id=data_pipeline.organization_id,
|
|
278
|
+
name=data_pipeline.name,
|
|
279
|
+
mql_binary=[bson.decode(bson_bytes) for bson_bytes in data_pipeline.mql_binary],
|
|
280
|
+
schedule=data_pipeline.schedule,
|
|
281
|
+
created_on=data_pipeline.created_on.ToDatetime(),
|
|
282
|
+
updated_at=data_pipeline.updated_at.ToDatetime(),
|
|
283
|
+
enabled=data_pipeline.enabled,
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
@dataclass
|
|
287
|
+
class DataPipelineRun:
|
|
288
|
+
"""Represents a data pipeline run and its associated metadata."""
|
|
289
|
+
|
|
290
|
+
id: str
|
|
291
|
+
"""The ID of the data pipeline run"""
|
|
292
|
+
|
|
293
|
+
status: DataPipelineRunStatus.ValueType
|
|
294
|
+
"""The status of the data pipeline run"""
|
|
295
|
+
|
|
296
|
+
start_time: datetime
|
|
297
|
+
"""The time the data pipeline run started"""
|
|
298
|
+
|
|
299
|
+
end_time: datetime
|
|
300
|
+
"""The time the data pipeline run ended"""
|
|
301
|
+
|
|
302
|
+
data_start_time: datetime
|
|
303
|
+
"""The start time of the data that was processed in the run."""
|
|
304
|
+
data_end_time: datetime
|
|
305
|
+
"""The end time of the data that was processed in the run."""
|
|
306
|
+
|
|
307
|
+
@classmethod
|
|
308
|
+
def from_proto(cls, data_pipeline_run: ProtoDataPipelineRun) -> Self:
|
|
309
|
+
return cls(
|
|
310
|
+
id=data_pipeline_run.id,
|
|
311
|
+
status=data_pipeline_run.status,
|
|
312
|
+
start_time=data_pipeline_run.start_time.ToDatetime(),
|
|
313
|
+
end_time=data_pipeline_run.end_time.ToDatetime(),
|
|
314
|
+
data_start_time=data_pipeline_run.data_start_time.ToDatetime(),
|
|
315
|
+
data_end_time=data_pipeline_run.data_end_time.ToDatetime(),
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
@dataclass
|
|
319
|
+
class DataPipelineRunsPage:
|
|
320
|
+
"""Represents a page of data pipeline runs and provides pagination functionality."""
|
|
321
|
+
|
|
322
|
+
_client: "DataClient"
|
|
323
|
+
"""The data client used to make API calls"""
|
|
324
|
+
|
|
325
|
+
pipeline_id: str
|
|
326
|
+
"""The ID of the pipeline these runs belong to"""
|
|
327
|
+
|
|
328
|
+
page_size: int
|
|
329
|
+
"""The number of runs per page"""
|
|
330
|
+
|
|
331
|
+
runs: List["DataClient.DataPipelineRun"]
|
|
332
|
+
"""The list of runs in this page"""
|
|
333
|
+
|
|
334
|
+
next_page_token: str
|
|
335
|
+
"""The token to use to get the next page of results"""
|
|
336
|
+
|
|
337
|
+
async def next_page(self) -> "DataClient.DataPipelineRunsPage":
|
|
338
|
+
"""Get the next page of data pipeline runs.
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
DataPipelineRunsPage: The next page of runs, or an empty page if there are no more runs
|
|
342
|
+
"""
|
|
343
|
+
if not self.next_page_token:
|
|
344
|
+
# no token, return empty next page
|
|
345
|
+
return DataClient.DataPipelineRunsPage(
|
|
346
|
+
_client=self._client, pipeline_id=self.pipeline_id, page_size=self.page_size, runs=[], next_page_token=""
|
|
347
|
+
)
|
|
348
|
+
return await self._client._list_data_pipeline_runs(self.pipeline_id, self.page_size, self.next_page_token)
|
|
349
|
+
|
|
350
|
+
@classmethod
|
|
351
|
+
def from_proto(cls, data_pipeline_runs_page: ListDataPipelineRunsResponse, client: "DataClient", page_size: int) -> Self:
|
|
352
|
+
return cls(
|
|
353
|
+
_client=client,
|
|
354
|
+
pipeline_id=data_pipeline_runs_page.pipeline_id,
|
|
355
|
+
page_size=page_size,
|
|
356
|
+
runs=[DataClient.DataPipelineRun.from_proto(run) for run in data_pipeline_runs_page.runs],
|
|
357
|
+
next_page_token=data_pipeline_runs_page.next_page_token,
|
|
358
|
+
)
|
|
359
|
+
|
|
223
360
|
def __init__(self, channel: Channel, metadata: Mapping[str, str]):
|
|
224
|
-
"""Create a
|
|
361
|
+
"""Create a :class:`DataClient` that maintains a connection to app.
|
|
225
362
|
|
|
226
363
|
Args:
|
|
227
364
|
channel (grpclib.client.Channel): Connection to app.
|
|
@@ -231,11 +368,13 @@ class DataClient:
|
|
|
231
368
|
self._data_client = DataServiceStub(channel)
|
|
232
369
|
self._data_sync_client = DataSyncServiceStub(channel)
|
|
233
370
|
self._dataset_client = DatasetServiceStub(channel)
|
|
371
|
+
self._data_pipelines_client = DataPipelinesServiceStub(channel)
|
|
234
372
|
self._channel = channel
|
|
235
373
|
|
|
236
374
|
_data_client: DataServiceStub
|
|
237
375
|
_data_sync_client: DataSyncServiceStub
|
|
238
376
|
_dataset_client: DatasetServiceStub
|
|
377
|
+
_data_pipelines_client: DataPipelinesServiceStub
|
|
239
378
|
_metadata: Mapping[str, str]
|
|
240
379
|
_channel: Channel
|
|
241
380
|
|
|
@@ -249,9 +388,8 @@ class DataClient:
|
|
|
249
388
|
include_internal_data: bool = False,
|
|
250
389
|
dest: Optional[str] = None,
|
|
251
390
|
) -> Tuple[List[TabularData], int, str]:
|
|
252
|
-
"""Filter and download tabular data. The data will be paginated into pages of
|
|
253
|
-
|
|
254
|
-
If the file is not empty, it will be overwritten.
|
|
391
|
+
"""Filter and download tabular data. The data will be paginated into pages of ``limit`` items; the returned tuple will include
|
|
392
|
+
the pagination ID. If a destination is provided, this method saves returned data to that file, overwriting any existing file content.
|
|
255
393
|
|
|
256
394
|
::
|
|
257
395
|
|
|
@@ -269,23 +407,23 @@ class DataClient:
|
|
|
269
407
|
print(f"My data: {my_data}")
|
|
270
408
|
|
|
271
409
|
Args:
|
|
272
|
-
filter (viam.proto.app.data.Filter): Optional
|
|
273
|
-
data.
|
|
410
|
+
filter (~viam.proto.app.data.Filter): Optional, specifies tabular data to retrieve. If missing, matches all tabular data.
|
|
274
411
|
limit (int): The maximum number of entries to include in a page. Defaults to 50 if unspecified.
|
|
275
|
-
sort_order (viam.proto.app.data.Order): The desired sort order of the data.
|
|
412
|
+
sort_order (~viam.proto.app.data.Order): The desired sort order of the data.
|
|
276
413
|
last (str): Optional string indicating the object identifier of the last-returned data.
|
|
277
|
-
|
|
278
|
-
|
|
414
|
+
Returned by calls to :class:`TabularDataByFilter` as the ``last`` value.
|
|
415
|
+
If provided, the server returns the next data entries after the last object identifier.
|
|
279
416
|
count_only (bool): Whether to return only the total count of entries.
|
|
280
417
|
include_internal_data (bool): Whether to return the internal data. Internal data is used for Viam-specific data ingestion,
|
|
281
|
-
|
|
418
|
+
like cloud SLAM. Defaults to ``False``.
|
|
282
419
|
dest (str): Optional filepath for writing retrieved data.
|
|
283
420
|
|
|
284
421
|
Returns:
|
|
285
422
|
Tuple[List[TabularData], int, str]: A tuple containing the following:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
423
|
+
|
|
424
|
+
- ``tabular_data`` (*List[TabularData]*): The tabular data.
|
|
425
|
+
- ``count`` (*int*): The count (number of entries).
|
|
426
|
+
- ``last`` (*str*): The last-returned page ID.
|
|
289
427
|
|
|
290
428
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#tabulardatabyfilter>`_.
|
|
291
429
|
"""
|
|
@@ -332,7 +470,7 @@ class DataClient:
|
|
|
332
470
|
|
|
333
471
|
Args:
|
|
334
472
|
organization_id (str): The ID of the organization that owns the data.
|
|
335
|
-
|
|
473
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
336
474
|
sql_query (str): The SQL query to run.
|
|
337
475
|
|
|
338
476
|
Returns:
|
|
@@ -346,7 +484,12 @@ class DataClient:
|
|
|
346
484
|
|
|
347
485
|
@_alias_param("query", param_alias="mql_binary")
|
|
348
486
|
async def tabular_data_by_mql(
|
|
349
|
-
self,
|
|
487
|
+
self,
|
|
488
|
+
organization_id: str,
|
|
489
|
+
query: Union[List[bytes], List[Dict[str, Any]]],
|
|
490
|
+
use_recent_data: Optional[bool] = None,
|
|
491
|
+
tabular_data_source_type: TabularDataSourceType.ValueType = TabularDataSourceType.TABULAR_DATA_SOURCE_TYPE_STANDARD,
|
|
492
|
+
pipeline_id: Optional[str] = None,
|
|
350
493
|
) -> List[Dict[str, Union[ValueTypes, datetime]]]:
|
|
351
494
|
"""Obtain unified tabular data and metadata, queried with MQL.
|
|
352
495
|
|
|
@@ -363,11 +506,16 @@ class DataClient:
|
|
|
363
506
|
|
|
364
507
|
Args:
|
|
365
508
|
organization_id (str): The ID of the organization that owns the data.
|
|
366
|
-
|
|
509
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
367
510
|
query (Union[List[bytes], List[Dict[str, Any]]]): The MQL query to run, as a list of MongoDB aggregation pipeline stages.
|
|
368
|
-
|
|
369
|
-
so
|
|
370
|
-
use_recent_data (bool): Whether to query blob storage or your recent data store. Defaults to
|
|
511
|
+
Each stage can be provided as either a dictionary or raw BSON bytes, but support for bytes will be removed in the
|
|
512
|
+
future, so prefer the dictionary option.
|
|
513
|
+
use_recent_data (bool): Whether to query blob storage or your recent data store. Defaults to ``False``..
|
|
514
|
+
Deprecated, use `tabular_data_source_type` instead.
|
|
515
|
+
tabular_data_source_type (viam.proto.app.data.TabularDataSourceType): The data source to query.
|
|
516
|
+
Defaults to `TABULAR_DATA_SOURCE_TYPE_STANDARD`.
|
|
517
|
+
pipeline_id (str): The ID of the data pipeline to query. Defaults to `None`.
|
|
518
|
+
Required if `tabular_data_source_type` is `TABULAR_DATA_SOURCE_TYPE_PIPELINE_SINK`.
|
|
371
519
|
|
|
372
520
|
Returns:
|
|
373
521
|
List[Dict[str, Union[ValueTypes, datetime]]]: An array of decoded BSON data objects.
|
|
@@ -375,7 +523,10 @@ class DataClient:
|
|
|
375
523
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#tabulardatabymql>`_.
|
|
376
524
|
"""
|
|
377
525
|
binary: List[bytes] = [bson.encode(query) for query in query] if isinstance(query[0], dict) else query # type: ignore
|
|
378
|
-
|
|
526
|
+
data_source = TabularDataSource(type=tabular_data_source_type, pipeline_id=pipeline_id)
|
|
527
|
+
if use_recent_data:
|
|
528
|
+
data_source.type = TabularDataSourceType.TABULAR_DATA_SOURCE_TYPE_HOT_STORAGE
|
|
529
|
+
request = TabularDataByMQLRequest(organization_id=organization_id, mql_binary=binary, data_source=data_source)
|
|
379
530
|
response: TabularDataByMQLResponse = await self._data_client.TabularDataByMQL(request, metadata=self._metadata)
|
|
380
531
|
return [bson.decode(bson_bytes) for bson_bytes in response.raw_data]
|
|
381
532
|
|
|
@@ -404,16 +555,19 @@ class DataClient:
|
|
|
404
555
|
|
|
405
556
|
Args:
|
|
406
557
|
part_id (str): The ID of the part that owns the data.
|
|
407
|
-
resource_name (str): The name of the requested resource that captured the data.
|
|
408
|
-
resource_api (str): The API of the requested resource that captured the data.
|
|
409
|
-
method_name (str): The data capture method name.
|
|
558
|
+
resource_name (str): The name of the requested resource that captured the data. For example, "my-sensor".
|
|
559
|
+
resource_api (str): The API of the requested resource that captured the data. For example, "rdk:component:sensor".
|
|
560
|
+
method_name (str): The data capture method name. For exampe, "Readings".
|
|
410
561
|
|
|
411
562
|
Returns:
|
|
412
|
-
Optional[Tuple[datetime, datetime, Dict[str, ValueTypes]]]:
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
563
|
+
Optional[Tuple[datetime, datetime, Dict[str, ValueTypes]]]:
|
|
564
|
+
A return value of ``None`` means that this data source
|
|
565
|
+
has not synced data in the last year. Otherwise, the data source has synced some data in the last year, so the returned
|
|
566
|
+
tuple contains the following:
|
|
567
|
+
|
|
568
|
+
- ``time_captured`` (*datetime*): The time captured.
|
|
569
|
+
- ``time_synced`` (*datetime*): The time synced.
|
|
570
|
+
- ``payload`` (*Dict[str, ValueTypes]*): The latest tabular data captured from the specified data source.
|
|
417
571
|
|
|
418
572
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#getlatesttabulardata>`_.
|
|
419
573
|
"""
|
|
@@ -501,9 +655,9 @@ class DataClient:
|
|
|
501
655
|
include_internal_data: bool = False,
|
|
502
656
|
dest: Optional[str] = None,
|
|
503
657
|
) -> Tuple[List[BinaryData], int, str]:
|
|
504
|
-
"""Filter and download binary data. The data will be paginated into pages of
|
|
505
|
-
in the returned tuple
|
|
506
|
-
|
|
658
|
+
"""Filter and download binary data. The data will be paginated into pages of ``limit`` items, and the pagination ID will be included
|
|
659
|
+
in the returned tuple as ``last``. If a destination is provided, this method saves returned data to that file,
|
|
660
|
+
overwriting any existing file content.
|
|
507
661
|
|
|
508
662
|
::
|
|
509
663
|
|
|
@@ -542,25 +696,25 @@ class DataClient:
|
|
|
542
696
|
my_untagged_data.extend(data)
|
|
543
697
|
|
|
544
698
|
Args:
|
|
545
|
-
filter (viam.proto.app.data.Filter): Optional
|
|
546
|
-
data.
|
|
699
|
+
filter (~viam.proto.app.data.Filter): Optional, specifies tabular data to retrieve. An empty filter matches all binary data.
|
|
547
700
|
limit (int): The maximum number of entries to include in a page. Defaults to 50 if unspecified.
|
|
548
|
-
sort_order (viam.proto.app.data.Order): The desired sort order of the data.
|
|
701
|
+
sort_order (~viam.proto.app.data.Order): The desired sort order of the data.
|
|
549
702
|
last (str): Optional string indicating the object identifier of the last-returned data.
|
|
550
|
-
|
|
551
|
-
|
|
703
|
+
This object identifier is returned by calls to :meth:`binary_data_by_filter` as the ``last`` value.
|
|
704
|
+
If provided, the server will return the next data entries after the last object identifier.
|
|
552
705
|
include_binary_data (bool): Boolean specifying whether to actually include the binary file data with each retrieved file.
|
|
553
|
-
|
|
706
|
+
Defaults to true (that is, both the files' data and metadata are returned).
|
|
554
707
|
count_only (bool): Whether to return only the total count of entries.
|
|
555
708
|
include_internal_data (bool): Whether to return the internal data. Internal data is used for Viam-specific data ingestion,
|
|
556
|
-
|
|
709
|
+
like cloud SLAM. Defaults to ``False``.
|
|
557
710
|
dest (str): Optional filepath for writing retrieved data.
|
|
558
711
|
|
|
559
712
|
Returns:
|
|
560
|
-
Tuple[List[viam.proto.app.data.BinaryData], int, str]: A tuple containing the following:
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
713
|
+
Tuple[List[~viam.proto.app.data.BinaryData], int, str]: A tuple containing the following:
|
|
714
|
+
|
|
715
|
+
- ``data`` (*List[* :class:`~viam.proto.app.data.BinaryData` *]*): The binary data.
|
|
716
|
+
- ``count`` (*int*): The count (number of entries).
|
|
717
|
+
- ``last`` (*str*): The last-returned page ID.
|
|
564
718
|
|
|
565
719
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#binarydatabyfilter>`_.
|
|
566
720
|
"""
|
|
@@ -611,15 +765,17 @@ class DataClient:
|
|
|
611
765
|
binary_data = await data_client.binary_data_by_ids(my_ids)
|
|
612
766
|
|
|
613
767
|
Args:
|
|
614
|
-
binary_ids (Union[List[BinaryID], List[str]]): Binary data
|
|
615
|
-
|
|
768
|
+
binary_ids (Union[List[~viam.proto.app.data.BinaryID], List[str]]): Binary data ID strings specifying the desired data or
|
|
769
|
+
:class:`BinaryID` objects. Must be non-empty.
|
|
770
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
771
|
+
list of strings.*
|
|
616
772
|
dest (str): Optional filepath for writing retrieved data.
|
|
617
773
|
|
|
618
774
|
Raises:
|
|
619
|
-
GRPCError: If no binary data
|
|
775
|
+
GRPCError: If no binary data ID strings or :class:`BinaryID` objects are provided.
|
|
620
776
|
|
|
621
777
|
Returns:
|
|
622
|
-
List[viam.proto.app.data.BinaryData]: The binary data.
|
|
778
|
+
List[~viam.proto.app.data.BinaryData]: The binary data.
|
|
623
779
|
|
|
624
780
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#binarydatabyids>`_.
|
|
625
781
|
"""
|
|
@@ -651,10 +807,10 @@ class DataClient:
|
|
|
651
807
|
)
|
|
652
808
|
|
|
653
809
|
Args:
|
|
654
|
-
organization_id (str): ID of organization to delete data from.
|
|
655
|
-
|
|
656
|
-
delete_older_than_days (int): Delete data that was captured up to this many days ago. For example
|
|
657
|
-
|
|
810
|
+
organization_id (str): The ID of the organization to delete the data from.
|
|
811
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
812
|
+
delete_older_than_days (int): Delete data that was captured up to *this many* days ago. For example, a value of
|
|
813
|
+
10 deletes any data that was captured up to 10 days ago. A value of 0 deletes *all* existing data.
|
|
658
814
|
|
|
659
815
|
Returns:
|
|
660
816
|
int: The number of items deleted.
|
|
@@ -666,7 +822,7 @@ class DataClient:
|
|
|
666
822
|
return response.deleted_count
|
|
667
823
|
|
|
668
824
|
async def delete_tabular_data_by_filter(self, filter: Optional[Filter]) -> int:
|
|
669
|
-
"""Deprecated: use delete_tabular_data instead."""
|
|
825
|
+
"""Deprecated: use :meth:`delete_tabular_data` instead."""
|
|
670
826
|
raise NotImplementedError()
|
|
671
827
|
|
|
672
828
|
async def delete_binary_data_by_filter(self, filter: Optional[Filter]) -> int:
|
|
@@ -681,9 +837,10 @@ class DataClient:
|
|
|
681
837
|
res = await data_client.delete_binary_data_by_filter(my_filter)
|
|
682
838
|
|
|
683
839
|
Args:
|
|
684
|
-
filter (viam.proto.app.data.Filter): Optional
|
|
685
|
-
|
|
686
|
-
|
|
840
|
+
filter (~viam.proto.app.data.Filter): Optional, specifies binary data to delete.
|
|
841
|
+
**CAUTION: Passing an empty** ``Filter`` **deletes all binary data!**
|
|
842
|
+
You must specify an organization ID with ``organization_ids`` when using this option.
|
|
843
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
687
844
|
|
|
688
845
|
Returns:
|
|
689
846
|
int: The number of items deleted.
|
|
@@ -720,13 +877,13 @@ class DataClient:
|
|
|
720
877
|
binary_data = await data_client.delete_binary_data_by_ids(my_ids)
|
|
721
878
|
|
|
722
879
|
Args:
|
|
723
|
-
binary_ids (Union[List[BinaryID], List[str]]): Binary data
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
880
|
+
binary_ids (Union[List[~viam.proto.app.data.BinaryID], List[str]]): Binary data ID strings specifying the data to be deleted or
|
|
881
|
+
:class:`BinaryID` objects. Must be non-empty.
|
|
882
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
883
|
+
list of strings.*
|
|
727
884
|
|
|
728
885
|
Raises:
|
|
729
|
-
GRPCError: If no binary data
|
|
886
|
+
GRPCError: If no binary data ID strings or :class:`BinaryID` objects are provided.
|
|
730
887
|
|
|
731
888
|
Returns:
|
|
732
889
|
int: The number of items deleted.
|
|
@@ -770,13 +927,13 @@ class DataClient:
|
|
|
770
927
|
|
|
771
928
|
Args:
|
|
772
929
|
tags (List[str]): List of tags to add to specified binary data. Must be non-empty.
|
|
773
|
-
binary_ids (Union[List[BinaryID], List[str]]): Binary data
|
|
774
|
-
Must be non-empty.
|
|
775
|
-
|
|
776
|
-
|
|
930
|
+
binary_ids (Union[List[~viam.proto.app.data.BinaryID], List[str]]): Binary data ID strings specifying the data to be tagged or
|
|
931
|
+
:class:`BinaryID` objects. Must be non-empty.
|
|
932
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
933
|
+
list of strings.*
|
|
777
934
|
|
|
778
935
|
Raises:
|
|
779
|
-
GRPCError: If no binary data
|
|
936
|
+
GRPCError: If no binary data ID strings or :class:`BinaryID` objects are provided.
|
|
780
937
|
|
|
781
938
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#addtagstobinarydatabyids>`_.
|
|
782
939
|
"""
|
|
@@ -802,8 +959,7 @@ class DataClient:
|
|
|
802
959
|
|
|
803
960
|
Args:
|
|
804
961
|
tags (List[str]): List of tags to add to specified binary data. Must be non-empty.
|
|
805
|
-
filter (viam.proto.app.data.Filter):
|
|
806
|
-
tagged.
|
|
962
|
+
filter (~viam.proto.app.data.Filter): Specifies binary data to tag. If none is provided, tags all data.
|
|
807
963
|
|
|
808
964
|
Raises:
|
|
809
965
|
GRPCError: If no tags are provided.
|
|
@@ -843,13 +999,13 @@ class DataClient:
|
|
|
843
999
|
|
|
844
1000
|
Args:
|
|
845
1001
|
tags (List[str]): List of tags to remove from specified binary data. Must be non-empty.
|
|
846
|
-
binary_ids (Union[List[BinaryID], List[str]]): Binary data
|
|
847
|
-
Must be non-empty.
|
|
848
|
-
|
|
849
|
-
|
|
1002
|
+
binary_ids (Union[List[~viam.proto.app.data.BinaryID], List[str]]): Binary data ID strings specifying the data to be untagged
|
|
1003
|
+
or `BinaryID` objects. Must be non-empty.
|
|
1004
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
1005
|
+
list of strings.*
|
|
850
1006
|
|
|
851
1007
|
Raises:
|
|
852
|
-
GRPCError: If no
|
|
1008
|
+
GRPCError: If no binary data ID strings, :class:`BinaryID` objects, or tags are provided.
|
|
853
1009
|
|
|
854
1010
|
Returns:
|
|
855
1011
|
int: The number of tags removed.
|
|
@@ -881,8 +1037,7 @@ class DataClient:
|
|
|
881
1037
|
|
|
882
1038
|
Args:
|
|
883
1039
|
tags (List[str]): List of tags to remove from specified binary data.
|
|
884
|
-
filter (viam.proto.app.data.Filter):
|
|
885
|
-
untagged.
|
|
1040
|
+
filter (~viam.proto.app.data.Filter): Specifies binary data to untag. If none is provided, removes tags from all data.
|
|
886
1041
|
|
|
887
1042
|
Raises:
|
|
888
1043
|
GRPCError: If no tags are provided.
|
|
@@ -910,8 +1065,7 @@ class DataClient:
|
|
|
910
1065
|
tags = await data_client.tags_by_filter(my_filter)
|
|
911
1066
|
|
|
912
1067
|
Args:
|
|
913
|
-
filter (viam.proto.app.data.Filter):
|
|
914
|
-
return.
|
|
1068
|
+
filter (~viam.proto.app.data.Filter): Specifies subset ofdata to retrieve tags from. If none is provided, returns all tags.
|
|
915
1069
|
|
|
916
1070
|
Returns:
|
|
917
1071
|
List[str]: The list of tags.
|
|
@@ -948,9 +1102,9 @@ class DataClient:
|
|
|
948
1102
|
print(bbox_id)
|
|
949
1103
|
|
|
950
1104
|
Args:
|
|
951
|
-
binary_id (Union[viam.proto.app.data.BinaryID, str]): The binary data
|
|
952
|
-
|
|
953
|
-
|
|
1105
|
+
binary_id (Union[~viam.proto.app.data.BinaryID, str]): The binary data ID or :class:`BinaryID` of the image to add the bounding
|
|
1106
|
+
box to. *DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data
|
|
1107
|
+
IDs as a list of strings.*
|
|
954
1108
|
label (str): A label for the bounding box.
|
|
955
1109
|
x_min_normalized (float): Min X value of the bounding box normalized from 0 to 1.
|
|
956
1110
|
y_min_normalized (float): Min Y value of the bounding box normalized from 0 to 1.
|
|
@@ -999,10 +1153,10 @@ class DataClient:
|
|
|
999
1153
|
|
|
1000
1154
|
Args:
|
|
1001
1155
|
bbox_id (str): The ID of the bounding box to remove.
|
|
1002
|
-
binary_id (Union[viam.proto.app.data.BinaryID, str]): The binary data
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1156
|
+
binary_id (Union[~viam.proto.app.data.BinaryID, str]): The binary data ID or :class:`BinaryID` of the image to remove the
|
|
1157
|
+
bounding box from.
|
|
1158
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
1159
|
+
list of strings.*
|
|
1006
1160
|
|
|
1007
1161
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#removeboundingboxfromimagebyid>`_.
|
|
1008
1162
|
"""
|
|
@@ -1028,8 +1182,8 @@ class DataClient:
|
|
|
1028
1182
|
print(bounding_box_labels)
|
|
1029
1183
|
|
|
1030
1184
|
Args:
|
|
1031
|
-
filter (viam.proto.app.data.Filter):
|
|
1032
|
-
|
|
1185
|
+
filter (~viam.proto.app.data.Filter): Specifies data to retrieve bounding box labels from. If none is provided, returns labels
|
|
1186
|
+
from all data.
|
|
1033
1187
|
|
|
1034
1188
|
Returns:
|
|
1035
1189
|
List[str]: The list of bounding box labels.
|
|
@@ -1049,8 +1203,8 @@ class DataClient:
|
|
|
1049
1203
|
hostname = await data_client.get_database_connection(organization_id="<YOUR-ORG-ID>")
|
|
1050
1204
|
|
|
1051
1205
|
Args:
|
|
1052
|
-
organization_id (str):
|
|
1053
|
-
|
|
1206
|
+
organization_id (str): The ID of the organization you'd like to connect to.
|
|
1207
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
1054
1208
|
|
|
1055
1209
|
Returns:
|
|
1056
1210
|
str: The hostname of the federated database.
|
|
@@ -1073,8 +1227,8 @@ class DataClient:
|
|
|
1073
1227
|
)
|
|
1074
1228
|
|
|
1075
1229
|
Args:
|
|
1076
|
-
organization_id (str): The ID of the organization.
|
|
1077
|
-
|
|
1230
|
+
organization_id (str): The ID of the organization you'd like to configure a database user for.
|
|
1231
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
1078
1232
|
password (str): The password of the user.
|
|
1079
1233
|
|
|
1080
1234
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#configuredatabaseuser>`_.
|
|
@@ -1096,7 +1250,7 @@ class DataClient:
|
|
|
1096
1250
|
Args:
|
|
1097
1251
|
name (str): The name of the dataset being created.
|
|
1098
1252
|
organization_id (str): The ID of the organization where the dataset is being created.
|
|
1099
|
-
|
|
1253
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
1100
1254
|
|
|
1101
1255
|
Returns:
|
|
1102
1256
|
str: The dataset ID of the created dataset.
|
|
@@ -1118,9 +1272,12 @@ class DataClient:
|
|
|
1118
1272
|
print(datasets)
|
|
1119
1273
|
|
|
1120
1274
|
Args:
|
|
1121
|
-
ids (List[str]): The IDs of the datasets
|
|
1122
|
-
|
|
1123
|
-
|
|
1275
|
+
ids (List[str]): The IDs of the datasets that you would like to retrieve information about. To retrieve a dataset ID:
|
|
1276
|
+
|
|
1277
|
+
- Navigate to the **DATASETS** tab of the **DATA** page.
|
|
1278
|
+
- Click on the dataset.
|
|
1279
|
+
- Click the **...** menu.
|
|
1280
|
+
- Select **Copy dataset ID**.
|
|
1124
1281
|
|
|
1125
1282
|
Returns:
|
|
1126
1283
|
Sequence[Dataset]: The list of datasets.
|
|
@@ -1143,8 +1300,8 @@ class DataClient:
|
|
|
1143
1300
|
print(datasets)
|
|
1144
1301
|
|
|
1145
1302
|
Args:
|
|
1146
|
-
organization_id (str): The ID of the organization.
|
|
1147
|
-
|
|
1303
|
+
organization_id (str): The ID of the organization you'd like to retrieve datasets from.
|
|
1304
|
+
To find your organization ID, visit the organization settings page in the Viam app.
|
|
1148
1305
|
|
|
1149
1306
|
Returns:
|
|
1150
1307
|
Sequence[Dataset]: The list of datasets in the organization.
|
|
@@ -1169,8 +1326,12 @@ class DataClient:
|
|
|
1169
1326
|
)
|
|
1170
1327
|
|
|
1171
1328
|
Args:
|
|
1172
|
-
id (str): The ID of the dataset.
|
|
1173
|
-
|
|
1329
|
+
id (str): The ID of the dataset. To retrieve the dataset ID:
|
|
1330
|
+
|
|
1331
|
+
- Navigate to the **DATASETS** tab of the **DATA** page.
|
|
1332
|
+
- Click on the dataset.
|
|
1333
|
+
- Click the **...** menu.
|
|
1334
|
+
- Select **Copy dataset ID**.
|
|
1174
1335
|
name (str): The new name of the dataset.
|
|
1175
1336
|
|
|
1176
1337
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#renamedataset>`_.
|
|
@@ -1188,8 +1349,12 @@ class DataClient:
|
|
|
1188
1349
|
)
|
|
1189
1350
|
|
|
1190
1351
|
Args:
|
|
1191
|
-
id (str): The ID of the dataset.
|
|
1192
|
-
|
|
1352
|
+
id (str): The ID of the dataset. To retrieve the dataset ID:
|
|
1353
|
+
|
|
1354
|
+
- Navigate to the **DATASETS** tab of the **DATA** page.
|
|
1355
|
+
- Click on the dataset.
|
|
1356
|
+
- Click the **...** menu.
|
|
1357
|
+
- Select **Copy dataset ID**.
|
|
1193
1358
|
|
|
1194
1359
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#deletedataset>`_.
|
|
1195
1360
|
"""
|
|
@@ -1207,24 +1372,27 @@ class DataClient:
|
|
|
1207
1372
|
include_binary_data=False
|
|
1208
1373
|
)
|
|
1209
1374
|
|
|
1210
|
-
|
|
1375
|
+
my_binary_data_ids = []
|
|
1211
1376
|
|
|
1212
1377
|
for obj in binary_metadata:
|
|
1213
|
-
|
|
1378
|
+
my_binary_data_ids.append(
|
|
1214
1379
|
obj.metadata.binary_data_id
|
|
1215
1380
|
)
|
|
1216
1381
|
|
|
1217
1382
|
await data_client.add_binary_data_to_dataset_by_ids(
|
|
1218
|
-
binary_ids=
|
|
1383
|
+
binary_ids=my_binary_data_ids,
|
|
1219
1384
|
dataset_id="abcd-1234xyz-8765z-123abc"
|
|
1220
1385
|
)
|
|
1221
1386
|
|
|
1222
1387
|
Args:
|
|
1223
|
-
binary_ids (List[BinaryID]):
|
|
1224
|
-
navigate to
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1388
|
+
binary_ids (List[~viam.proto.app.data.BinaryID]): Unique identifiers for binary data to add to the dataset. To retrieve these IDs,
|
|
1389
|
+
navigate to the DATA page, click on an image, and copy its Binary Data ID from the details tab.
|
|
1390
|
+
dataset_id (str): The ID of the dataset to be added to. To retrieve the dataset ID:
|
|
1391
|
+
|
|
1392
|
+
- Navigate to the **DATASETS** tab of the **DATA** page.
|
|
1393
|
+
- Click on the dataset.
|
|
1394
|
+
- Click the **...** menu.
|
|
1395
|
+
- Select **Copy dataset ID**.
|
|
1228
1396
|
|
|
1229
1397
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#addbinarydatatodatasetbyids>`_.
|
|
1230
1398
|
"""
|
|
@@ -1248,26 +1416,29 @@ class DataClient:
|
|
|
1248
1416
|
include_binary_data=False
|
|
1249
1417
|
)
|
|
1250
1418
|
|
|
1251
|
-
|
|
1419
|
+
my_binary_data_ids = []
|
|
1252
1420
|
|
|
1253
1421
|
for obj in binary_metadata:
|
|
1254
|
-
|
|
1422
|
+
my_binary_data_ids.append(
|
|
1255
1423
|
obj.metadata.binary_data_id
|
|
1256
1424
|
)
|
|
1257
1425
|
|
|
1258
1426
|
await data_client.remove_binary_data_from_dataset_by_ids(
|
|
1259
|
-
binary_ids=
|
|
1427
|
+
binary_ids=my_binary_data_ids,
|
|
1260
1428
|
dataset_id="abcd-1234xyz-8765z-123abc"
|
|
1261
1429
|
)
|
|
1262
1430
|
|
|
1263
1431
|
Args:
|
|
1264
|
-
binary_ids (Union[List[BinaryID], List[str]]):
|
|
1265
|
-
navigate to
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1432
|
+
binary_ids (Union[List[~viam.proto.app.data.BinaryID], List[str]]): Unique identifiers for the binary data to remove from the dataset. To retrieve these IDs,
|
|
1433
|
+
navigate to the DATA page, click on an image and copy its Binary Data ID from the details tab.
|
|
1434
|
+
*DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
|
|
1435
|
+
list of strings.*
|
|
1436
|
+
dataset_id (str): The ID of the dataset to be removed from. To retrieve the dataset ID:
|
|
1437
|
+
|
|
1438
|
+
- Navigate to the **DATASETS** tab of the **DATA** page.
|
|
1439
|
+
- Click on the dataset.
|
|
1440
|
+
- Click the **...** menu.
|
|
1441
|
+
- Select **Copy dataset ID**.
|
|
1271
1442
|
|
|
1272
1443
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#removebinarydatafromdatasetbyids>`_.
|
|
1273
1444
|
"""
|
|
@@ -1294,8 +1465,8 @@ class DataClient:
|
|
|
1294
1465
|
) -> str:
|
|
1295
1466
|
"""Upload binary sensor data.
|
|
1296
1467
|
|
|
1297
|
-
Upload binary data collected on a robot through a specific component (for example, a motor) along with the relevant metadata
|
|
1298
|
-
|
|
1468
|
+
Upload binary data collected on a robot through a specific component (for example, a motor), along with the relevant metadata.
|
|
1469
|
+
Binary data can be found on the **DATA** page of the Viam app.
|
|
1299
1470
|
|
|
1300
1471
|
::
|
|
1301
1472
|
|
|
@@ -1320,19 +1491,19 @@ class DataClient:
|
|
|
1320
1491
|
component_type (str): Type of the component used to capture the data (for example, "movement_sensor").
|
|
1321
1492
|
component_name (str): Name of the component used to capture the data.
|
|
1322
1493
|
method_name (str): Name of the method used to capture the data.
|
|
1323
|
-
file_extension (str): The file extension of binary data including the period
|
|
1324
|
-
The backend
|
|
1325
|
-
or
|
|
1494
|
+
file_extension (str): The file extension of binary data, *including the period*, for example ``.jpg``, ``.png``, ``.pcd``.
|
|
1495
|
+
The backend routes the binary to its corresponding mime type based on this extension. Files with a ``.jpeg``, ``.jpg``,
|
|
1496
|
+
or ``.png`` extension will appear in the **Images** tab.
|
|
1326
1497
|
method_parameters (Optional[Mapping[str, Any]]): Optional dictionary of method parameters. No longer in active use.
|
|
1327
1498
|
tags (Optional[List[str]]): Optional list of tags to allow for tag-based data filtering when retrieving data.
|
|
1328
1499
|
data_request_times (Optional[Tuple[datetime.datetime, datetime.datetime]]): Optional tuple containing datetime objects
|
|
1329
|
-
denoting the times this data was requested[0] by the robot and received[1] from the appropriate sensor.
|
|
1500
|
+
denoting the times this data was requested ``[0]`` by the robot and received ``[1]`` from the appropriate sensor.
|
|
1330
1501
|
|
|
1331
1502
|
Raises:
|
|
1332
1503
|
GRPCError: If an invalid part ID is passed.
|
|
1333
1504
|
|
|
1334
1505
|
Returns:
|
|
1335
|
-
str: The
|
|
1506
|
+
str: The binary data ID of the uploaded data.
|
|
1336
1507
|
|
|
1337
1508
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#binarydatacaptureupload>`_.
|
|
1338
1509
|
"""
|
|
@@ -1375,8 +1546,8 @@ class DataClient:
|
|
|
1375
1546
|
) -> str:
|
|
1376
1547
|
"""Upload tabular sensor data.
|
|
1377
1548
|
|
|
1378
|
-
Upload tabular data collected on a robot through a specific component (for example, a motor) along with the relevant metadata
|
|
1379
|
-
|
|
1549
|
+
Upload tabular data collected on a robot through a specific component (for example, a motor), along with the relevant metadata.
|
|
1550
|
+
Tabular data can be found under the **Sensors** tab of the **DATA** page.
|
|
1380
1551
|
|
|
1381
1552
|
::
|
|
1382
1553
|
|
|
@@ -1401,24 +1572,24 @@ class DataClient:
|
|
|
1401
1572
|
|
|
1402
1573
|
Args:
|
|
1403
1574
|
tabular_data (List[Mapping[str, Any]]): List of the data to be uploaded, represented tabularly as a collection of dictionaries.
|
|
1404
|
-
Must include the key
|
|
1575
|
+
Must include the key ``readings`` for sensors.
|
|
1405
1576
|
part_id (str): Part ID of the component used to capture the data.
|
|
1406
|
-
component_type (str): Type of the component used to capture the data (for example,
|
|
1577
|
+
component_type (str): Type of the component used to capture the data (for example, ``rdk:component:movement_sensor``).
|
|
1407
1578
|
component_name (str): Name of the component used to capture the data.
|
|
1408
1579
|
method_name (str): Name of the method used to capture the data.
|
|
1409
|
-
data_request_times (List[Tuple[datetime.datetime, datetime.datetime]]): List of tuples, each containing
|
|
1410
|
-
denoting the times this data was requested[0] by the robot and received[1] from the appropriate sensor.
|
|
1411
|
-
tabular data and
|
|
1580
|
+
data_request_times (List[Tuple[datetime.datetime, datetime.datetime]]): List of tuples, each containing ``datetime`` objects
|
|
1581
|
+
denoting the times this data was requested ``[0]`` by the robot and received ``[1]`` from the appropriate sensor.
|
|
1582
|
+
Pass a list of tabular data and timestamps with length ``n > 1`` to upload ``n`` datapoints, all with the same metadata.
|
|
1412
1583
|
method_parameters (Optional[Mapping[str, Any]]): Optional dictionary of method parameters. No longer in active use.
|
|
1413
1584
|
tags (Optional[List[str]]): Optional list of tags to allow for tag-based data filtering when retrieving data.
|
|
1414
1585
|
|
|
1415
1586
|
Raises:
|
|
1416
1587
|
GRPCError: If an invalid part ID is passed.
|
|
1417
|
-
ValueError: If
|
|
1588
|
+
ValueError: If the provided list of `Timestamp` objects has a length that does not match the length of the list of tabular
|
|
1418
1589
|
data.
|
|
1419
1590
|
|
|
1420
1591
|
Returns:
|
|
1421
|
-
str: The
|
|
1592
|
+
str: The file ID of the uploaded data.
|
|
1422
1593
|
|
|
1423
1594
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#tabulardatacaptureupload>`_.
|
|
1424
1595
|
"""
|
|
@@ -1493,22 +1664,22 @@ class DataClient:
|
|
|
1493
1664
|
)
|
|
1494
1665
|
|
|
1495
1666
|
Args:
|
|
1496
|
-
data (bytes):
|
|
1667
|
+
data (bytes): The data to be uploaded.
|
|
1497
1668
|
part_id (str): Part ID of the resource associated with the file.
|
|
1498
|
-
file_ext (str):
|
|
1669
|
+
file_ext (str): File extension type for the data. required for determining MIME type.
|
|
1499
1670
|
component_type (Optional[str]): Optional type of the component associated with the file (for example, "movement_sensor").
|
|
1500
1671
|
component_name (Optional[str]): Optional name of the component associated with the file.
|
|
1501
1672
|
method_name (Optional[str]): Optional name of the method associated with the file.
|
|
1502
1673
|
method_parameters (Optional[str]): Optional dictionary of the method parameters. No longer in active use.
|
|
1503
1674
|
data_request_times (Optional[Tuple[datetime.datetime, datetime.datetime]]): Optional tuple containing datetime objects
|
|
1504
|
-
denoting the times this data was requested[0] by the robot and received[1] from the appropriate sensor.
|
|
1675
|
+
denoting the times this data was requested ``[0]`` by the robot and received ``[1]`` from the appropriate sensor.
|
|
1505
1676
|
tags (Optional[List[str]]): Optional list of tags to allow for tag-based filtering when retrieving data.
|
|
1506
1677
|
|
|
1507
1678
|
Raises:
|
|
1508
1679
|
GRPCError: If an invalid part ID is passed.
|
|
1509
1680
|
|
|
1510
1681
|
Returns:
|
|
1511
|
-
str: The
|
|
1682
|
+
str: The binary data ID of the uploaded data.
|
|
1512
1683
|
|
|
1513
1684
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#streamingdatacaptureupload>`_.
|
|
1514
1685
|
"""
|
|
@@ -1553,8 +1724,8 @@ class DataClient:
|
|
|
1553
1724
|
) -> str:
|
|
1554
1725
|
"""Upload arbitrary file data.
|
|
1555
1726
|
|
|
1556
|
-
Upload file data that may be stored on a robot along with the relevant metadata
|
|
1557
|
-
|
|
1727
|
+
Upload file data that may be stored on a robot along with the relevant metadata. File data can be found in the
|
|
1728
|
+
**Files** tab of the **DATA** page.
|
|
1558
1729
|
|
|
1559
1730
|
::
|
|
1560
1731
|
|
|
@@ -1572,18 +1743,18 @@ class DataClient:
|
|
|
1572
1743
|
component_type (Optional[str]): Optional type of the component associated with the file (for example, "movement_sensor").
|
|
1573
1744
|
component_name (Optional[str]): Optional name of the component associated with the file.
|
|
1574
1745
|
method_name (Optional[str]): Optional name of the method associated with the file.
|
|
1575
|
-
file_name (Optional[str]): Optional name of the file. The empty string "" will be assigned as the file name if one isn't
|
|
1746
|
+
file_name (Optional[str]): Optional name of the file. The empty string ``""`` will be assigned as the file name if one isn't
|
|
1576
1747
|
provided.
|
|
1577
1748
|
method_parameters (Optional[str]): Optional dictionary of the method parameters. No longer in active use.
|
|
1578
|
-
file_extension (Optional[str]): Optional file extension. The empty string "" will be assigned as the file extension if one
|
|
1579
|
-
provided. Files with a
|
|
1749
|
+
file_extension (Optional[str]): Optional file extension. The empty string ``""`` will be assigned as the file extension if one
|
|
1750
|
+
isn't provided. Files with a ``.jpeg``, ``.jpg``, or ``.png`` extension will be saved to the **Images** tab.
|
|
1580
1751
|
tags (Optional[List[str]]): Optional list of tags to allow for tag-based filtering when retrieving data.
|
|
1581
1752
|
|
|
1582
1753
|
Raises:
|
|
1583
1754
|
GRPCError: If an invalid part ID is passed.
|
|
1584
1755
|
|
|
1585
1756
|
Returns:
|
|
1586
|
-
str: ID of the new file.
|
|
1757
|
+
str: Binary data ID of the new file.
|
|
1587
1758
|
|
|
1588
1759
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#fileupload>`_.
|
|
1589
1760
|
"""
|
|
@@ -1613,8 +1784,8 @@ class DataClient:
|
|
|
1613
1784
|
) -> str:
|
|
1614
1785
|
"""Upload arbitrary file data.
|
|
1615
1786
|
|
|
1616
|
-
Upload file data that may be stored on a robot along with the relevant metadata
|
|
1617
|
-
|
|
1787
|
+
Upload file data that may be stored on a robot along with the relevant metadata. File data can be found in the
|
|
1788
|
+
**Files** tab of the **DATA** page.
|
|
1618
1789
|
|
|
1619
1790
|
::
|
|
1620
1791
|
|
|
@@ -1639,7 +1810,7 @@ class DataClient:
|
|
|
1639
1810
|
FileNotFoundError: If the provided filepath is not found.
|
|
1640
1811
|
|
|
1641
1812
|
Returns:
|
|
1642
|
-
str: ID of the new file.
|
|
1813
|
+
str: Binary data ID of the new file.
|
|
1643
1814
|
|
|
1644
1815
|
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#fileuploadfrompath>`_.
|
|
1645
1816
|
"""
|
|
@@ -1677,6 +1848,115 @@ class DataClient:
|
|
|
1677
1848
|
raise TypeError("Response cannot be empty")
|
|
1678
1849
|
return response
|
|
1679
1850
|
|
|
1851
|
+
async def get_data_pipeline(self, id: str) -> DataPipeline:
|
|
1852
|
+
"""Get a data pipeline by its ID.
|
|
1853
|
+
|
|
1854
|
+
::
|
|
1855
|
+
|
|
1856
|
+
data_pipeline = await data_client.get_data_pipeline(id="<YOUR-DATA-PIPELINE-ID>")
|
|
1857
|
+
|
|
1858
|
+
Args:
|
|
1859
|
+
id (str): The ID of the data pipeline to get.
|
|
1860
|
+
|
|
1861
|
+
Returns:
|
|
1862
|
+
DataPipeline: The data pipeline with the given ID.
|
|
1863
|
+
"""
|
|
1864
|
+
request = GetDataPipelineRequest(id=id)
|
|
1865
|
+
response: GetDataPipelineResponse = await self._data_pipelines_client.GetDataPipeline(request, metadata=self._metadata)
|
|
1866
|
+
return DataClient.DataPipeline.from_proto(response.data_pipeline)
|
|
1867
|
+
|
|
1868
|
+
async def list_data_pipelines(self, organization_id: str) -> List[DataPipeline]:
|
|
1869
|
+
"""List all of the data pipelines for an organization.
|
|
1870
|
+
|
|
1871
|
+
::
|
|
1872
|
+
|
|
1873
|
+
data_pipelines = await data_client.list_data_pipelines(organization_id="<YOUR-ORGANIZATION-ID>")
|
|
1874
|
+
|
|
1875
|
+
Args:
|
|
1876
|
+
organization_id (str): The ID of the organization that owns the pipelines.
|
|
1877
|
+
You can obtain your organization ID from the Viam app's organization settings page.
|
|
1878
|
+
|
|
1879
|
+
Returns:
|
|
1880
|
+
List[DataPipeline]: A list of all of the data pipelines for the given organization.
|
|
1881
|
+
"""
|
|
1882
|
+
request = ListDataPipelinesRequest(organization_id=organization_id)
|
|
1883
|
+
response: ListDataPipelinesResponse = await self._data_pipelines_client.ListDataPipelines(request, metadata=self._metadata)
|
|
1884
|
+
return [DataClient.DataPipeline.from_proto(pipeline) for pipeline in response.data_pipelines]
|
|
1885
|
+
|
|
1886
|
+
async def create_data_pipeline(self, organization_id: str, name: str, mql_binary: List[Dict[str, Any]], schedule: str) -> str:
|
|
1887
|
+
"""Create a new data pipeline.
|
|
1888
|
+
|
|
1889
|
+
::
|
|
1890
|
+
|
|
1891
|
+
data_pipeline_id = await data_client.create_data_pipeline(
|
|
1892
|
+
organization_id="<YOUR-ORGANIZATION-ID>",
|
|
1893
|
+
name="<YOUR-PIPELINE-NAME>",
|
|
1894
|
+
mql_binary=[<YOUR-MQL-PIPELINE-AGGREGATION>],
|
|
1895
|
+
schedule="<YOUR-SCHEDULE>"
|
|
1896
|
+
)
|
|
1897
|
+
|
|
1898
|
+
Args:
|
|
1899
|
+
organization_id (str): The ID of the organization that will own the pipeline.
|
|
1900
|
+
You can obtain your organization ID from the Viam app's organization settings page.
|
|
1901
|
+
name (str): The name of the pipeline.
|
|
1902
|
+
mql_binary (List[Dict[str, Any]]):The MQL pipeline to run, as a list of MongoDB aggregation pipeline stages.
|
|
1903
|
+
schedule (str): A cron expression representing the expected execution schedule in UTC (note this also
|
|
1904
|
+
defines the input time window; an hourly schedule would process 1 hour of data at a time).
|
|
1905
|
+
|
|
1906
|
+
Returns:
|
|
1907
|
+
str: The ID of the newly created pipeline.
|
|
1908
|
+
"""
|
|
1909
|
+
binary: List[bytes] = [bson.encode(query) for query in mql_binary]
|
|
1910
|
+
request = CreateDataPipelineRequest(organization_id=organization_id, name=name, mql_binary=binary, schedule=schedule)
|
|
1911
|
+
response: CreateDataPipelineResponse = await self._data_pipelines_client.CreateDataPipeline(request, metadata=self._metadata)
|
|
1912
|
+
return response.id
|
|
1913
|
+
|
|
1914
|
+
async def delete_data_pipeline(self, id: str) -> None:
|
|
1915
|
+
"""Delete a data pipeline by its ID.
|
|
1916
|
+
|
|
1917
|
+
::
|
|
1918
|
+
|
|
1919
|
+
await data_client.delete_data_pipeline(id="<YOUR-DATA-PIPELINE-ID>")
|
|
1920
|
+
|
|
1921
|
+
Args:
|
|
1922
|
+
id (str): The ID of the data pipeline to delete.
|
|
1923
|
+
"""
|
|
1924
|
+
request = DeleteDataPipelineRequest(id=id)
|
|
1925
|
+
await self._data_pipelines_client.DeleteDataPipeline(request, metadata=self._metadata)
|
|
1926
|
+
|
|
1927
|
+
async def list_data_pipeline_runs(self, id: str, page_size: int = 10) -> DataPipelineRunsPage:
|
|
1928
|
+
"""List all of the data pipeline runs for a data pipeline.
|
|
1929
|
+
|
|
1930
|
+
::
|
|
1931
|
+
|
|
1932
|
+
data_pipeline_runs = await data_client.list_data_pipeline_runs(id="<YOUR-DATA-PIPELINE-ID>")
|
|
1933
|
+
while len(data_pipeline_runs.runs) > 0:
|
|
1934
|
+
data_pipeline_runs = await data_pipeline_runs.next_page()
|
|
1935
|
+
|
|
1936
|
+
Args:
|
|
1937
|
+
id (str): The ID of the pipeline to list runs for
|
|
1938
|
+
page_size (int): The number of runs to return per page. Defaults to 10.
|
|
1939
|
+
|
|
1940
|
+
Returns:
|
|
1941
|
+
DataPipelineRunsPage: A page of data pipeline runs with pagination support
|
|
1942
|
+
"""
|
|
1943
|
+
return await self._list_data_pipeline_runs(id, page_size)
|
|
1944
|
+
|
|
1945
|
+
async def _list_data_pipeline_runs(self, id: str, page_size: int, page_token: str = "") -> DataPipelineRunsPage:
|
|
1946
|
+
"""Internal method to list data pipeline runs with pagination.
|
|
1947
|
+
|
|
1948
|
+
Args:
|
|
1949
|
+
id (str): The ID of the pipeline to list runs for
|
|
1950
|
+
page_size (int): The number of runs to return per page
|
|
1951
|
+
page_token (str): The token to use to get the next page of results
|
|
1952
|
+
|
|
1953
|
+
Returns:
|
|
1954
|
+
DataPipelineRunsPage: A page of data pipeline runs with pagination support
|
|
1955
|
+
"""
|
|
1956
|
+
request = ListDataPipelineRunsRequest(id=id, page_size=page_size, page_token=page_token)
|
|
1957
|
+
response: ListDataPipelineRunsResponse = await self._data_pipelines_client.ListDataPipelineRuns(request, metadata=self._metadata)
|
|
1958
|
+
return DataClient.DataPipelineRunsPage.from_proto(response, self, page_size)
|
|
1959
|
+
|
|
1680
1960
|
@staticmethod
|
|
1681
1961
|
def create_filter(
|
|
1682
1962
|
component_name: Optional[str] = None,
|