Skip to content

Commit 1326bb6

Browse files
committed
chore: revert noxfile and test tweaks for specific packages
1 parent 03d6dda commit 1326bb6

File tree

8 files changed

+82
-298
lines changed

8 files changed

+82
-298
lines changed

packages/bigframes/noxfile.py

Lines changed: 59 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import multiprocessing
2121
import os
2222
import pathlib
23-
import re
2423
import shutil
2524
import time
2625
from typing import Dict, List
@@ -62,7 +61,6 @@
6261
"pytest-cov",
6362
"pytest-timeout",
6463
]
65-
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
6664
UNIT_TEST_DEPENDENCIES: List[str] = []
6765
UNIT_TEST_EXTRAS: List[str] = ["tests"]
6866
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
@@ -95,7 +93,7 @@
9593
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [
9694
"google-cloud-bigquery",
9795
]
98-
SYSTEM_TEST_EXTRAS: List[str] = []
96+
SYSTEM_TEST_EXTRAS: List[str] = ["tests"]
9997
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
10098
# Make sure we leave some versions without "extras" so we know those
10199
# dependencies are actually optional.
@@ -191,15 +189,6 @@ def format(session):
191189
*LINT_PATHS,
192190
)
193191

194-
# 3. Run Ruff to format code
195-
session.run(
196-
"ruff",
197-
"format",
198-
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
199-
"--line-length=88", # Standard Black line length
200-
*LINT_PATHS,
201-
)
202-
203192

204193
@nox.session(python=DEFAULT_PYTHON_VERSION)
205194
def lint_setup_py(session):
@@ -266,14 +255,10 @@ def run_unit(session, install_test_extra):
266255

267256

268257
@nox.session(python=ALL_PYTHON)
269-
@nox.parametrize("test_extra", [True, False])
270-
def unit(session, test_extra):
258+
def unit(session):
271259
if session.python in ("3.7", "3.8", "3.9"):
272260
session.skip("Python 3.9 and below are not supported")
273-
if test_extra:
274-
run_unit(session, install_test_extra=test_extra)
275-
else:
276-
unit_noextras(session)
261+
run_unit(session, install_test_extra=True)
277262

278263

279264
@nox.session(python=ALL_PYTHON[-1])
@@ -376,15 +361,14 @@ def run_system(
376361
@nox.session(python="3.12")
377362
def system(session: nox.sessions.Session):
378363
"""Run the system test suite."""
379-
if session.python in ("3.7", "3.8", "3.9"):
380-
session.skip("Python 3.9 and below are not supported")
381-
364+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16489): Restore system test once this bug is fixed
382365
run_system(
383366
session=session,
384367
prefix_name="system",
385368
test_folder=os.path.join("tests", "system", "small"),
386369
check_cov=True,
387370
)
371+
# session.skip("Temporarily skip system test")
388372

389373

390374
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -401,10 +385,6 @@ def system_noextras(session: nox.sessions.Session):
401385
@nox.session(python="3.12")
402386
def doctest(session: nox.sessions.Session):
403387
"""Run the system test suite."""
404-
session.skip(
405-
"Temporary skip to enable a PR merge. Remove skip as part of closing https://github.com/googleapis/google-cloud-python/issues/16489"
406-
)
407-
408388
run_system(
409389
session=session,
410390
prefix_name="doctest",
@@ -460,10 +440,6 @@ def cover(session):
460440
This outputs the coverage report aggregating coverage from the test runs
461441
(including system test runs), and then erases coverage data.
462442
"""
463-
# TODO: Remove this skip when the issue is resolved.
464-
# https://github.com/googleapis/google-cloud-python/issues/16635
465-
session.skip("Temporarily skip coverage session")
466-
467443
session.install("coverage", "pytest-cov")
468444

469445
# Create a coverage report that includes only the product code.
@@ -945,129 +921,69 @@ def cleanup(session):
945921

946922

947923
@nox.session(python=DEFAULT_PYTHON_VERSION)
948-
@nox.parametrize(
949-
"protobuf_implementation",
950-
["python", "upb"],
951-
)
952-
def core_deps_from_source(session, protobuf_implementation):
924+
def core_deps_from_source(session):
953925
"""Run all tests with core dependencies installed from source
954926
rather than pulling the dependencies from PyPI.
955927
"""
956-
957-
# Install all dependencies
958-
session.install("-e", ".")
959-
960-
# Install dependencies for the unit test environment
961-
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
962-
session.install(*unit_deps_all)
963-
964-
# Install dependencies for the system test environment
965-
system_deps_all = (
966-
SYSTEM_TEST_STANDARD_DEPENDENCIES
967-
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
968-
+ SYSTEM_TEST_EXTRAS
969-
)
970-
session.install(*system_deps_all)
971-
972-
# Because we test minimum dependency versions on the minimum Python
973-
# version, the first version we test with in the unit tests sessions has a
974-
# constraints file containing all dependencies and extras.
975-
with open(
976-
CURRENT_DIRECTORY / "testing" / "constraints-3.10.txt",
977-
encoding="utf-8",
978-
) as constraints_file:
979-
constraints_text = constraints_file.read()
980-
981-
# Ignore leading whitespace and comment lines.
982-
# Fiona fails to build on GitHub CI because gdal-config is missing and no Python 3.14 wheels are available.
983-
constraints_deps = [
984-
match.group(1)
985-
for match in re.finditer(
986-
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
987-
)
988-
if match.group(1) != "fiona"
989-
]
990-
991-
# Install dependencies specified in `testing/constraints-X.txt`.
992-
session.install(*constraints_deps)
993-
994-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and
995-
# `grpcio-status` should be added to the list below so that they are installed from source,
996-
# rather than PyPI.
997-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be
998-
# added to the list below so that it is installed from source, rather than PyPI
999-
# Note: If a dependency is added to the `core_dependencies_from_source` list,
1000-
# the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
1001-
core_dependencies_from_source = [
1002-
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
1003-
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
1004-
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
1005-
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
1006-
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
1007-
]
1008-
1009-
for dep in core_dependencies_from_source:
1010-
session.install(dep, "--no-deps", "--ignore-installed")
1011-
print(f"Installed {dep}")
1012-
1013-
session.run(
1014-
"py.test",
1015-
"tests/unit",
1016-
env={
1017-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
1018-
},
1019-
)
928+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
929+
# Add core deps from source tests
930+
session.skip("Core deps from source tests are not yet supported")
1020931

1021932

1022-
@nox.session(python=ALL_PYTHON[-1])
933+
@nox.session(python=DEFAULT_PYTHON_VERSION)
1023934
def prerelease_deps(session):
1024935
"""Run all tests with prerelease versions of dependencies installed."""
1025936
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
1026937
# Add prerelease deps tests
1027-
unit_prerelease(session)
1028-
system_prerelease(session)
938+
session.skip("prerelease deps tests are not yet supported")
1029939

1030940

1031-
# NOTE: this is based on mypy session that came directly from the bigframes split repo
1032-
# the split repo used 3.10, the monorepo uses 3.14
1033-
@nox.session(python="3.14")
941+
@nox.session(python=DEFAULT_PYTHON_VERSION)
1034942
def mypy(session):
1035-
"""Run type checks with mypy."""
1036-
# Editable mode is not compatible with mypy when there are multiple
1037-
# package directories. See:
1038-
# https://github.com/python/mypy/issues/10564#issuecomment-851687749
1039-
session.install(".")
1040-
1041-
# Just install the dependencies' type info directly, since "mypy --install-types"
1042-
# might require an additional pass.
1043-
deps = (
1044-
set(
1045-
[
1046-
MYPY_VERSION,
1047-
# TODO: update to latest pandas-stubs once we resolve bigframes issues.
1048-
"pandas-stubs<=2.2.3.241126",
1049-
"types-protobuf",
1050-
"types-python-dateutil",
1051-
"types-requests",
1052-
"types-setuptools",
1053-
"types-tabulate",
1054-
"types-PyYAML",
1055-
"polars",
1056-
"anywidget",
1057-
]
1058-
)
1059-
| set(SYSTEM_TEST_STANDARD_DEPENDENCIES)
1060-
| set(UNIT_TEST_STANDARD_DEPENDENCIES)
1061-
)
1062-
1063-
session.install(*deps)
1064-
shutil.rmtree(".mypy_cache", ignore_errors=True)
1065-
session.run(
1066-
"mypy",
1067-
"bigframes",
1068-
os.path.join("tests", "system"),
1069-
os.path.join("tests", "unit"),
1070-
"--check-untyped-defs",
1071-
"--explicit-package-bases",
1072-
'--exclude="^third_party"',
1073-
)
943+
"""Run the type checker."""
944+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
945+
# Add mypy tests previously used mypy session (below) failed to run in the monorepo
946+
session.skip("mypy tests are not yet supported")
947+
948+
949+
# @nox.session(python=ALL_PYTHON)
950+
# def mypy(session):
951+
# """Run type checks with mypy."""
952+
# # Editable mode is not compatible with mypy when there are multiple
953+
# # package directories. See:
954+
# # https://github.com/python/mypy/issues/10564#issuecomment-851687749
955+
# session.install(".")
956+
957+
# # Just install the dependencies' type info directly, since "mypy --install-types"
958+
# # might require an additional pass.
959+
# deps = (
960+
# set(
961+
# [
962+
# MYPY_VERSION,
963+
# # TODO: update to latest pandas-stubs once we resolve bigframes issues.
964+
# "pandas-stubs<=2.2.3.241126",
965+
# "types-protobuf",
966+
# "types-python-dateutil",
967+
# "types-requests",
968+
# "types-setuptools",
969+
# "types-tabulate",
970+
# "types-PyYAML",
971+
# "polars",
972+
# "anywidget",
973+
# ]
974+
# )
975+
# | set(SYSTEM_TEST_STANDARD_DEPENDENCIES)
976+
# | set(UNIT_TEST_STANDARD_DEPENDENCIES)
977+
# )
978+
979+
# session.install(*deps)
980+
# shutil.rmtree(".mypy_cache", ignore_errors=True)
981+
# session.run(
982+
# "mypy",
983+
# "bigframes",
984+
# os.path.join("tests", "system"),
985+
# os.path.join("tests", "unit"),
986+
# "--check-untyped-defs",
987+
# "--explicit-package-bases",
988+
# '--exclude="^third_party"',
989+
# )

packages/google-cloud-bigquery/noxfile.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414

1515
from __future__ import absolute_import
1616

17+
from functools import wraps
1718
import os
1819
import pathlib
1920
import re
2021
import shutil
2122
import time
22-
from functools import wraps
2323

2424
import nox
2525

2626
MYPY_VERSION = "mypy==1.6.1"
2727
BLACK_VERSION = "black==23.7.0"
28-
RUFF_VERSION = "ruff==0.14.14"
2928
ISORT_VERSION = "isort==5.10.1"
3029
BLACK_PATHS = (
3130
"benchmark",
@@ -551,31 +550,16 @@ def core_deps_from_source(session):
551550
session.skip("Core deps from source tests are not yet supported")
552551

553552

554-
@nox.session(python=DEFAULT_PYTHON_VERSION)
553+
@nox.session
555554
def format(session: nox.sessions.Session) -> None:
556555
"""
557-
Run ruff to sort imports and format code.
556+
Run isort to sort imports. Then run black
557+
to format code to uniform standard.
558558
"""
559-
# 1. Install ruff (skipped automatically if you run with --no-venv)
560-
session.install(RUFF_VERSION)
561-
562-
# 2. Run Ruff to fix imports
563-
session.run(
564-
"ruff",
565-
"check",
566-
"--select",
567-
"I",
568-
"--fix",
569-
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
570-
"--line-length=88",
571-
*BLACK_PATHS,
572-
)
559+
session.install(BLACK_VERSION, ISORT_VERSION)
560+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
573561

574-
# 3. Run Ruff to format code
575-
session.run(
576-
"ruff",
577-
"format",
578-
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
579-
"--line-length=88",
580-
*BLACK_PATHS,
581-
)
562+
# Use the --fss option to sort imports using strict alphabetical order.
563+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
564+
session.run("isort", "--fss", *python_files)
565+
session.run("black", *python_files)

packages/google-cloud-bigquery/tests/unit/job/test_async_job_retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_result_w_retry_wo_state(global_time_lock):
110110
predicate=custom_predicate,
111111
initial=0.001,
112112
maximum=0.001,
113-
deadline=1.0, # Increased from 0.1 to avoid flakiness in slow environments
113+
deadline=0.1,
114114
)
115115
assert job.result(retry=custom_retry) is job
116116

0 commit comments

Comments
 (0)