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: updates a number of optional dependencies #1864

Merged
merged 42 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5b3e7db
replaces unittest.skipif
chalmerlowe Mar 20, 2024
ad84c43
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 20, 2024
25e28f8
adds a test for bqstorage_client == None
chalmerlowe Mar 21, 2024
6e6d8a1
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
fde7286
fix lint via removal of metadata imports
chalmerlowe Mar 21, 2024
502c430
added pragma
chalmerlowe Mar 21, 2024
a6d0669
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 21, 2024
b5c194b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
c4a9222
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 21, 2024
3ea3304
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
e21c9fe
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 21, 2024
8b47e07
updates unittest to pytest conversion in sys/test_client.py
chalmerlowe Mar 25, 2024
a27d2bd
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 25, 2024
7150c06
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
5c4ede6
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 25, 2024
16fc3ca
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
18219ef
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 25, 2024
d030541
unittest to pytest conversion unit/conftest.py
chalmerlowe Mar 25, 2024
acf3abc
updates unittest to pytest conversion test_dbapi__helpers.py
chalmerlowe Mar 25, 2024
34ee2d6
updates unittest to pytest conversion test_dbapi_connection.py
chalmerlowe Mar 25, 2024
7e78927
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
30c1631
unittest to pytest conversion test_dbapi_cursor.py
chalmerlowe Mar 25, 2024
af02cb8
more changes to test_dbapi_connection.py
chalmerlowe Mar 25, 2024
ba8f146
linting, some error fixes re: pyarrow
chalmerlowe Mar 25, 2024
1ed7aad
more updates
chalmerlowe Mar 25, 2024
82f44b0
linting fixes
chalmerlowe Mar 25, 2024
594c3de
updates to some tqdm tests
chalmerlowe Mar 25, 2024
0ae5e1a
Update tests/unit/test_table.py
chalmerlowe Mar 25, 2024
cac8e8f
updates syntax error
chalmerlowe Mar 25, 2024
5a93b0b
revised version checks for pandas using pytest.skip()
chalmerlowe Mar 26, 2024
ed6bf2b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 26, 2024
8edbf43
revise title of import; should clean up coverage
chalmerlowe Mar 27, 2024
1eead87
last cleanup on missing coverage
chalmerlowe Mar 27, 2024
ccd6bc4
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 27, 2024
49f6724
Update tests/system/test_client.py
chalmerlowe Mar 27, 2024
2a53adf
Update tests/system/test_client.py
chalmerlowe Mar 27, 2024
ba4750f
Update tests/unit/test_client.py
chalmerlowe Mar 27, 2024
3634ab1
Update tests/unit/conftest.py
chalmerlowe Mar 27, 2024
5617542
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 27, 2024
423b9f6
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 27, 2024
0415084
removed errant @fixture flag
chalmerlowe Mar 27, 2024
122f156
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/bigquery/_tqdm_helpers.py
Expand Up @@ -67,7 +67,7 @@ def get_progress_bar(progress_bar_type, description, total, unit):
)
elif progress_bar_type == "tqdm_gui":
return tqdm.tqdm_gui(desc=description, total=total, unit=unit)
except (KeyError, TypeError):
except (KeyError, TypeError): # pragma: NO COVER
# Protect ourselves from any tqdm errors. In case of
# unexpected tqdm behavior, just fall back to showing
# no progress bar.
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/client.py
Expand Up @@ -593,7 +593,7 @@ def _ensure_bqstorage_client(
)
return None

if bqstorage_client is None:
if bqstorage_client is None: # pragma: NO COVER
tswast marked this conversation as resolved.
Show resolved Hide resolved
bqstorage_client = bigquery_storage.BigQueryReadClient(
credentials=self._credentials,
client_options=client_options,
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -45,8 +45,9 @@
]
pyarrow_dependency = "pyarrow >= 3.0.0"
extras = {
# Keep the no-op bqstorage extra for backward compatibility.
# See: https://github.com/googleapis/python-bigquery/issues/757
# bqstorage had a period where it was a required dependency, and has been
# moved back to optional due to bloat. See
# https://github.com/googleapis/python-bigquery/issues/1196 for more background.
"bqstorage": [
"google-cloud-bigquery-storage >= 2.6.0, <3.0.0dev",
# Due to an issue in pip's dependency resolver, the `grpc` extra is not
Expand Down
30 changes: 9 additions & 21 deletions tests/system/test_client.py
Expand Up @@ -55,16 +55,6 @@

from . import helpers

try:
from google.cloud import bigquery_storage
except ImportError: # pragma: NO COVER
bigquery_storage = None

try:
import pyarrow
import pyarrow.types
except ImportError: # pragma: NO COVER
pyarrow = None

JOB_TIMEOUT = 120 # 2 minutes
DATA_PATH = pathlib.Path(__file__).parent.parent / "data"
Expand Down Expand Up @@ -1800,11 +1790,11 @@ def test_dbapi_fetchall_from_script(self):
row_tuples = [r.values() for r in rows]
self.assertEqual(row_tuples, [(5, "foo"), (6, "bar"), (7, "baz")])

@unittest.skipIf(
bigquery_storage is None, "Requires `google-cloud-bigquery-storage`"
)
@unittest.skipIf(pyarrow is None, "Requires `pyarrow`")
def test_dbapi_fetch_w_bqstorage_client_large_result_set(self):
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pyarrow")
from google.cloud import bigquery_storage
chalmerlowe marked this conversation as resolved.
Show resolved Hide resolved

bqstorage_client = bigquery_storage.BigQueryReadClient(
credentials=Config.CLIENT._credentials
)
Expand Down Expand Up @@ -1862,10 +1852,8 @@ def test_dbapi_dry_run_query(self):

self.assertEqual(list(rows), [])

@unittest.skipIf(
bigquery_storage is None, "Requires `google-cloud-bigquery-storage`"
)
def test_dbapi_connection_does_not_leak_sockets(self):
pytest.importorskip("google.cloud.bigquery_storage")
current_process = psutil.Process()
conn_count_start = len(current_process.connections())

Expand Down Expand Up @@ -2410,11 +2398,11 @@ def test_create_table_rows_fetch_nested_schema(self):
self.assertEqual(found[7], e_favtime)
self.assertEqual(found[8], decimal.Decimal(expected["FavoriteNumber"]))

@unittest.skipIf(pyarrow is None, "Requires `pyarrow`")
@unittest.skipIf(
bigquery_storage is None, "Requires `google-cloud-bigquery-storage`"
)
def test_nested_table_to_arrow(self):
pytest.importorskip("google.cloud.bigquery_storage")
pyarrow = pytest.importorskip("pyarrow")
pyarrow.types = pytest.importorskip("pyarrow.types")
from google.cloud import bigquery_storage
chalmerlowe marked this conversation as resolved.
Show resolved Hide resolved
from google.cloud.bigquery.job import SourceFormat
from google.cloud.bigquery.job import WriteDisposition

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/conftest.py
Expand Up @@ -39,6 +39,11 @@ def LOCATION():
yield "us-central"


@pytest.fixture
def PYARROW_MINIMUM_VERSION(): # pragma: NO COVER
return "3.0.0"
chalmerlowe marked this conversation as resolved.
Show resolved Hide resolved


Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't look like this fixture is used?

Also if it is used, could this use the constant from _version_helpers as the tests do below?

def noop_add_server_timeout_header(headers, kwargs):
if headers:
kwargs["headers"] = headers
Expand Down