From b5a1127307f3d0f33346406751df769bf7264581 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Tue, 27 Feb 2024 23:04:54 +0100 Subject: [PATCH 1/4] DOCS-1880: Document new data client methods --- docs/build/program/apis/data-client.md | 229 ++++++++++++++++++++ static/include/services/apis/data-client.md | 7 + 2 files changed, 236 insertions(+) diff --git a/docs/build/program/apis/data-client.md b/docs/build/program/apis/data-client.md index 0c6193daac..431fa4d1c7 100644 --- a/docs/build/program/apis/data-client.md +++ b/docs/build/program/apis/data-client.md @@ -846,3 +846,232 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ {{% /tab %}} {{< /tabs >}} + +### CreateDataset + +Create a new dataset. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- name (str): The name of the dataset being created. +- organization_id (str): The ID of the organization where the dataset is being created. + +**Returns:** + +- (`str`): The dataset ID of the created dataset. + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.create_dataset). + +```python {class="line-numbers linkable-line-numbers"} +name = await data_client.create_dataset( + name="", + organization_id="" +) +print(name) +``` + +{{% /tab %}} +{{< /tabs >}} + +### ListDatasetByIds + +Get a list of datasets using their IDs. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- ids (List[str]): The IDs of the datasets being called for. + +**Returns:** + +- (Sequence[[Dataset](https://python.viam.dev/autoapi/viam/gen/app/dataset/v1/dataset_pb2/index.html#viam.gen.app.dataset.v1.dataset_pb2.Dataset)]): The list of datasets. + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.list_dataset_by_ids). + +```python {class="line-numbers linkable-line-numbers"} +datasets = await data_client.list_dataset_by_ids( + ids=[""] +) +print(datasets) +``` + +{{% /tab %}} +{{< /tabs >}} + +### ListDatasetByOrganizationId + +Get the datasets in an organization. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- organization_id (str): The ID of the organization. + +**Returns:** + +- (Sequence[[Dataset](https://python.viam.dev/autoapi/viam/gen/app/dataset/v1/dataset_pb2/index.html#viam.gen.app.dataset.v1.dataset_pb2.Dataset)]): The list of datasets in the organization. + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.list_datasets_by_organization_id). + +```python {class="line-numbers linkable-line-numbers"} +datasets = await data_client.list_datasets_by_organization_id( + organization_id="" +) +print(datasets) +``` + +{{% /tab %}} +{{< /tabs >}} + +### RenameDataset + +Rename a dataset specified by the dataset ID. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- id (str): The ID of the dataset. +- name (str): The new name of the dataset. + +**Returns:** + +- None. + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.rename_dataset). + +```python {class="line-numbers linkable-line-numbers"} +await data_client.rename_dataset( + id="", + name="" +) +``` + +{{% /tab %}} +{{< /tabs >}} + +### DeleteDataset + +Delete a dataset. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- id (str): The ID of the dataset. + +**Returns:** + +- None. + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.delete_dataset). + +```python {class="line-numbers linkable-line-numbers"} +await data_client.delete_dataset( + id="" +) +``` + +{{% /tab %}} +{{< /tabs >}} + +### AddBinaryDataToDatasetByIds + +Add the BinaryData to the provided dataset. +This BinaryData will be tagged with the VIAM_DATASET\_{id} label. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- binary_ids (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to add to dataset. +- dataset_id (str): The ID of the dataset to be added to. + +**Returns:** + +- None. + +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_binary_data_to_dataset_by_ids). + +```python {class="line-numbers linkable-line-numbers"} +from viam.proto.app.data import BinaryID + +binary_metadata = await data_client.binary_data_by_filter( + include_file_data=False +) + +my_binary_ids = [] + +for obj in binary_metadata: + my_binary_ids.append( + BinaryID( + file_id=obj.metadata.id, + organization_id=obj.metadata.capture_metadata.organization_id, + location_id=obj.metadata.capture_metadata.location_id + ) + ) + +await data_client.add_binary_data_to_dataset_by_ids( + binary_ids=my_binary_ids, + dataset_id="" +) +``` + +{{% /tab %}} +{{< /tabs >}} + +### RemoveBinaryDataFromDatasetByIds + +Remove the BinaryData from the provided dataset. +This BinaryData will lose the VIAM_DATASET\_{id} tag. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- binary_ids (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to remove from dataset. +- dataset_id (str): The ID of the dataset to be removed from. + +**Returns:** + +- None. + +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_binary_data_from_dataset_by_ids). + +```python {class="line-numbers linkable-line-numbers"} +from viam.proto.app.data import BinaryID + +binary_metadata = await data_client.binary_data_by_filter( + include_file_data=False +) + +my_binary_ids = [] + +for obj in binary_metadata: + my_binary_ids.append( + BinaryID( + file_id=obj.metadata.id, + organization_id=obj.metadata.capture_metadata.organization_id, + location_id=obj.metadata.capture_metadata.location_id + ) + ) + +await data_client.remove_binary_data_from_dataset_by_ids( + binary_ids=my_binary_ids, + dataset_id="" +) +``` + +{{% /tab %}} +{{< /tabs >}} diff --git a/static/include/services/apis/data-client.md b/static/include/services/apis/data-client.md index 48f1c0c3c1..a6b6934902 100644 --- a/static/include/services/apis/data-client.md +++ b/static/include/services/apis/data-client.md @@ -21,3 +21,10 @@ Method Name | Description [`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. +[`CreateDataset`](/build/program/apis/data-client/#createdataset) | +[`ListDatasetByIds`](/build/program/apis/data-client/#listdatasetbyids) | +[`ListDatasetByOrganizationId`](/build/program/apis/data-client/#listdatasetbyorganizationid) | +[`RenameDataset`](/build/program/apis/data-client/#renamedataset) | +[`DeleteDataset`](/build/program/apis/data-client/#deletedataset) | +[`AddBinaryDataToDatasetByIds`](/build/program/apis/data-client/#addbinarydatatodatasetbyids) | +[`RemoveBinaryDataFromDatasetByIds`](/build/program/apis/data-client/#removebinarydatafromdatasetbyids) | From d567fce851e9e6bdc6ae2c0659dfab14223574f9 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:25:59 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: JessamyT <75634662+JessamyT@users.noreply.github.com> --- docs/build/program/apis/data-client.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/build/program/apis/data-client.md b/docs/build/program/apis/data-client.md index 431fa4d1c7..fea4e63079 100644 --- a/docs/build/program/apis/data-client.md +++ b/docs/build/program/apis/data-client.md @@ -856,12 +856,12 @@ Create a new dataset. **Parameters:** -- name (str): The name of the dataset being created. -- organization_id (str): The ID of the organization where the dataset is being created. +- `name` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The name of the dataset being created. +- `organization_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the organization where the dataset is being created. **Returns:** -- (`str`): The dataset ID of the created dataset. +- [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The dataset ID of the created dataset. For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/data_client/index.html#viam.app.data_client.DataClient.create_dataset). @@ -885,7 +885,7 @@ Get a list of datasets using their IDs. **Parameters:** -- ids (List[str]): The IDs of the datasets being called for. +- `ids` (List[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)]): The IDs of the datasets being called for. **Returns:** @@ -912,7 +912,7 @@ Get the datasets in an organization. **Parameters:** -- organization_id (str): The ID of the organization. +- `organization_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the organization. **Returns:** @@ -939,8 +939,8 @@ Rename a dataset specified by the dataset ID. **Parameters:** -- id (str): The ID of the dataset. -- name (str): The new name of the dataset. +- `id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the dataset. +- `name` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The new name of the dataset. **Returns:** @@ -967,7 +967,7 @@ Delete a dataset. **Parameters:** -- id (str): The ID of the dataset. +- `id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the dataset. **Returns:** @@ -986,7 +986,7 @@ await data_client.delete_dataset( ### AddBinaryDataToDatasetByIds -Add the BinaryData to the provided dataset. +Add the [BinaryData](https://python.viam.dev/autoapi/viam/proto/app/data/index.html#viam.proto.app.data.BinaryData) to the provided dataset. This BinaryData will be tagged with the VIAM_DATASET\_{id} label. {{< tabs >}} @@ -994,8 +994,8 @@ This BinaryData will be tagged with the VIAM_DATASET\_{id} label. **Parameters:** -- binary_ids (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to add to dataset. -- dataset_id (str): The ID of the dataset to be added to. +- `binary_ids` (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to add to dataset. +- `dataset_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the dataset to be added to. **Returns:** @@ -1040,8 +1040,8 @@ This BinaryData will lose the VIAM_DATASET\_{id} tag. **Parameters:** -- binary_ids (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to remove from dataset. -- dataset_id (str): The ID of the dataset to be removed from. +- `binary_ids` (List[[BinaryID](https://python.viam.dev/autoapi/viam/gen/app/data/v1/data_pb2/index.html#viam.gen.app.data.v1.data_pb2.BinaryID "viam.gen.app.data.v1.data_pb2.BinaryID")]): The IDs of binary data to remove from dataset. +- `dataset_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of the dataset to be removed from. **Returns:** From db5a72d457bfd0c95e2cda2d762845651a10a556 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:29:23 +0100 Subject: [PATCH 3/4] Update static/include/services/apis/data-client.md --- static/include/services/apis/data-client.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/static/include/services/apis/data-client.md b/static/include/services/apis/data-client.md index a6b6934902..514c457276 100644 --- a/static/include/services/apis/data-client.md +++ b/static/include/services/apis/data-client.md @@ -21,10 +21,10 @@ Method Name | Description [`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. -[`CreateDataset`](/build/program/apis/data-client/#createdataset) | -[`ListDatasetByIds`](/build/program/apis/data-client/#listdatasetbyids) | -[`ListDatasetByOrganizationId`](/build/program/apis/data-client/#listdatasetbyorganizationid) | -[`RenameDataset`](/build/program/apis/data-client/#renamedataset) | -[`DeleteDataset`](/build/program/apis/data-client/#deletedataset) | -[`AddBinaryDataToDatasetByIds`](/build/program/apis/data-client/#addbinarydatatodatasetbyids) | -[`RemoveBinaryDataFromDatasetByIds`](/build/program/apis/data-client/#removebinarydatafromdatasetbyids) | +[`CreateDataset`](/build/program/apis/data-client/#createdataset) | Create a new dataset. +[`ListDatasetByIds`](/build/program/apis/data-client/#listdatasetbyids) | Get a list of datasets using their IDs. +[`ListDatasetByOrganizationId`](/build/program/apis/data-client/#listdatasetbyorganizationid) | Get the datasets in an organization. +[`RenameDataset`](/build/program/apis/data-client/#renamedataset) | Rename a dataset specified by the dataset ID. +[`DeleteDataset`](/build/program/apis/data-client/#deletedataset) | Delete a dataset. +[`AddBinaryDataToDatasetByIds`](/build/program/apis/data-client/#addbinarydatatodatasetbyids) | Add the BinaryData to the provided dataset. This BinaryData will be tagged with the VIAM_DATASET_{id} label. +[`RemoveBinaryDataFromDatasetByIds`](/build/program/apis/data-client/#removebinarydatafromdatasetbyids) | Remove the BinaryData from the provided dataset. This BinaryData will lose the VIAM_DATASET_{id} tag. From 6221b9072ae894a6d22dd22da24503bcfac48901 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:42:08 +0100 Subject: [PATCH 4/4] Apply suggestions from code review --- docs/build/program/apis/data-client.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/build/program/apis/data-client.md b/docs/build/program/apis/data-client.md index fea4e63079..ba59a82a1d 100644 --- a/docs/build/program/apis/data-client.md +++ b/docs/build/program/apis/data-client.md @@ -895,7 +895,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ ```python {class="line-numbers linkable-line-numbers"} datasets = await data_client.list_dataset_by_ids( - ids=[""] + ids=["abcd-1234xyz-8765z-123abc"] ) print(datasets) ``` @@ -950,7 +950,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ ```python {class="line-numbers linkable-line-numbers"} await data_client.rename_dataset( - id="", + id="abcd-1234xyz-8765z-123abc", name="" ) ``` @@ -977,7 +977,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ ```python {class="line-numbers linkable-line-numbers"} await data_client.delete_dataset( - id="" + id="abcd-1234xyz-8765z-123abc" ) ``` @@ -1023,7 +1023,7 @@ for obj in binary_metadata: await data_client.add_binary_data_to_dataset_by_ids( binary_ids=my_binary_ids, - dataset_id="" + dataset_id="abcd-1234xyz-8765z-123abc" ) ``` @@ -1069,7 +1069,7 @@ for obj in binary_metadata: await data_client.remove_binary_data_from_dataset_by_ids( binary_ids=my_binary_ids, - dataset_id="" + dataset_id="abcd-1234xyz-8765z-123abc" ) ```