Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Fix: refactor to adapt to changes to shapely dependency - #1376

Merged
chalmerlowe merged 7 commits into
mainfrom
fix-shapely-bug
Oct 5, 2022
Merged

Fix: refactor to adapt to changes to shapely dependency#1376
chalmerlowe merged 7 commits into
mainfrom
fix-shapely-bug

Conversation

@chalmerlowe

@chalmerlowechalmerlowe commented Oct 4, 2022

Copy link
Copy Markdown
Collaborator

The shapely library has undergone some internal refactoring.
Certain classes, such as WKTReader are no longer used, instead, the library relies on some functions that are imported from what appears to be pygeos.

This change points at the correct function to replace the outdated method call.

  • NEW: shapely.wkt.loads()
  • OLD: shapely.geos.WKTReader(shapely.geos.lgeos).read

Fixes#1364 🦕

Context:

This issue appeared when running a test in python-bigquery-sqlalchemy ... when running certain tests in that library, the code tried to load the tests/unit/testconf.py file from that library which references table.py in this library.

That was causing some failures in tests in the python-bigquery-sqlalchemy library.

@product-auto-labelproduct-auto-labelBot added size: xs Pull request size is extra small. api: bigquery Issues related to the googleapis/python-bigquery API. labels Oct 4, 2022
@chalmerlowe

Copy link
Copy Markdown
CollaboratorAuthor

@shollyman can you take a look at this for me and give me a sanity check?

@shollymanshollyman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see in the pandas helper we also use the well-known bytes reader, does this also need cleanup?

https://github.com/googleapis/python-bigquery/blob/main/google/cloud/bigquery/_pandas_helpers.py#L66

May be also worth checking system tests for unusual setups.

Are there other imports under shapely that need scrutiny beyond shapely.geos?

@chalmerlowechalmerlowe changed the title Fix shapely bugFix: refactor to adapt to changes to shapely dependencyOct 5, 2022
@product-auto-labelproduct-auto-labelBot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Oct 5, 2022
@chalmerlowe

chalmerlowe commented Oct 5, 2022

Copy link
Copy Markdown
CollaboratorAuthor

@shollyman

I checked the remainder of the code for references to shapely, WKT*, WKB*, etc.

Added a minor change based on what I found.

@chalmerlowechalmerlowe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 5, 2022
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 5, 2022
@shollyman

Copy link
Copy Markdown
Contributor

There's no test changes? Is this indicative that our existing tests were sufficient in catching and exercising this dependency? Do we need to exercise anything new as part of the changes?

@chalmerlowe

Copy link
Copy Markdown
CollaboratorAuthor

There's no test changes? Is this indicative that our existing tests were sufficient in catching and exercising this dependency? Do we need to exercise anything new as part of the changes?

The existing tests were already using the new refactoring > they referred to the correct functions in the correct files.

@chalmerlowe
chalmerlowe marked this pull request as ready for review October 5, 2022 17:48
@chalmerlowe
chalmerlowe requested review from a teamOctober 5, 2022 17:48
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
)
* fix: refactored to account for changes in dependency
* Removes comment and ensures linting success
* refactor to use loads() function
* fix: refactors to account for changes to shapely dependency
* fix: refactors to account for changes to shapely dependency
* blacken the code
* add mypy ignore flag for shapely import
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.size: sPull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Missing attribute: WKTReader

4 participants

@chalmerlowe@shollyman@parthea@yoshi-kokoro