GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #293

Copy link
Copy link
Closed
#328
Closed
list_models() of dataset containing a BigQuery AutoML models errors with Invalid enum value AUTOML_REGRESSOR for enum type#293
#328
Copy link
Assignees
HemangChothani
Labels
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.

Description

@romainr
romainr
opened on Oct 3, 2020
Issue body actions

Listing 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

  1. Create a BigQuery AutoML model, e.g. https://cloud.google.com/bigquery-ml/docs/bigqueryml-mf-explicit-tutorial
  2. 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..

Activity

  1. product-auto-label
    added
    api: bigqueryIssues related to the googleapis/python-bigquery API.
    on Oct 3, 2020
  2. yoshi-automation
    added
    triage meI really want to be triaged.
    on Oct 4, 2020
  3. HemangChothani
    added
    type: questionRequest for information or clarification. Not an issue.
    and removed
    triage meI really want to be triaged.
    on Oct 5, 2020
  4. HemangChothani
    self-assigned this
    on Oct 5, 2020
  5. HemangChothani commented on Oct 5, 2020

    @HemangChothani
    HemangChothani
    on Oct 5, 2020
    Contributor
    More actions

    @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.

  6. tswast commented on Oct 5, 2020

    @tswast
    tswast
    on Oct 5, 2020
    Contributor
    More actions

    We're working on refreshing the protocol buffers at https://github.com/googleapis/googleapis/tree/master/google/cloud/bigquery/v2 which are used to generate this code.

    @romainr does this happen at the time of list_models() or when the enum property is accessed? I wonder if it would be a useful workaround in the meantime to add some lazy parsing logic to this generated code to not fail on missing enum values?

    CC @shollyman

  7. HemangChothani commented on Oct 5, 2020

    @HemangChothani
    HemangChothani
    on Oct 5, 2020
    Contributor
    More actions

    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.

    Reacted by Romain Rigaux
  8. romainr commented on Oct 5, 2020

    @romainr
    romainr
    on Oct 5, 2020
    Author
    More actions

    Thanks for confirming!

    In the meantime, @HemangChothani, would you be able to share your "workaround"?

  9. HemangChothani commented on Oct 6, 2020

    @HemangChothani
    HemangChothani
    on Oct 6, 2020
    Contributor
    More actions

    @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.

  10. tswast
    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
    type: questionRequest for information or clarification. Not an issue.
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Oct 9, 2020
  11. tswast commented on Oct 15, 2020

    @tswast
    tswast
    on Oct 15, 2020
    Contributor
    More actions

    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

    Reacted by Romain Rigaux
  12. tswast
    closed this as completedin #328on Oct 19, 2020
  13. skelliest commented on Oct 23, 2020

    @skelliest
    skelliest
    on Oct 23, 2020
    More actions

    Thank you! Just when I wanted to access my new models!

    Reacted by Sean Kelly
  14. stokvis4 commented on May 5, 2022

    @stokvis4
    stokvis4
    on May 5, 2022
    More actions

    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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @HemangChothani
    HemangChothani

Labels

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.