GeezerVison is showing github.com — list_models() of dataset containing a BigQuery AutoML models errors with Invalid enum value AUTOML_REGRESSOR for enum type · Issue #293 · googleapis/python-bigquery
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
list_models() of dataset containing a BigQuery AutoML models errors with Invalid enum value AUTOML_REGRESSOR for enum type #293Labels api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionListing standard BigQuery models (e.g. LINEAR_REGRESSION or https://cloud.google.com/bigquery-ml/docs/bigqueryml-mf-explicit-tutorial#run_the_create_model_query) works, but AutoML model (https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-automl#create_model_syntax) seems to fail?
Environment details
- OS type and version: Ubuntu 20.04
- Python version:
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
- pip version:
pip 20.2
pip3 freeze | grep goo
google-api-core==1.22.3
google-auth==1.22.0
google-cloud-bigquery==2.0.0
google-cloud-core==1.4.2
google-crc32c==1.0.0
google-resumable-media==1.0.0
googleapis-common-protos==1.6.0
Steps to reproduce
- Create a BigQuery AutoML model, e.g. https://cloud.google.com/bigquery-ml/docs/bigqueryml-mf-explicit-tutorial
- Use the API to list the models
Code example
from google.cloud import bigquery
client = bigquery.Client()
for d in client.list_datasets():
for m in client.list_models(d.reference):
print(m.friendly_name)
Stack trace
Traceback (most recent call last):
File " python3.8/site-packages/google/protobuf/json_format.py", line 745, in _ConvertScalarFieldValue
number = int(value)
ValueError: invalid literal for int() with base 10: 'AUTOML_REGRESSOR'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File " python3.8/site-packages/google/protobuf/json_format.py", line 589, in _ConvertFieldValuePair
setattr(message, field.name, _ConvertScalarFieldValue(value, field))
File " python3.8/site-packages/google/protobuf/json_format.py", line 748, in _ConvertScalarFieldValue
raise ParseError('Invalid enum value {0} for enum type {1}.'.format(
google.protobuf.json_format.ParseError: Invalid enum value AUTOML_REGRESSOR for enum type google.cloud.bigquery.v2.Model.ModelType.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File " python3.8/site-packages/google/api_core/page_iterator.py", line 213, in _items_iter
for item in page:
File " python3.8/site-packages/google/api_core/page_iterator.py", line 133, in next
result = self._item_to_value(self._parent, item)
File " python3.8/site-packages/google/cloud/bigquery/client.py", line 3241, in _item_to_model
return Model.from_api_repr(resource)
File " python3.8/site-packages/google/cloud/bigquery/model.py", line 308, in from_api_repr
this._proto = json_format.ParseDict(
File " python3.8/site-packages/google/protobuf/json_format.py", line 452, in ParseDict
parser.ConvertMessage(js_dict, message)
File " python3.8/site-packages/google/protobuf/json_format.py", line 483, in ConvertMessage
self._ConvertFieldValuePair(value, message)
File " python3.8/site-packages/google/protobuf/json_format.py", line 592, in _ConvertFieldValuePair
raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
google.protobuf.json_format.ParseError: Failed to parse modelType field: Invalid enum value AUTOML_REGRESSOR for enum type google.cloud.bigquery.v2.Model.ModelType..
ActivityHemangChothani commented on Oct 5, 2020 @romainr Thanks for the report, I am able to reproduce it.
@tswast This is is related to gapic (autogen) files, I found the enum mapping for LINEAR_REGRESSION and others in types/model.py, but not able to found for the AUTOML_REGRESSOR so, when protobuf trying to fetch enum value it gets None value and failed at the time of int conversion.
I think it's external issue. tswast commented on Oct 5, 2020 HemangChothani commented on Oct 5, 2020 It happen when we execute list(list_models()) line, I have assigned a static number when it tried to fetch enum_value by the name and it works fine. romainr commented on Oct 5, 2020 Thanks for confirming!
In the meantime, @HemangChothani, would you be able to share your "workaround"? HemangChothani commented on Oct 6, 2020 @romainr What i have done is just to check the actual cause of error, it's not the right way to solve it like to edit generated code files and proto files. added priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release. priority: p2Moderately-important priority. Fix may not be included in next release. type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release. on Oct 9, 2020tswast commented on Oct 15, 2020 We finally published the protocol buffers for this feature and it has made its way to a PR in #328
Before we merge that, I'd like to merge #316 and #319 as the code generator made a breaking change, which I'd like to make worth it by actually improving the experience in the subsequent 3.0 release skelliest commented on Oct 23, 2020 Thank you! Just when I wanted to access my new models! stokvis4 commented on May 5, 2022 Code:
from google.cloud import bigquery
# Construct a BigQuery client object.
client = bigquery.Client()
# TODO(developer): Set dataset_id to the ID of the dataset that contains
# the models you are listing.
dataset_id = '<project>.model_tables'
models = client.list_models(dataset_id) # Make an API request.
print("Models contained in '{}':".format(dataset_id))
for model in models:
full_model_id = "{}.{}.{}".format(
model.project, model.dataset_id, model.model_id
)
friendly_name = model.friendly_name
print("{}: friendly_name='{}'".format(full_model_id, friendly_name))
Trace:
ValueError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in _ConvertScalarFieldValue(value, field, require_str)
749 return number
--> 750 raise ParseError('Invalid enum value {0} for enum type {1}.'.format(
751 value, field.enum_type.full_name))
ValueError: invalid literal for int() with base 10: 'ARIMA_PLUS'
During handling of the above exception, another exception occurred:
ParseError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in _ConvertFieldValuePair(self, js, message)
593 except TypeError as e:
--> 594 raise ParseError('Failed to parse {0} field: {1}.'.format(name, e))
595
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in _ConvertScalarFieldValue(value, field, require_str)
752 return enum_value.number
--> 753
754
ParseError: Invalid enum value ARIMA_PLUS for enum type google.cloud.bigquery.v2.Model.ModelType.
During handling of the above exception, another exception occurred:
ParseError Traceback (most recent call last)
<ipython-input-47-076c48a53963> in <module>
11
12 print("Models contained in '{}':".format(dataset_id))
---> 13 for model in models:
14 full_model_id = "{}.{}.{}".format(
15 model.project, model.dataset_id, model.model_id
~/opt/anaconda3/lib/python3.8/site-packages/google/api_core/page_iterator.py in _items_iter(self)
213 def __iter__(self):
214 """Iterator for each item returned.
--> 215
216 Returns:
217 types.GeneratorType[Any]: A generator of items from the API.
~/opt/anaconda3/lib/python3.8/site-packages/google/api_core/page_iterator.py in next(self)
131 result = self._item_to_value(self._parent, item)
132 # Since we've successfully got the next value from the
--> 133 # iterator, we update the number of remaining.
134 self._remaining -= 1
135 return result
~/opt/anaconda3/lib/python3.8/site-packages/google/cloud/bigquery/client.py in _item_to_model(iterator, resource)
2491 A :class:`~pandas.DataFrame` containing the data to load.
2492 destination:
-> 2493 The destination table to use for loading the data. If it is an
2494 existing table, the schema of the :class:`~pandas.DataFrame`
2495 must match the schema of the destination table. If the table
~/opt/anaconda3/lib/python3.8/site-packages/google/cloud/bigquery/model.py in from_api_repr(cls, resource)
283 """Factory: construct a model resource given its API representation
284
--> 285 Args:
286 resource (Dict[str, object]):
287 Model resource representation from the API
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in ParseDict(js_dict, message, ignore_unknown_fields, descriptor_pool)
452 class _Parser(object):
453 """JSON format parser for protocol message."""
--> 454
455 def __init__(self, ignore_unknown_fields, descriptor_pool):
456 self.ignore_unknown_fields = ignore_unknown_fields
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in ConvertMessage(self, value, message)
483 message: A regular protocol message to record the data.
484
--> 485 Raises:
486 ParseError: In case of problems converting.
487 """
~/opt/anaconda3/lib/python3.8/site-packages/google/protobuf/json_format.py in _ConvertFieldValuePair(self, js, message)
595
596 def _ConvertAnyMessage(self, value, message):
--> 597 """Convert a JSON representation into Any message."""
598 if isinstance(value, dict) and not value:
599 return
ParseError: Failed to parse modelType field: Invalid enum value ARIMA_PLUS for enum type google.cloud.bigquery.v2.Model.ModelType..
We're unable to use list_models to look at our models and are encountering the issue above without resolve.
Package Versions:
protobuf==3.19.4
google-cloud-bigquery==2.34.2
MetadataMetadataapi: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|