Skip to content

Commit 4e86c04

Browse files
committed
adds debugging to noxfile and tweaks to correct coverage
1 parent 6f11d53 commit 4e86c04

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

@@ -100,6 +102,27 @@
100102

101103
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
102104

105+
106+
def _calculate_duration(func):
107+
"""This decorator prints the execution time for the decorated function."""
108+
109+
@wraps(func)
110+
def wrapper(*args, **kwargs):
111+
start = time.monotonic()
112+
result = func(*args, **kwargs)
113+
end = time.monotonic()
114+
total_seconds = round(end - start)
115+
hours = total_seconds // 3600 # Integer division to get hours
116+
remaining_seconds = total_seconds % 3600 # Modulo to find remaining seconds
117+
minutes = remaining_seconds // 60
118+
seconds = remaining_seconds % 60
119+
human_time = f"{hours:}:{minutes:0>2}:{seconds:0>2}"
120+
print(f"Session ran in {total_seconds} seconds ({human_time})")
121+
return result
122+
123+
return wrapper
124+
125+
103126
nox.options.sessions = [
104127
"unit",
105128
"system",
@@ -118,13 +141,15 @@
118141

119142

120143
@nox.session(python=DEFAULT_PYTHON_VERSION)
144+
@_calculate_duration
121145
def lint(session):
122146
"""Run linters.
123147
124148
Returns a failure if the linters find linting errors or sufficiently
125149
serious code quality issues.
126150
"""
127151
session.install(FLAKE8_VERSION, BLACK_VERSION)
152+
session.run("python", "-m", "pip", "freeze")
128153
session.run(
129154
"black",
130155
"--check",
@@ -134,16 +159,19 @@ def lint(session):
134159

135160

136161
@nox.session(python=DEFAULT_PYTHON_VERSION)
162+
@_calculate_duration
137163
def blacken(session):
138164
"""Run black. Format code to uniform standard."""
139165
session.install(BLACK_VERSION)
166+
session.run("python", "-m", "pip", "freeze")
140167
session.run(
141168
"black",
142169
*LINT_PATHS,
143170
)
144171

145172

146173
@nox.session(python=DEFAULT_PYTHON_VERSION)
174+
@_calculate_duration
147175
def format(session):
148176
"""
149177
Run isort to sort imports. Then run black
@@ -152,6 +180,7 @@ def format(session):
152180
session.install(BLACK_VERSION, ISORT_VERSION)
153181
# Use the --fss option to sort imports using strict alphabetical order.
154182
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
183+
session.run("python", "-m", "pip", "freeze")
155184
session.run(
156185
"isort",
157186
"--fss",
@@ -164,9 +193,11 @@ def format(session):
164193

165194

166195
@nox.session(python=DEFAULT_PYTHON_VERSION)
196+
@_calculate_duration
167197
def lint_setup_py(session):
168198
"""Verify that setup.py is valid (including RST check)."""
169199
session.install("docutils", "pygments")
200+
session.run("python", "-m", "pip", "freeze")
170201
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
171202

172203

@@ -203,6 +234,7 @@ def install_unittest_dependencies(session, *constraints):
203234
"protobuf_implementation",
204235
["python", "upb", "cpp"],
205236
)
237+
@_calculate_duration
206238
def unit(session, protobuf_implementation, install_extras=True):
207239
# Install all test dependencies, then install this package in-place.
208240

@@ -229,6 +261,7 @@ def unit(session, protobuf_implementation, install_extras=True):
229261
session.install("protobuf<4")
230262

231263
# Run py.test against the unit tests.
264+
session.run("python", "-m", "pip", "freeze")
232265
session.run(
233266
"py.test",
234267
"--quiet",
@@ -278,6 +311,7 @@ def install_systemtest_dependencies(session, *constraints):
278311

279312

280313
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
314+
@_calculate_duration
281315
def system(session):
282316
"""Run the system test suite."""
283317
constraints_path = str(
@@ -300,6 +334,7 @@ def system(session):
300334
session.skip("System tests were not found")
301335

302336
install_systemtest_dependencies(session, "-c", constraints_path)
337+
session.run("python", "-m", "pip", "freeze")
303338

304339
# Run py.test against the system tests.
305340
if system_test_exists:
@@ -321,6 +356,7 @@ def system(session):
321356

322357

323358
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
359+
@_calculate_duration
324360
def system_noextras(session):
325361
"""Run the system test suite."""
326362
constraints_path = str(
@@ -345,6 +381,7 @@ def system_noextras(session):
345381
global SYSTEM_TEST_EXTRAS_BY_PYTHON
346382
SYSTEM_TEST_EXTRAS_BY_PYTHON = False
347383
install_systemtest_dependencies(session, "-c", constraints_path)
384+
session.run("python", "-m", "pip", "freeze")
348385

349386
# Run py.test against the system tests.
350387
if system_test_exists:
@@ -366,6 +403,7 @@ def system_noextras(session):
366403

367404

368405
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])
406+
@_calculate_duration
369407
def compliance(session):
370408
"""Run the SQLAlchemy dialect-compliance system tests"""
371409
constraints_path = str(
@@ -418,19 +456,22 @@ def compliance(session):
418456

419457

420458
@nox.session(python=DEFAULT_PYTHON_VERSION)
459+
@_calculate_duration
421460
def cover(session):
422461
"""Run the final coverage report.
423462
424463
This outputs the coverage report aggregating coverage from the unit
425464
test runs (not system test runs), and then erases coverage data.
426465
"""
427466
session.install("coverage", "pytest-cov")
467+
session.run("python", "-m", "pip", "freeze")
428468
session.run("coverage", "report", "--show-missing", "--fail-under=100")
429469

430470
session.run("coverage", "erase")
431471

432472

433473
@nox.session(python="3.10")
474+
@_calculate_duration
434475
def docs(session):
435476
"""Build the docs for this library."""
436477

@@ -453,6 +494,7 @@ def docs(session):
453494
)
454495

455496
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
497+
session.run("python", "-m", "pip", "freeze")
456498
session.run(
457499
"sphinx-build",
458500
"-W", # warnings as errors
@@ -468,6 +510,7 @@ def docs(session):
468510

469511

470512
@nox.session(python="3.10")
513+
@_calculate_duration
471514
def docfx(session):
472515
"""Build the docfx yaml files for this library."""
473516

@@ -490,6 +533,7 @@ def docfx(session):
490533
)
491534

492535
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
536+
session.run("python", "-m", "pip", "freeze")
493537
session.run(
494538
"sphinx-build",
495539
"-T", # show full traceback on exception
@@ -520,6 +564,7 @@ def docfx(session):
520564
"protobuf_implementation",
521565
["python", "upb", "cpp"],
522566
)
567+
@_calculate_duration
523568
def prerelease_deps(session, protobuf_implementation):
524569
"""Run all tests with prerelease versions of dependencies installed."""
525570

@@ -581,6 +626,7 @@ def prerelease_deps(session, protobuf_implementation):
581626
"requests",
582627
]
583628
session.install(*other_deps)
629+
session.run("python", "-m", "pip", "freeze")
584630

585631
# Print out prerelease package versions
586632
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)