Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bigquery): import Mapping from collections.abc not from collections #9826

Merged
merged 3 commits into from
Nov 21, 2019
Merged

fix(bigquery): import Mapping from collections.abc not from collections #9826

merged 3 commits into from
Nov 21, 2019

Conversation

alextford11
Copy link
Contributor

Getting following deprecation warning in Bigquery:

File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/job.py", line 3216, in __iter__
    return iter(self.result())
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/job.py", line 3105, in result
    dest_table = Table(dest_table_ref, schema=schema)
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/table.py", line 335, in __init__
    self.schema = schema
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/table.py", line 400, in schema
    value = _to_schema_fields(value)
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/schema.py", line 284, in _to_schema_fields
    if not isinstance(field, (SchemaField, collections.Mapping)):
  File "/usr/lib/python3.7/collections/__init__.py", line 52, in __getattr__
    DeprecationWarning, stacklevel=2)
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

@alextford11 alextford11 requested a review from a team November 19, 2019 09:29
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 19, 2019
@alextford11 alextford11 changed the title import Mapping from collections.abc not from collections fix(bigquery): import Mapping from collections.abc not from collections Nov 19, 2019
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When was the abc module added? If not until 3.x, we still need to account for compatibility with Python 2.7 for a little while longer.

bigquery/google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
bigquery/google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 21, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 21, 2019
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Just kicked off the Kokoro CI tests. We can merge, assuming those pass.

Copy link

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tswast I know you like importing modules, not classes, but this is the canonical approach, anything else will be very unclear.

bigquery/google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
bigquery/google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 21, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 21, 2019
@tswast tswast merged commit 0588f19 into googleapis:master Nov 21, 2019
@robert-l1
Copy link

I believe this update is causing issues with several versions of the BigQuery client class. My images are now throwing:

Traceback (most recent call last):
  File "test.py", line 20, in <module>
    from google.cloud import bigquery
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
    from google.cloud.bigquery.client import Client
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/client.py", line 58, in <module>
    from google.cloud.bigquery import _pandas_helpers
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/_pandas_helpers.py", line 40, in <module>
    from google.cloud.bigquery import schema
  File "/usr/local/lib/python3.7/dist-packages/google/cloud/bigquery/schema.py", line 17, in <module>
    from six.moves import collections_abc
ImportError: cannot import name 'collections_abc' from 'six.moves' (unknown location)

I see the same in 2.7:

    from google.cloud import bigquery
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
    from google.cloud.bigquery.client import Client
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery/client.py", line 58, in <module>
    from google.cloud.bigquery import _pandas_helpers
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery/_pandas_helpers.py", line 40, in <module>
    from google.cloud.bigquery import schema
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/bigquery/schema.py", line 17, in <module>
    from six.moves import collections_abc
ImportError: cannot import name collections_abc

@tkrassowski
Copy link

@robert-l1
Upgrade your six package to newer version. Collections_abc support came in 1.13.1 (benjaminp/six#241).

@neteler
Copy link

neteler commented Jan 8, 2020

@robert-l1
Upgrade your six package to newer version. Collections_abc support came in 1.13.1

FWIW: So far six 1.13.0 is the latest release (https://pypi.org/project/six/) and seems to be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants