Skip to content

Commit cb385ab

Browse files
authored
Merge branch 'autogen' into test/adds-generate-typing-checks-2
2 parents 548f0a9 + f5c24b9 commit cb385ab

File tree

7 files changed

+339
-174
lines changed

7 files changed

+339
-174
lines changed

.github/workflows/unittest.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
runs-on: ubuntu-22.04
2020
strategy:
2121
matrix:
22-
python: ['3.9', '3.10', "3.11", "3.12", "3.13"]
22+
python: ["3.13"] # TODO: For alpha release purposes, microgenerator tests
23+
# are limited to Python 3.13. By default this also limits
24+
# GAPIC tests. Once the testing kinks are worked out we can
25+
# explore a more comprehensive approach.
2326
steps:
2427
- name: Checkout
2528
uses: actions/checkout@v4
@@ -36,6 +39,7 @@ jobs:
3639
run: |
3740
python -m pip install --upgrade setuptools pip wheel
3841
python -m pip install nox
42+
# These unit tests cover the GAPIC generated code.
3943
- name: Run unit tests
4044
env:
4145
COVERAGE_FILE: .coverage-${{ matrix.python }}
@@ -44,6 +48,15 @@ jobs:
4448
PY_VERSION: ${{ matrix.python }}
4549
run: |
4650
nox -s unit-${{ matrix.python }}
51+
# These unit tests cover the microgenerator module.
52+
- name: Run microgenerator unit tests
53+
env:
54+
COVERAGE_FILE: .coverage-microgenerator-${{ matrix.python }}
55+
BUILD_TYPE: presubmit
56+
TEST_TYPE: unit
57+
PY_VERSION: ${{ matrix.python }}
58+
run: |
59+
nox -f scripts/microgenerator/noxfile.py -s unit-${{ matrix.python }}
4760
- name: Upload coverage results
4861
uses: actions/upload-artifact@v4
4962
with:
@@ -84,4 +97,4 @@ jobs:
8497
run: |
8598
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
8699
coverage combine .coverage-results/**/.coverage*
87-
coverage report --show-missing --fail-under=100
100+
coverage report --show-missing --fail-under=100

scripts/__init__.py

Whitespace-only changes.

scripts/microgenerator/noxfile.py

Lines changed: 8 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from functools import wraps
1818
import pathlib
1919
import os
20-
import shutil
2120
import nox
2221
import time
2322

@@ -28,7 +27,6 @@
2827
BLACK_PATHS = (".",)
2928

3029
DEFAULT_PYTHON_VERSION = "3.9"
31-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.11", "3.12", "3.13"]
3230
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.11", "3.12", "3.13"]
3331
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3432

@@ -56,14 +54,12 @@ def wrapper(*args, **kwargs):
5654
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
5755
nox.options.sessions = [
5856
"unit",
59-
"system",
6057
"cover",
6158
"lint",
6259
"lint_setup_py",
6360
"blacken",
6461
"mypy",
6562
"pytype",
66-
"docs",
6763
]
6864

6965

@@ -95,10 +91,8 @@ def default(session, install_extras=True):
9591
# If no, we use our own context object from magics.py. In order to exercise
9692
# that logic (and the associated tests) we avoid installing the [ipython] extra
9793
# which has a downstream effect of then avoiding installing bigquery_magics.
98-
if install_extras and session.python == UNIT_TEST_PYTHON_VERSIONS[0]:
99-
install_target = ".[bqstorage,pandas,ipywidgets,geopandas,matplotlib,tqdm,opentelemetry,bigquery_v2]"
100-
elif install_extras: # run against all other UNIT_TEST_PYTHON_VERSIONS
101-
install_target = ".[all]"
94+
if install_extras: # run against all other UNIT_TEST_PYTHON_VERSIONS
95+
install_target = "."
10296
else:
10397
install_target = "."
10498
session.install("-e", install_target, "-c", constraints_path)
@@ -107,9 +101,6 @@ def default(session, install_extras=True):
107101
# directly. For example, pandas-gbq is recommended for pandas features, but
108102
# we want to test that we fallback to the previous behavior. For context,
109103
# see internal document go/pandas-gbq-and-bigframes-redundancy.
110-
if session.python == UNIT_TEST_PYTHON_VERSIONS[0]:
111-
session.run("python", "-m", "pip", "uninstall", "pandas-gbq", "-y")
112-
113104
session.run("python", "-m", "pip", "freeze")
114105

115106
# Run py.test against the unit tests.
@@ -118,13 +109,12 @@ def default(session, install_extras=True):
118109
"-n=8",
119110
"--quiet",
120111
"-W default::PendingDeprecationWarning",
121-
"--cov=google/cloud/bigquery",
122-
"--cov=tests/unit",
112+
"--cov=scripts.microgenerator",
123113
"--cov-append",
124114
"--cov-config=.coveragerc",
125115
"--cov-report=",
126116
"--cov-fail-under=0",
127-
os.path.join("tests", "unit"),
117+
"tests/unit",
128118
*session.posargs,
129119
)
130120

@@ -142,7 +132,7 @@ def unit(session):
142132
def mypy(session):
143133
"""Run type checks with mypy."""
144134

145-
session.install("-e", ".[all]")
135+
session.install("-e", ".")
146136
session.install(MYPY_VERSION)
147137

148138
# Just install the dependencies' type info directly, since "mypy --install-types"
@@ -166,77 +156,11 @@ def pytype(session):
166156
# https://github.com/googleapis/python-bigquery/issues/655
167157

168158
session.install("attrs==20.3.0")
169-
session.install("-e", ".[all]")
159+
session.install("-e", ".")
170160
session.install(PYTYPE_VERSION)
171161
session.run("python", "-m", "pip", "freeze")
172162
# See https://github.com/google/pytype/issues/464
173-
session.run("pytype", "-P", ".", "google/cloud/bigquery")
174-
175-
176-
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
177-
@_calculate_duration
178-
def system(session):
179-
"""Run the system test suite."""
180-
181-
constraints_path = str(
182-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
183-
)
184-
185-
# Sanity check: Only run system tests if the environment variable is set.
186-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
187-
session.skip("Credentials must be set via environment variable.")
188-
189-
# Use pre-release gRPC for system tests.
190-
# Exclude version 1.49.0rc1 which has a known issue.
191-
# See https://github.com/grpc/grpc/pull/30642
192-
session.install("--pre", "grpcio!=1.49.0rc1", "-c", constraints_path)
193-
194-
# Install all test dependencies, then install local packages in place.
195-
session.install(
196-
"pytest",
197-
"psutil",
198-
"pytest-xdist",
199-
"google-cloud-testutils",
200-
"-c",
201-
constraints_path,
202-
)
203-
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "") == "true":
204-
# mTLS test requires pyopenssl and latest google-cloud-storage
205-
session.install("google-cloud-storage", "pyopenssl")
206-
else:
207-
session.install("google-cloud-storage", "-c", constraints_path)
208-
209-
# Data Catalog needed for the column ACL test with a real Policy Tag.
210-
session.install("google-cloud-datacatalog", "-c", constraints_path)
211-
212-
# Resource Manager needed for test with a real Resource Tag.
213-
session.install("google-cloud-resource-manager", "-c", constraints_path)
214-
215-
if session.python in ["3.11", "3.12"]:
216-
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
217-
else:
218-
extras = "[all]"
219-
session.install("-e", f".{extras}", "-c", constraints_path)
220-
221-
# Test with some broken "extras" in case the user didn't install the extra
222-
# directly. For example, pandas-gbq is recommended for pandas features, but
223-
# we want to test that we fallback to the previous behavior. For context,
224-
# see internal document go/pandas-gbq-and-bigframes-redundancy.
225-
if session.python == SYSTEM_TEST_PYTHON_VERSIONS[0]:
226-
session.run("python", "-m", "pip", "uninstall", "pandas-gbq", "-y")
227-
228-
# print versions of all dependencies
229-
session.run("python", "-m", "pip", "freeze")
230-
231-
# Run py.test against the system tests.
232-
session.run(
233-
"py.test",
234-
"-n=auto",
235-
"--quiet",
236-
"-W default::PendingDeprecationWarning",
237-
os.path.join("tests", "system"),
238-
*session.posargs,
239-
)
163+
session.run("pytype", "-P", ".", "scripts")
240164

241165

242166
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -266,10 +190,8 @@ def lint(session):
266190
session.install("flake8", BLACK_VERSION)
267191
session.install("-e", ".")
268192
session.run("python", "-m", "pip", "freeze")
269-
session.run("flake8", os.path.join("google", "cloud", "bigquery"))
193+
session.run("flake8", os.path.join("scripts"))
270194
session.run("flake8", "tests")
271-
session.run("flake8", os.path.join("docs", "samples"))
272-
session.run("flake8", os.path.join("docs", "snippets.py"))
273195
session.run("flake8", "benchmark")
274196
session.run("black", "--check", *BLACK_PATHS)
275197

@@ -294,89 +216,3 @@ def blacken(session):
294216
session.install(BLACK_VERSION)
295217
session.run("python", "-m", "pip", "freeze")
296218
session.run("black", *BLACK_PATHS)
297-
298-
299-
@nox.session(python="3.10")
300-
@_calculate_duration
301-
def docs(session):
302-
"""Build the docs."""
303-
304-
session.install(
305-
# We need to pin to specific versions of the `sphinxcontrib-*` packages
306-
# which still support sphinx 4.x.
307-
# See https://github.com/googleapis/sphinx-docfx-yaml/issues/344
308-
# and https://github.com/googleapis/sphinx-docfx-yaml/issues/345.
309-
"sphinxcontrib-applehelp==1.0.4",
310-
"sphinxcontrib-devhelp==1.0.2",
311-
"sphinxcontrib-htmlhelp==2.0.1",
312-
"sphinxcontrib-qthelp==1.0.3",
313-
"sphinxcontrib-serializinghtml==1.1.5",
314-
"sphinx==4.5.0",
315-
"alabaster",
316-
"recommonmark",
317-
)
318-
session.install("google-cloud-storage")
319-
session.install("-e", ".[all]")
320-
321-
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
322-
session.run("python", "-m", "pip", "freeze")
323-
session.run(
324-
"sphinx-build",
325-
"-W", # warnings as errors
326-
"-T", # show full traceback on exception
327-
"-N", # no colors
328-
"-b",
329-
"html",
330-
"-d",
331-
os.path.join("docs", "_build", "doctrees", ""),
332-
os.path.join("docs", ""),
333-
os.path.join("docs", "_build", "html", ""),
334-
)
335-
336-
337-
@nox.session(python="3.10")
338-
@_calculate_duration
339-
def docfx(session):
340-
"""Build the docfx yaml files for this library."""
341-
342-
session.install("-e", ".")
343-
session.install(
344-
# We need to pin to specific versions of the `sphinxcontrib-*` packages
345-
# which still support sphinx 4.x.
346-
# See https://github.com/googleapis/sphinx-docfx-yaml/issues/344
347-
# and https://github.com/googleapis/sphinx-docfx-yaml/issues/345.
348-
"sphinxcontrib-applehelp==1.0.4",
349-
"sphinxcontrib-devhelp==1.0.2",
350-
"sphinxcontrib-htmlhelp==2.0.1",
351-
"sphinxcontrib-qthelp==1.0.3",
352-
"sphinxcontrib-serializinghtml==1.1.5",
353-
"gcp-sphinx-docfx-yaml",
354-
"alabaster",
355-
"recommonmark",
356-
)
357-
358-
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
359-
session.run("python", "-m", "pip", "freeze")
360-
session.run(
361-
"sphinx-build",
362-
"-T", # show full traceback on exception
363-
"-N", # no colors
364-
"-D",
365-
(
366-
"extensions=sphinx.ext.autodoc,"
367-
"sphinx.ext.autosummary,"
368-
"docfx_yaml.extension,"
369-
"sphinx.ext.intersphinx,"
370-
"sphinx.ext.coverage,"
371-
"sphinx.ext.napoleon,"
372-
"sphinx.ext.todo,"
373-
"sphinx.ext.viewcode,"
374-
"recommonmark"
375-
),
376-
"-b",
377-
"html",
378-
"-d",
379-
os.path.join("docs", "_build", "doctrees", ""),
380-
os.path.join("docs", ""),
381-
os.path.join("docs", "_build", "html", ""),
382-
)

scripts/microgenerator/setup.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
import setuptools # type: ignore
17+
18+
name = "google-cloud-bigquery_v2-centralized-client"
19+
description = "Google Cloud Bigquery V2 Centralized Client Microgenerator"
20+
version = "0.1.0"
21+
22+
if version[0] == "0":
23+
release_status = "Development Status :: 4 - Beta"
24+
else:
25+
release_status = "Development Status :: 5 - Production/Stable"
26+
27+
dependencies = [ # TODO: break out development reqs from generation requirements
28+
"PyYAML",
29+
"Jinja2",
30+
]
31+
extras = {}
32+
33+
packages = [
34+
package
35+
for package in setuptools.find_namespace_packages()
36+
if package.startswith("google")
37+
]
38+
39+
setuptools.setup(
40+
name=name,
41+
version=version,
42+
description=description,
43+
author="Google LLC",
44+
author_email="[email protected]",
45+
license="Apache 2.0",
46+
classifiers=[
47+
release_status,
48+
"Intended Audience :: Developers",
49+
"License :: OSI Approved :: Apache Software License",
50+
"Programming Language :: Python",
51+
"Programming Language :: Python :: 3",
52+
"Programming Language :: Python :: 3.13",
53+
"Operating System :: OS Independent",
54+
"Topic :: Internet",
55+
],
56+
platforms="Posix; MacOS X; Windows",
57+
packages=packages,
58+
python_requires=">=3.12",
59+
install_requires=dependencies,
60+
extras_require=extras,
61+
include_package_data=True,
62+
zip_safe=False,
63+
)

scripts/microgenerator/tests/__init__.py

Whitespace-only changes.

scripts/microgenerator/tests/unit/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)