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

Commit 79a61ac

Browse files
committed
adds debugging to noxfile and tweaks to correct coverage
1 parent 5f0bc1f commit 79a61ac

File tree

4 files changed

+67
-5
lines changed

4 files changed

+67
-5
lines changed

noxfile.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
from __future__ import absolute_import
2020

21+
from functools import wraps
2122
import os
2223
import pathlib
2324
import re
2425
import shutil
26+
import time
2527
from typing import Dict, List
2628
import warnings
2729

@@ -110,6 +112,27 @@
110112

111113
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
112114

115+
116+
def _calculate_duration(func):
117+
"""This decorator prints the execution time for the decorated function."""
118+
119+
@wraps(func)
120+
def wrapper(*args, **kwargs):
121+
start = time.monotonic()
122+
result = func(*args, **kwargs)
123+
end = time.monotonic()
124+
total_seconds = round(end - start)
125+
hours = total_seconds // 3600 # Integer division to get hours
126+
remaining_seconds = total_seconds % 3600 # Modulo to find remaining seconds
127+
minutes = remaining_seconds // 60
128+
seconds = remaining_seconds % 60
129+
human_time = f"{hours:}:{minutes:0>2}:{seconds:0>2}"
130+
print(f"Session ran in {total_seconds} seconds ({human_time})")
131+
return result
132+
133+
return wrapper
134+
135+
113136
nox.options.sessions = [
114137
"unit",
115138
"system",
@@ -128,13 +151,15 @@
128151

129152

130153
@nox.session(python=DEFAULT_PYTHON_VERSION)
154+
@_calculate_duration
131155
def lint(session):
132156
"""Run linters.
133157
134158
Returns a failure if the linters find linting errors or sufficiently
135159
serious code quality issues.
136160
"""
137161
session.install(FLAKE8_VERSION, BLACK_VERSION)
162+
session.run("python", "-m", "pip", "freeze")
138163
session.run(
139164
"black",
140165
"--check",
@@ -144,16 +169,19 @@ def lint(session):
144169

145170

146171
@nox.session(python=DEFAULT_PYTHON_VERSION)
172+
@_calculate_duration
147173
def blacken(session):
148174
"""Run black. Format code to uniform standard."""
149175
session.install(BLACK_VERSION)
176+
session.run("python", "-m", "pip", "freeze")
150177
session.run(
151178
"black",
152179
*LINT_PATHS,
153180
)
154181

155182

156183
@nox.session(python=DEFAULT_PYTHON_VERSION)
184+
@_calculate_duration
157185
def format(session):
158186
"""
159187
Run isort to sort imports. Then run black
@@ -162,6 +190,7 @@ def format(session):
162190
session.install(BLACK_VERSION, ISORT_VERSION)
163191
# Use the --fss option to sort imports using strict alphabetical order.
164192
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
193+
session.run("python", "-m", "pip", "freeze")
165194
session.run(
166195
"isort",
167196
"--fss",
@@ -174,9 +203,11 @@ def format(session):
174203

175204

176205
@nox.session(python=DEFAULT_PYTHON_VERSION)
206+
@_calculate_duration
177207
def lint_setup_py(session):
178208
"""Verify that setup.py is valid (including RST check)."""
179209
session.install("docutils", "pygments")
210+
session.run("python", "-m", "pip", "freeze")
180211
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
181212

182213

@@ -213,6 +244,7 @@ def install_unittest_dependencies(session, *constraints):
213244
"protobuf_implementation",
214245
["python", "upb", "cpp"],
215246
)
247+
@_calculate_duration
216248
def unit(session, protobuf_implementation, install_extras=True):
217249
# Install all test dependencies, then install this package in-place.
218250

@@ -239,6 +271,7 @@ def unit(session, protobuf_implementation, install_extras=True):
239271
session.install("protobuf<4")
240272

241273
# Run py.test against the unit tests.
274+
session.run("python", "-m", "pip", "freeze")
242275
session.run(
243276
"py.test",
244277
"--quiet",
@@ -288,6 +321,7 @@ def install_systemtest_dependencies(session, *constraints):
288321

289322

290323
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
324+
@_calculate_duration
291325
def system(session):
292326
"""Run the system test suite."""
293327
constraints_path = str(
@@ -310,6 +344,7 @@ def system(session):
310344
session.skip("System tests were not found")
311345

312346
install_systemtest_dependencies(session, "-c", constraints_path)
347+
session.run("python", "-m", "pip", "freeze")
313348

314349
# Run py.test against the system tests.
315350
if system_test_exists:
@@ -331,6 +366,7 @@ def system(session):
331366

332367

333368
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
369+
@_calculate_duration
334370
def system_noextras(session):
335371
"""Run the system test suite."""
336372
constraints_path = str(
@@ -355,6 +391,7 @@ def system_noextras(session):
355391
global SYSTEM_TEST_EXTRAS_BY_PYTHON
356392
SYSTEM_TEST_EXTRAS_BY_PYTHON = False
357393
install_systemtest_dependencies(session, "-c", constraints_path)
394+
session.run("python", "-m", "pip", "freeze")
358395

359396
# Run py.test against the system tests.
360397
if system_test_exists:
@@ -376,6 +413,7 @@ def system_noextras(session):
376413

377414

378415
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])
416+
@_calculate_duration
379417
def compliance(session):
380418
"""Run the SQLAlchemy dialect-compliance system tests"""
381419
constraints_path = str(
@@ -430,19 +468,22 @@ def compliance(session):
430468

431469

432470
@nox.session(python=DEFAULT_PYTHON_VERSION)
471+
@_calculate_duration
433472
def cover(session):
434473
"""Run the final coverage report.
435474
436475
This outputs the coverage report aggregating coverage from the unit
437476
test runs (not system test runs), and then erases coverage data.
438477
"""
439478
session.install("coverage", "pytest-cov")
479+
session.run("python", "-m", "pip", "freeze")
440480
session.run("coverage", "report", "--show-missing", "--fail-under=100")
441481

442482
session.run("coverage", "erase")
443483

444484

445485
@nox.session(python="3.10")
486+
@_calculate_duration
446487
def docs(session):
447488
"""Build the docs for this library."""
448489

@@ -465,6 +506,7 @@ def docs(session):
465506
)
466507

467508
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
509+
session.run("python", "-m", "pip", "freeze")
468510
session.run(
469511
"sphinx-build",
470512
"-W", # warnings as errors
@@ -480,6 +522,7 @@ def docs(session):
480522

481523

482524
@nox.session(python="3.10")
525+
@_calculate_duration
483526
def docfx(session):
484527
"""Build the docfx yaml files for this library."""
485528

@@ -502,6 +545,7 @@ def docfx(session):
502545
)
503546

504547
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
548+
session.run("python", "-m", "pip", "freeze")
505549
session.run(
506550
"sphinx-build",
507551
"-T", # show full traceback on exception
@@ -532,6 +576,7 @@ def docfx(session):
532576
"protobuf_implementation",
533577
["python", "upb", "cpp"],
534578
)
579+
@_calculate_duration
535580
def prerelease_deps(session, protobuf_implementation):
536581
"""Run all tests with prerelease versions of dependencies installed."""
537582

@@ -593,6 +638,7 @@ def prerelease_deps(session, protobuf_implementation):
593638
"requests",
594639
]
595640
session.install(*other_deps)
641+
session.run("python", "-m", "pip", "freeze")
596642

597643
# Print out prerelease package versions
598644
session.run(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def readme():
6262
# https://github.com/grpc/grpc/pull/15254
6363
"grpcio >= 1.47.0, < 2.0.0",
6464
"grpcio >= 1.49.1, < 2.0.0; python_version>='3.11'",
65-
"pyarrow >= 3.0.0",
65+
"pyarrow >= 5.0.0",
6666
],
6767
}
6868

sqlalchemy_bigquery/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@
4848
from . import _versions_helpers
4949

5050
sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()
51-
if sys_major == 3 and sys_minor in (7, 8):
51+
# Now that support for Python 3.7 and 3.8 has been removed, we don't expect the
52+
# following check to succeed. The warning is only included for robustness.
53+
if sys_major == 3 and sys_minor in (7, 8): # pragma: NO COVER
5254
warnings.warn(
53-
"The python-bigquery library will stop supporting Python 3.7 "
54-
"and Python 3.8 in a future major release expected in Q4 2024. "
55+
"The python-bigquery-sqlalchemy library no longer supports Python 3.7 "
56+
"and Python 3.8. "
5557
f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
5658
"recommend that you update soon to ensure ongoing support. For "
5759
"more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
58-
PendingDeprecationWarning,
60+
FutureWarning,
5961
)
6062

6163

testing/constraints-3.9.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This constraints file is used to check that lower bounds
2+
# are correct in setup.py
3+
# List *all* library dependencies and extras in this file.
4+
# Pin the version to the lower bound.
5+
#
6+
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
7+
sqlalchemy==1.4.16
8+
google-auth==1.25.0
9+
google-cloud-bigquery==3.3.6
10+
google-cloud-bigquery-storage==2.0.0
11+
google-api-core==1.31.5
12+
grpcio==1.47.0
13+
numpy==1.26.4
14+
pyarrow==5.0.0

0 commit comments

Comments
 (0)