ci: Import numpy before pyarrow in tests to resolve import warning by chalmerlowe · Pull Request #2187 · googleapis/python-bigquery · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

ci: Import numpy before pyarrow in tests to resolve import warning #2187

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

Merged
merged 10 commits into from
May 20, 2025

Conversation

chalmerlowe
Copy link
Collaborator

@chalmerlowe chalmerlowe commented May 15, 2025

A PytestDeprecationWarning was occurring in several test files because pyarrow, when imported by pytest.importorskip, would fail to import numpy.core.multiarray.

This change addresses the warning by explicitly importing numpy before pytest.importorskip("pyarrow", ...) in the affected test files. This ensures that numpy is fully initialized before pyarrow attempts to use it, resolving the underlying import error.

tests/unit/test_table.py::TestRowIterator::test_to_arrow_w_empty_table
  /repo/python-bigquery/tests/unit/test_table.py:3270: PytestDeprecationWarning: 
  Module 'pyarrow' was found, but when imported by pytest it raised:

      **ImportError('numpy.core.multiarray failed to import')**

  In pytest 9.1 this warning will become an error by default.
  You can fix the underlying problem, or alternatively overwrite this behavior and silence this warning by passing exc_type=ImportError explicitly.
  See https://docs.pytest.org/en/stable/deprecations.html#pytest-importorskip-default-behavior-regarding-importerror
    pyarrow = pytest.importorskip(

A `PytestDeprecationWarning` was occurring in several test files
because `pyarrow`, when imported by `pytest.importorskip`, would fail
to import `numpy.core.multiarray`.

This change addresses the warning by explicitly importing `numpy`
before `pytest.importorskip("pyarrow", ...)` in the affected
test files. This ensures that numpy is fully initialized before
pyarrow attempts to use it, resolving the underlying import error.

I also updated the test execution to use `nox -s unit`, which
correctly sets up the test environment and dependencies, allowing
the tests to pass and confirm the warning is resolved. Pre-existing
failures in `tests/unit/test_magics.py` are unrelated to this change.
@chalmerlowe chalmerlowe self-assigned this May 15, 2025
@chalmerlowe chalmerlowe requested review from a team as code owners May 15, 2025 15:35
@chalmerlowe chalmerlowe requested a review from suzmue May 15, 2025 15:35
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery API. labels May 15, 2025
@chalmerlowe chalmerlowe requested review from tswast and removed request for suzmue May 19, 2025 15:11
@chalmerlowe chalmerlowe merged commit a3d6bf3 into main May 20, 2025
37 of 40 checks passed
@chalmerlowe chalmerlowe deleted the fix-pyarrow-numpy-import-warning branch May 20, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.