Skip to content

Commit 2853cae

Browse files
committed
Revert changes to bigframes/noxfile.py to match main
1 parent c399fb2 commit 2853cae

1 file changed

Lines changed: 134 additions & 59 deletions

File tree

packages/bigframes/noxfile.py

Lines changed: 134 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import multiprocessing
2121
import os
2222
import pathlib
23+
import re
2324
import shutil
2425
import time
2526
from typing import Dict, List
@@ -61,6 +62,7 @@
6162
"pytest-cov",
6263
"pytest-timeout",
6364
]
65+
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
6466
UNIT_TEST_DEPENDENCIES: List[str] = []
6567
UNIT_TEST_EXTRAS: List[str] = ["tests"]
6668
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
@@ -93,7 +95,7 @@
9395
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [
9496
"google-cloud-bigquery",
9597
]
96-
SYSTEM_TEST_EXTRAS: List[str] = ["tests"]
98+
SYSTEM_TEST_EXTRAS: List[str] = []
9799
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
98100
# Make sure we leave some versions without "extras" so we know those
99101
# dependencies are actually optional.
@@ -255,10 +257,14 @@ def run_unit(session, install_test_extra):
255257

256258

257259
@nox.session(python=ALL_PYTHON)
258-
def unit(session):
260+
@nox.parametrize("test_extra", [True, False])
261+
def unit(session, test_extra):
259262
if session.python in ("3.7", "3.8", "3.9"):
260263
session.skip("Python 3.9 and below are not supported")
261-
run_unit(session, install_test_extra=True)
264+
if test_extra:
265+
run_unit(session, install_test_extra=test_extra)
266+
else:
267+
unit_noextras(session)
262268

263269

264270
@nox.session(python=ALL_PYTHON[-1])
@@ -361,14 +367,15 @@ def run_system(
361367
@nox.session(python="3.12")
362368
def system(session: nox.sessions.Session):
363369
"""Run the system test suite."""
364-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16489): Restore system test once this bug is fixed
370+
if session.python in ("3.7", "3.8", "3.9"):
371+
session.skip("Python 3.9 and below are not supported")
372+
365373
run_system(
366374
session=session,
367375
prefix_name="system",
368376
test_folder=os.path.join("tests", "system", "small"),
369377
check_cov=True,
370378
)
371-
# session.skip("Temporarily skip system test")
372379

373380

374381
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -385,6 +392,10 @@ def system_noextras(session: nox.sessions.Session):
385392
@nox.session(python="3.12")
386393
def doctest(session: nox.sessions.Session):
387394
"""Run the system test suite."""
395+
session.skip(
396+
"Temporary skip to enable a PR merge. Remove skip as part of closing https://github.com/googleapis/google-cloud-python/issues/16489"
397+
)
398+
388399
run_system(
389400
session=session,
390401
prefix_name="doctest",
@@ -440,6 +451,10 @@ def cover(session):
440451
This outputs the coverage report aggregating coverage from the test runs
441452
(including system test runs), and then erases coverage data.
442453
"""
454+
# TODO: Remove this skip when the issue is resolved.
455+
# https://github.com/googleapis/google-cloud-python/issues/16635
456+
session.skip("Temporarily skip coverage session")
457+
443458
session.install("coverage", "pytest-cov")
444459

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

922937

923938
@nox.session(python=DEFAULT_PYTHON_VERSION)
924-
def core_deps_from_source(session):
939+
@nox.parametrize(
940+
"protobuf_implementation",
941+
["python", "upb"],
942+
)
943+
def core_deps_from_source(session, protobuf_implementation):
925944
"""Run all tests with core dependencies installed from source
926945
rather than pulling the dependencies from PyPI.
927946
"""
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")
931947

948+
# Install all dependencies
949+
session.install("-e", ".")
932950

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

9401021

941-
@nox.session(python=DEFAULT_PYTHON_VERSION)
1022+
# NOTE: this is based on mypy session that came directly from the bigframes split repo
1023+
# the split repo used 3.10, the monorepo uses 3.14
1024+
@nox.session(python="3.14")
9421025
def mypy(session):
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-
# )
1026+
"""Run type checks with mypy."""
1027+
# Editable mode is not compatible with mypy when there are multiple
1028+
# package directories. See:
1029+
# https://github.com/python/mypy/issues/10564#issuecomment-851687749
1030+
session.install(".")
1031+
1032+
# Just install the dependencies' type info directly, since "mypy --install-types"
1033+
# might require an additional pass.
1034+
deps = (
1035+
set(
1036+
[
1037+
MYPY_VERSION,
1038+
# TODO: update to latest pandas-stubs once we resolve bigframes issues.
1039+
"pandas-stubs<=2.2.3.241126",
1040+
"types-protobuf",
1041+
"types-python-dateutil",
1042+
"types-requests",
1043+
"types-setuptools",
1044+
"types-tabulate",
1045+
"types-PyYAML",
1046+
"polars",
1047+
"anywidget",
1048+
]
1049+
)
1050+
| set(SYSTEM_TEST_STANDARD_DEPENDENCIES)
1051+
| set(UNIT_TEST_STANDARD_DEPENDENCIES)
1052+
)
1053+
1054+
session.install(*deps)
1055+
shutil.rmtree(".mypy_cache", ignore_errors=True)
1056+
session.run(
1057+
"mypy",
1058+
"bigframes",
1059+
os.path.join("tests", "system"),
1060+
os.path.join("tests", "unit"),
1061+
"--check-untyped-defs",
1062+
"--explicit-package-bases",
1063+
'--exclude="^third_party"',
1064+
)

0 commit comments

Comments
 (0)