Skip to content

Commit 8d9ee7c

Browse files
yoshi-automationJim Fulton
andauthored
chore: pick up autosynth changes (#185)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * Updated synth.py to recover some prevous manual changes. Co-authored-by: Jim Fulton <jim@jimfulton.info>
1 parent af4ba17 commit 8d9ee7c

File tree

7 files changed

+161
-96
lines changed

7 files changed

+161
-96
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# Generated by synthtool. DO NOT EDIT!
1818
[run]
1919
branch = True
20+
omit =
21+
pybigquery/requirements.py
2022

2123
[report]
2224
fail_under = 100

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ repos:
2626
hooks:
2727
- id: black
2828
- repo: https://gitlab.com/pycqa/flake8
29-
rev: 3.9.1
29+
rev: 3.9.2
3030
hooks:
3131
- id: flake8

docs/multiprocessing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. note::
22

3-
Because this client uses :mod:`grpcio` library, it is safe to
3+
Because this client uses :mod:`grpc` library, it is safe to
44
share instances across threads. In multiprocessing scenarios, the best
55
practice is to create client instances *after* the invocation of
6-
:func:`os.fork` by :class:`multiprocessing.Pool` or
6+
:func:`os.fork` by :class:`multiprocessing.pool.Pool` or
77
:class:`multiprocessing.Process`.

noxfile.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
]
4949

5050
# Error if a python version is missing
51-
nox.options.error_on_missing_interpreters = True
5251
nox.options.stop_on_first_error = True
52+
nox.options.error_on_missing_interpreters = True
5353

5454

5555
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -86,7 +86,7 @@ def install_alembic_for_python_38(session, constraints_path):
8686
"""
8787
install alembic for Python 3.8 unit and system tests
8888
89-
We don't require alembic and most tests should run without it, however
89+
We do not require alembic and most tests should run without it, however
9090
9191
- We run some unit tests (Python 3.8) to cover the alembic
9292
registration that happens when alembic is installed.
@@ -105,6 +105,7 @@ def default(session):
105105
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
106106
)
107107
session.install("mock", "pytest", "pytest-cov", "-c", constraints_path)
108+
108109
install_alembic_for_python_38(session, constraints_path)
109110
session.install("-e", ".", "-c", constraints_path)
110111

@@ -182,30 +183,23 @@ def system(session):
182183

183184
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
184185
def compliance(session):
185-
"""Run the system test suite."""
186+
"""Run the SQLAlchemy dialect-compliance system tests"""
186187
constraints_path = str(
187188
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
188189
)
189190
system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance")
190191

191-
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
192192
if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false":
193193
session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping")
194-
# Sanity check: Only run tests if the environment variable is set.
195194
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
196195
session.skip("Credentials must be set via environment variable")
197-
# Install pyopenssl for mTLS testing.
198196
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
199197
session.install("pyopenssl")
200-
# Sanity check: only run tests if found.
201198
if not os.path.exists(system_test_folder_path):
202199
session.skip("Compliance tests were not found")
203200

204-
# Use pre-release gRPC for system tests.
205201
session.install("--pre", "grpcio")
206202

207-
# Install all test dependencies, then install this package into the
208-
# virtualenv's dist-packages.
209203
session.install(
210204
"mock",
211205
"pytest",
@@ -249,7 +243,7 @@ def docs(session):
249243
"""Build the docs for this library."""
250244

251245
session.install("-e", ".")
252-
session.install("sphinx", "alabaster", "recommonmark")
246+
session.install("sphinx==4.0.1", "alabaster", "recommonmark")
253247

254248
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
255249
session.run(
@@ -271,7 +265,9 @@ def docfx(session):
271265
"""Build the docfx yaml files for this library."""
272266

273267
session.install("-e", ".")
274-
session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml")
268+
session.install(
269+
"sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml"
270+
)
275271

276272
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
277273
session.run(

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ universal = 1
2020

2121
[sqla_testing]
2222
requirement_cls=pybigquery.requirements:Requirements
23-
profile_file=sqlalchemy_dialect_compliance-profiles.txt
23+
profile_file=.sqlalchemy_dialect_compliance-profiles.txt
2424

2525
[tool:pytest]
2626
addopts= --tb native -v -r fxX -p no:warnings

synth.metadata

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,16 @@
33
{
44
"git": {
55
"name": ".",
6-
"remote": "https://github.com/googleapis/python-bigquery-sqlalchemy.git",
7-
"sha": "0a3151ba2cb5564ebc1bf2c920b4cab210cd73b8"
6+
"remote": "git@github.com:googleapis/python-bigquery-sqlalchemy.git",
7+
"sha": "95b0692e9b83290b5f0bb45f7dd49f9a10bba5e8"
8+
}
9+
},
10+
{
11+
"git": {
12+
"name": "synthtool",
13+
"remote": "https://github.com/googleapis/synthtool.git",
14+
"sha": "1778de119522ea9c9b18763c2a4577e22a60433c"
815
}
916
}
10-
],
11-
"generatedFiles": [
12-
".coveragerc",
13-
".flake8",
14-
".github/CONTRIBUTING.md",
15-
".github/ISSUE_TEMPLATE/bug_report.md",
16-
".github/ISSUE_TEMPLATE/feature_request.md",
17-
".github/ISSUE_TEMPLATE/support_request.md",
18-
".github/PULL_REQUEST_TEMPLATE.md",
19-
".github/header-checker-lint.yml",
20-
".github/release-please.yml",
21-
".github/snippet-bot.yml",
22-
".gitignore",
23-
".kokoro/build.sh",
24-
".kokoro/continuous/common.cfg",
25-
".kokoro/continuous/continuous.cfg",
26-
".kokoro/docker/docs/Dockerfile",
27-
".kokoro/docker/docs/fetch_gpg_keys.sh",
28-
".kokoro/docs/common.cfg",
29-
".kokoro/docs/docs-presubmit.cfg",
30-
".kokoro/docs/docs.cfg",
31-
".kokoro/populate-secrets.sh",
32-
".kokoro/presubmit/common.cfg",
33-
".kokoro/presubmit/presubmit.cfg",
34-
".kokoro/publish-docs.sh",
35-
".kokoro/release.sh",
36-
".kokoro/release/common.cfg",
37-
".kokoro/release/release.cfg",
38-
".kokoro/samples/lint/common.cfg",
39-
".kokoro/samples/lint/continuous.cfg",
40-
".kokoro/samples/lint/periodic.cfg",
41-
".kokoro/samples/lint/presubmit.cfg",
42-
".kokoro/samples/python3.6/common.cfg",
43-
".kokoro/samples/python3.6/continuous.cfg",
44-
".kokoro/samples/python3.6/periodic-head.cfg",
45-
".kokoro/samples/python3.6/periodic.cfg",
46-
".kokoro/samples/python3.6/presubmit.cfg",
47-
".kokoro/samples/python3.7/common.cfg",
48-
".kokoro/samples/python3.7/continuous.cfg",
49-
".kokoro/samples/python3.7/periodic-head.cfg",
50-
".kokoro/samples/python3.7/periodic.cfg",
51-
".kokoro/samples/python3.7/presubmit.cfg",
52-
".kokoro/samples/python3.8/common.cfg",
53-
".kokoro/samples/python3.8/continuous.cfg",
54-
".kokoro/samples/python3.8/periodic-head.cfg",
55-
".kokoro/samples/python3.8/periodic.cfg",
56-
".kokoro/samples/python3.8/presubmit.cfg",
57-
".kokoro/test-samples-against-head.sh",
58-
".kokoro/test-samples-impl.sh",
59-
".kokoro/test-samples.sh",
60-
".kokoro/trampoline.sh",
61-
".kokoro/trampoline_v2.sh",
62-
".pre-commit-config.yaml",
63-
".trampolinerc",
64-
"CODE_OF_CONDUCT.md",
65-
"CONTRIBUTING.rst",
66-
"MANIFEST.in",
67-
"docs/_static/custom.css",
68-
"docs/_templates/layout.html",
69-
"docs/conf.py",
70-
"docs/multiprocessing.rst",
71-
"noxfile.py",
72-
"renovate.json",
73-
"scripts/decrypt-secrets.sh",
74-
"scripts/readme-gen/readme_gen.py",
75-
"scripts/readme-gen/templates/README.tmpl.rst",
76-
"scripts/readme-gen/templates/auth.tmpl.rst",
77-
"scripts/readme-gen/templates/auth_api_key.tmpl.rst",
78-
"scripts/readme-gen/templates/install_deps.tmpl.rst",
79-
"scripts/readme-gen/templates/install_portaudio.tmpl.rst",
80-
"setup.cfg",
81-
"testing/.gitignore"
8217
]
8318
}

synth.py

Lines changed: 138 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
# ----------------------------------------------------------------------------
3030
templated_files = common.py_library(
3131
unit_test_python_versions=["3.6", "3.7", "3.8", "3.9"],
32-
system_test_python_versions=["3.8"],
33-
cov_level=50
32+
system_test_python_versions=["3.8", "3.9"],
33+
cov_level=100
3434
)
3535
s.move(templated_files, excludes=[
3636
# pybigquery was originally licensed MIT
@@ -41,6 +41,12 @@
4141
# Fixup files
4242
# ----------------------------------------------------------------------------
4343

44+
s.replace(
45+
[".coveragerc"],
46+
"google/cloud/__init__.py",
47+
"pybigquery/requirements.py",
48+
)
49+
4450
s.replace(
4551
["noxfile.py"],
4652
r"[\"']google[\"']",
@@ -51,6 +57,132 @@
5157
["noxfile.py"], "google/cloud", "pybigquery",
5258
)
5359

60+
def place_before(path, text, *before_text, escape=None):
61+
replacement = "\n".join(before_text) + "\n" + text
62+
if escape:
63+
for c in escape:
64+
text = text.replace(c, '\\' + c)
65+
s.replace([path], text, replacement)
66+
67+
place_before(
68+
"noxfile.py",
69+
"SYSTEM_TEST_PYTHON_VERSIONS=",
70+
"",
71+
"# We're using two Python versions to test with sqlalchemy 1.3 and 1.4.",
72+
)
73+
74+
place_before(
75+
"noxfile.py",
76+
"nox.options.error_on_missing_interpreters = True",
77+
"nox.options.stop_on_first_error = True",
78+
)
79+
80+
install_alembic_for_python_38 = '''
81+
def install_alembic_for_python_38(session, constraints_path):
82+
"""
83+
install alembic for Python 3.8 unit and system tests
84+
85+
We do not require alembic and most tests should run without it, however
86+
87+
- We run some unit tests (Python 3.8) to cover the alembic
88+
registration that happens when alembic is installed.
89+
90+
- We have a system test that demonstrates working with alembic and
91+
proves that the things we think should work do work. :)
92+
"""
93+
if session.python == "3.8":
94+
session.install("alembic", "-c", constraints_path)
95+
96+
97+
'''
98+
99+
place_before(
100+
"noxfile.py",
101+
"def default",
102+
install_alembic_for_python_38,
103+
)
104+
105+
place_before(
106+
"noxfile.py",
107+
' session.install("-e", ".", ',
108+
" install_alembic_for_python_38(session, constraints_path)",
109+
escape='(')
110+
111+
old_sessions = '''
112+
"unit",
113+
"system",
114+
"cover",
115+
"lint",
116+
'''
117+
118+
new_sessions = '''
119+
"lint",
120+
"unit",
121+
"cover",
122+
"system",
123+
"compliance",
124+
'''
125+
126+
s.replace( ["noxfile.py"], old_sessions, new_sessions)
127+
128+
compliance = '''
129+
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
130+
def compliance(session):
131+
"""Run the SQLAlchemy dialect-compliance system tests"""
132+
constraints_path = str(
133+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
134+
)
135+
system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance")
136+
137+
if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false":
138+
session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping")
139+
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
140+
session.skip("Credentials must be set via environment variable")
141+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
142+
session.install("pyopenssl")
143+
if not os.path.exists(system_test_folder_path):
144+
session.skip("Compliance tests were not found")
145+
146+
session.install("--pre", "grpcio")
147+
148+
session.install(
149+
"mock",
150+
"pytest",
151+
"pytest-rerunfailures",
152+
"google-cloud-testutils",
153+
"-c",
154+
constraints_path,
155+
)
156+
session.install("-e", ".", "-c", constraints_path)
157+
158+
session.run(
159+
"py.test",
160+
"-vv",
161+
f"--junitxml=compliance_{session.python}_sponge_log.xml",
162+
"--reruns=3",
163+
"--reruns-delay=60",
164+
"--only-rerun=403 Exceeded rate limits",
165+
"--only-rerun=409 Already Exists",
166+
"--only-rerun=404 Not found",
167+
"--only-rerun=400 Cannot execute DML over a non-existent table",
168+
system_test_folder_path,
169+
*session.posargs,
170+
)
171+
172+
173+
'''
174+
175+
place_before(
176+
"noxfile.py",
177+
"@nox.session(python=DEFAULT_PYTHON_VERSION)\n"
178+
"def cover(session):",
179+
compliance,
180+
escape="()",
181+
)
182+
183+
184+
185+
54186
# Add DB config for SQLAlchemy dialect test suite.
55187
# https://github.com/sqlalchemy/sqlalchemy/blob/master/README.dialects.rst
56188
# https://github.com/googleapis/python-bigquery-sqlalchemy/issues/89
@@ -61,11 +193,11 @@
61193
62194
[sqla_testing]
63195
requirement_cls=pybigquery.requirements:Requirements
64-
profile_file=.profiles.txt
196+
profile_file=.sqlalchemy_dialect_compliance-profiles.txt
65197
66-
[db]
67-
default=bigquery://
68-
bigquery=bigquery://
198+
[tool:pytest]
199+
addopts= --tb native -v -r fxX -p no:warnings
200+
python_files=tests/*test_*.py
69201
"""
70202
)
71203

0 commit comments

Comments
 (0)