2
votes

Everyone I have a question regarding about Google AutoML Vision Python API. I want to use one of his functions calls update_dataset. One of the parameters that I need to enter is update_mask. But the official API reference doesn't have a sample code about it, it is required to enter Field google.protobuf.FieldMask.paths. So can someone tell me what it is and how to use it? Here is the link to the API reference. Thanks for everyone that can help.

update_dataset: https://googleapis.dev/python/automl/latest/gapic/v1/api.html#google.cloud.automl_v1.AutoMlClient.update_dataset

field_mask: https://googleapis.dev/python/automl/latest/gapic/v1/types.html#google.cloud.automl_v1.types.FieldMask

2

2 Answers

0
votes

In [1] and [2] you have information about Field Masks in update operations. Briefly, field masks are a set of symbolic paths that specify which fields should be updated. If you are updating the whole dataset just initialize the field mask empty as in [3].

You can also take a look at python-docs-samples on github [4], there is no specific example about using the update_dataset function but there are many others. I think that to update the dataset you can just create another one and delete the previous one if it's not a must of the use case.

[1] https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?_ga=2.160013118.2033425889.1584347340-1628125311.1584193707#fieldmask

[2] https://developers.google.com/protocol-buffers/docs/reference/google.protobuf?_ga=2.160013118.2033425889.1584347340-1628125311.1584193707#field-masks-in-update-operations

[3] https://googleapis.dev/python/automl/latest/_modules/google/cloud/automl_v1/gapic/auto_ml_client.html#AutoMlClient.update_dataset

[4] https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/automl/cloud-client

0
votes

According to the docs for UpdateDatasetRequest the "update mask applies to the [dataset] resource.", so any paths should be relative to the dataset object.

For example, if you wanted to update the display_name and description, construct the following field mask:

from google.protobuf import field_mask_pb2

update_mask = field_mask_pb2.FieldMask(paths=[
    "display_name",
    "description",
])