pythongoogle-cloud-platformgoogle-bigquerygoogle-cloud-storagegoogle-cloud-automl

How to create a dataset with google cloud AutoML


Silly question, but I'm new to Python and Google Cloud. I'm trying to predict customer-lifetime-value with google cloud automl_v1beta1, the code is here

  from google.cloud.automl_v1beta1 import AutoMlClient, PredictionServiceClient
  from google.cloud_v1beta1 import automl

  client = AutoMlClient.from_service_account_file(keyfile_name)
  location_path = f"projects/{project_id}/locations/us-central1"
  dataset_display_name = automl_dataset
  # create dataset
  create_dataset_response = client.create_dataset(
      parent=location_path,
      dataset={'display_name': dataset_display_name, 'tables_dataset_metadata': {}})

and I received the following errors: \

Traceback (most recent call last):
  

File "/home/tensorflow-lifetime-value/clv_automl/test1.py", line 220, in <module>
    main()
  File "/home/tensorflow-lifetime-value/clv_automl/test1.py", line 193, in main
    model_name = create_automl_model(client,
  File "/home/tensorflow-lifetime-value/clv_automl/test1.py", line 48, in 

create_automl_model
    create_dataset_response = client.create_dataset(
  File "/home/.local/lib/python3.9/site-packages/google/cloud/automl_v1/services/auto_ml/client.py", line 623, in create_dataset
    request.dataset = dataset
  File "/usr/local/lib/python3.9/dist-packages/proto/message.py", line 757, in __setattr__
    pb_value = marshal.to_proto(pb_type, value)
  File "/usr/local/lib/python3.9/dist-packages/proto/marshal/marshal.py", line 211, in to_proto
    pb_value = rule.to_proto(value)
  File "/usr/local/lib/python3.9/dist-packages/proto/marshal/rules/message.py", line 36, in to_proto
    return self._descriptor(**value)
ValueError: Protocol message Dataset has no "tables_dataset_metadata" field.

Solution

  • I got the same error using your code when I used google-cloud-automl<=0.1.2. Your error will be fixed if you use google-cloud-automl>=0.1.2. But I suggest to always install the latest version by doing pip install --upgrade google-cloud-automl to maximize the latest updates from Google Cloud.