From dccbf9a77ebedad883d0cc54f1df91622d0840b9 Mon Sep 17 00:00:00 2001 From: andf-viam <132301587+andf-viam@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:24:23 -0500 Subject: [PATCH] DOCS-1430: Add missing DataClient methods (#2229) --- docs/build/program/apis/data-client.md | 137 ++++++++++++++++++++ static/include/services/apis/data-client.md | 3 + 2 files changed, 140 insertions(+) diff --git a/docs/build/program/apis/data-client.md b/docs/build/program/apis/data-client.md index 246620c57a..c341044947 100644 --- a/docs/build/program/apis/data-client.md +++ b/docs/build/program/apis/data-client.md @@ -634,6 +634,57 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ {{% /tab %}} {{< /tabs >}} +### StreamingDataCaptureUpload + +Upload the contents of streaming binary data and the relevant metadata to the [Viam app](https://app.viam.com). +Uploaded streaming data can be found under the [**Data** tab](https://app.viam.com/data). + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `data` [(bytes)](https://docs.python.org/3/library/stdtypes.html#bytes-objects): Data to be uploaded, represented in bytes. +- `part_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): Part ID of the resource associated with the file. +- `file_ext` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): File extension type for the data. required for determining MIME type. +- `component_type` [(Optional[str])](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): Optional type of the component associated with the file (For example, “movement_sensor”). +- `component_name` [(Optional[str])](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): Optional name of the component associated with the file. +- `method_name` [(Optional[str])](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): Optional name of the method associated with the file. +- `method_parameters` [(Optional[str])](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): Optional dictionary of the method parameters. No longer in active use. +- `data_request_times` [(Optional[Tuple[datetime.datetime, datetime.datetime]])](https://docs.python.org/3/library/stdtypes.html#tuples): Optional tuple containing [`datetime`](https://docs.python.org/3/library/datetime.html) objects denoting the times this data was requested and received by the appropriate sensor. +- `tags` [(Optional[List[str]])](https://docs.python.org/3/library/stdtypes.html#typesseq-list): Optional list of [image tags](/data/dataset/#image-tags) to allow for tag-based data filtering when retrieving data. + +**Returns:** + +- [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The `file_id` of the uploaded data. + +**Raises:** + +- `GRPCError` – If an invalid part ID is passed. + +```python {class="line-numbers linkable-line-numbers"} +time_requested = datetime(2023, 6, 5, 11) +time_received = datetime(2023, 6, 5, 11, 0, 3) + +file_id = await data_client.streaming_data_capture_upload( + data="byte-data-to-upload", + part_id="INSERT YOUR PART ID", + file_ext="png", + component_type='motor', + component_name='left_motor', + method_name='IsPowered', + data_request_times=[(time_requested, time_received)], + tags=["tag_1", "tag_2"] +) + +print(file_id) +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.streaming_data_capture_upload). + +{{% /tab %}} +{{< /tabs >}} + ### FileUpload Upload arbitrary files stored on your machine to the [Viam app](https://app.viam.com) by file name. @@ -705,3 +756,89 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ {{% /tab %}} {{< /tabs >}} + +### AddBoundingBoxToImageById + +Add a bounding box to an image specified by its BinaryID. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `binary_id` ([viam.proto.app.data.BinaryID](https://python.viam.dev/autoapi/viam/proto/app/data/index.html#viam.proto.app.data.BinaryID)): The ID of the image to add the bounding box to. +- `label` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): A label for the bounding box. +- `x_min_normalized` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): Minimum X value of the bounding box normalized from `0` to `1`. +- `y_min_normalized` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): Minimum Y value of the bounding box normalized from `0` to `1`. +- `x_max_normalized` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): Maximum X value of the bounding box normalized from `0` to `1`. +- `y_max_normalized` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): Maximum Y value of the bounding box normalized from `0` to `1`. + +**Returns:** + +- [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The bounding box ID of the image. + +**Raises:** + +- `GRPCError` – If the X or Y values are outside of the [0, 1] range. + +```python {class="line-numbers linkable-line-numbers"} +from viam.proto.app.data import BinaryID + +MY_BINARY_ID = BinaryID( + file_id=your-file_id, + organization_id=your-org-id, + location_id=your-location-id +) + +bbox_label = await data_client.add_bounding_box_to_image_by_id( + binary_id=MY_BINARY_ID, + label="label", + x_min_normalized=0, + y_min_normalized=.1, + x_max_normalized=.2, + y_max_normalized=.3 +) + +print(bbox_label) +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.add_bounding_box_to_image_by_id). + +{{% /tab %}} +{{< /tabs >}} + +### RemoveBoundingBoxFromImageById + +Removes a bounding box from an image specified by its BinaryID. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `bbox_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the bounding box to remove. +- `binary_id` ([viam.proto.app.data.BinaryID](https://python.viam.dev/autoapi/viam/proto/app/data/index.html#viam.proto.app.data.BinaryID)): Binary ID of the image to to remove the bounding box from. + +**Returns:** + +- None. + +```python {class="line-numbers linkable-line-numbers"} +from viam.proto.app.data import BinaryID + +MY_BINARY_ID = BinaryID( + file_id=your-file_id, + organization_id=your-org-id, + location_id=your-location-id +) + +await data_client.remove_bounding_box_from_image_by_id( + binary_id=MY_BINARY_ID, + bbox_id="your-bounding-box-id-to-delete" +) +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.remove_bounding_box_from_image_by_id). + +{{% /tab %}} +{{< /tabs >}} diff --git a/static/include/services/apis/data-client.md b/static/include/services/apis/data-client.md index 086f1503db..48f1c0c3c1 100644 --- a/static/include/services/apis/data-client.md +++ b/static/include/services/apis/data-client.md @@ -16,5 +16,8 @@ Method Name | Description [`GetDatabaseConnection`](/build/program/apis/data-client/#getdatabaseconnection) | Get a connection to access a MongoDB Atlas Data federation instance. [`BinaryDataCaptureUpload`](/build/program/apis/data-client/#binarydatacaptureupload) | Upload binary data collected on your machine through a specific component and the relevant metadata to the Viam app. [`TabularDataCaptureUpload`](/build/program/apis/data-client/#tabulardatacaptureupload) | Upload tabular data collected on your machine through a specific component and the relevant metadata to the Viam app. +[`StreamingDataCaptureUpload`](/build/program/apis/data-client/#streamingdatacaptureupload) | Upload the contents of streaming binary data and the relevant metadata to the Viam app. [`FileUpload`](/build/program/apis/data-client/#fileupload) | Upload file data stored on your machine and the relevant metadata to the Viam app. [`FileUploadFromPath`](/build/program/apis/data-client/#fileuploadfrompath) | Upload file data stored on your machine from the specified filepath and the relevant metadata to the Viam app. +[`AddBoundingBoxToImageById`](/build/program/apis/data-client/#addboundingboxtoimagebyid) | Add a bounding box to an image specified by its BinaryID. +[`RemoveBoundingBoxFromImageById`](/build/program/apis/data-client/#removeboundingboxfromimagebyid) | Removes a bounding box from an image specified by its BinaryID.