From d1b575f79abd98e9c76bb01a3b4b8de9e66564b6 Mon Sep 17 00:00:00 2001 From: Lo Ferris <50979514+loferris@users.noreply.github.com> Date: Wed, 1 Dec 2021 09:23:56 -0800 Subject: [PATCH 01/46] docs: add python quickstart sample (#141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial boilerplate for samples folder * basic test and nox setup * quickstart sample added * sample and test * updating test features * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updated region tags * removed CLI from sample and moved client creation out of main() * Update samples/snippets/quickstart.py Co-authored-by: Owl Bot Co-authored-by: Tim Swast --- bigquery-connection/snippets/__init__.py | 0 bigquery-connection/snippets/conftest.py | 33 +++ bigquery-connection/snippets/noxfile.py | 270 ++++++++++++++++++ .../snippets/noxfile_config.py | 38 +++ bigquery-connection/snippets/quickstart.py | 31 ++ .../snippets/quickstart_test.py | 25 ++ .../snippets/requirements-test.txt | 2 + bigquery-connection/snippets/requirements.txt | 1 + 8 files changed, 400 insertions(+) create mode 100644 bigquery-connection/snippets/__init__.py create mode 100644 bigquery-connection/snippets/conftest.py create mode 100644 bigquery-connection/snippets/noxfile.py create mode 100644 bigquery-connection/snippets/noxfile_config.py create mode 100644 bigquery-connection/snippets/quickstart.py create mode 100644 bigquery-connection/snippets/quickstart_test.py create mode 100644 bigquery-connection/snippets/requirements-test.txt create mode 100644 bigquery-connection/snippets/requirements.txt diff --git a/bigquery-connection/snippets/__init__.py b/bigquery-connection/snippets/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bigquery-connection/snippets/conftest.py b/bigquery-connection/snippets/conftest.py new file mode 100644 index 00000000000..8e39714b92f --- /dev/null +++ b/bigquery-connection/snippets/conftest.py @@ -0,0 +1,33 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from google.cloud.bigquery_connection_v1.services import connection_service +import pytest + + +@pytest.fixture(scope="session") +def project_id() -> str: + return os.environ["GOOGLE_CLOUD_PROJECT"] + + +@pytest.fixture(scope="session") +def connection_client() -> connection_service.ConnectionServiceClient: + return connection_service.ConnectionServiceClient() + + +@pytest.fixture(scope="session") +def location() -> str: + return "US" diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py new file mode 100644 index 00000000000..93a9122cc45 --- /dev/null +++ b/bigquery-connection/snippets/noxfile.py @@ -0,0 +1,270 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import print_function + +import os +from pathlib import Path +import sys +from typing import Callable, Dict, List, Optional + +import nox + + +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING +# DO NOT EDIT THIS FILE EVER! +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING + +BLACK_VERSION = "black==19.10b0" + +# Copy `noxfile_config.py` to your directory and modify it instead. + +# `TEST_CONFIG` dict is a configuration hook that allows users to +# modify the test configurations. The values here should be in sync +# with `noxfile_config.py`. Users will copy `noxfile_config.py` into +# their directory and modify it. + +TEST_CONFIG = { + # You can opt out from the test for specific Python versions. + "ignored_versions": [], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} + + +try: + # Ensure we can import noxfile_config in the project's directory. + sys.path.append(".") + from noxfile_config import TEST_CONFIG_OVERRIDE +except ImportError as e: + print("No user noxfile_config found: detail: {}".format(e)) + TEST_CONFIG_OVERRIDE = {} + +# Update the TEST_CONFIG with the user supplied values. +TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) + + +def get_pytest_env_vars() -> Dict[str, str]: + """Returns a dict for pytest invocation.""" + ret = {} + + # Override the GCLOUD_PROJECT and the alias. + env_key = TEST_CONFIG["gcloud_project_env"] + # This should error out if not set. + ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] + + # Apply user supplied envs. + ret.update(TEST_CONFIG["envs"]) + return ret + + +# DO NOT EDIT - automatically generated. +# All versions used to test samples. +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] + +# Any default versions that should be ignored. +IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] + +TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) + +INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( + "True", + "true", +) + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + +# +# Style Checks +# + + +def _determine_local_import_names(start_dir: str) -> List[str]: + """Determines all import names that should be considered "local". + + This is used when running the linter to insure that import order is + properly checked. + """ + file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] + return [ + basename + for basename, extension in file_ext_pairs + if extension == ".py" + or os.path.isdir(os.path.join(start_dir, basename)) + and basename not in ("__pycache__") + ] + + +# Linting with flake8. +# +# We ignore the following rules: +# E203: whitespace before ‘:’ +# E266: too many leading ‘#’ for block comment +# E501: line too long +# I202: Additional newline in a section of imports +# +# We also need to specify the rules which are ignored by default: +# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] +FLAKE8_COMMON_ARGS = [ + "--show-source", + "--builtin=gettext", + "--max-complexity=20", + "--import-order-style=google", + "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", + "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", + "--max-line-length=88", +] + + +@nox.session +def lint(session: nox.sessions.Session) -> None: + if not TEST_CONFIG["enforce_type_hints"]: + session.install("flake8", "flake8-import-order") + else: + session.install("flake8", "flake8-import-order", "flake8-annotations") + + local_names = _determine_local_import_names(".") + args = FLAKE8_COMMON_ARGS + [ + "--application-import-names", + ",".join(local_names), + ".", + ] + session.run("flake8", *args) + + +# +# Black +# + + +@nox.session +def blacken(session: nox.sessions.Session) -> None: + session.install(BLACK_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + session.run("black", *python_files) + + +# +# Sample Tests +# + + +PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] + + +def _session_tests( + session: nox.sessions.Session, post_install: Callable = None +) -> None: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) + + +@nox.session(python=ALL_VERSIONS) +def py(session: nox.sessions.Session) -> None: + """Runs py.test for a sample using the specified version of Python.""" + if session.python in TESTED_VERSIONS: + _session_tests(session) + else: + session.skip( + "SKIPPED: {} tests are disabled for this sample.".format(session.python) + ) + + +# +# Readmegen +# + + +def _get_repo_root() -> Optional[str]: + """ Returns the root folder of the project. """ + # Get root of this repository. Assume we don't have directories nested deeper than 10 items. + p = Path(os.getcwd()) + for i in range(10): + if p is None: + break + if Path(p / ".git").exists(): + return str(p) + # .git is not available in repos cloned via Cloud Build + # setup.py is always in the library's root, so use that instead + # https://github.com/googleapis/synthtool/issues/792 + if Path(p / "setup.py").exists(): + return str(p) + p = p.parent + raise Exception("Unable to detect repository root.") + + +GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")]) + + +@nox.session +@nox.parametrize("path", GENERATED_READMES) +def readmegen(session: nox.sessions.Session, path: str) -> None: + """(Re-)generates the readme for a sample.""" + session.install("jinja2", "pyyaml") + dir_ = os.path.dirname(path) + + if os.path.exists(os.path.join(dir_, "requirements.txt")): + session.install("-r", os.path.join(dir_, "requirements.txt")) + + in_file = os.path.join(dir_, "README.rst.in") + session.run( + "python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file + ) diff --git a/bigquery-connection/snippets/noxfile_config.py b/bigquery-connection/snippets/noxfile_config.py new file mode 100644 index 00000000000..0887541b3fa --- /dev/null +++ b/bigquery-connection/snippets/noxfile_config.py @@ -0,0 +1,38 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be inported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": True, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/bigquery-connection/snippets/quickstart.py b/bigquery-connection/snippets/quickstart.py new file mode 100644 index 00000000000..3c5107c1291 --- /dev/null +++ b/bigquery-connection/snippets/quickstart.py @@ -0,0 +1,31 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# [START bigqueryconnection_quickstart] + +from google.cloud import bigquery_connection_v1 as bq_connection + + +def main(project_id: str = "your-project-id", location: str = "US") -> None: + """Prints details and summary information about connections for a given admin project and location""" + client = bq_connection.ConnectionServiceClient() + print(f"List of connections in project {project_id} in location {location}") + req = bq_connection.ListConnectionsRequest( + parent=client.common_location_path(project_id, location) + ) + for connection in client.list_connections(request=req): + print(f"\tConnection {connection.friendly_name} ({connection.name})") + + +# [END bigqueryconnection_quickstart] diff --git a/bigquery-connection/snippets/quickstart_test.py b/bigquery-connection/snippets/quickstart_test.py new file mode 100644 index 00000000000..615134b5124 --- /dev/null +++ b/bigquery-connection/snippets/quickstart_test.py @@ -0,0 +1,25 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from . import quickstart + + +def test_quickstart( + capsys: pytest.CaptureFixture, project_id: str, location: str +) -> None: + quickstart.main(project_id, location) + out, _ = capsys.readouterr() + assert "List of connections in project" in out diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt new file mode 100644 index 00000000000..d0e9e7d837f --- /dev/null +++ b/bigquery-connection/snippets/requirements-test.txt @@ -0,0 +1,2 @@ +pytest==6.2.5 +google-cloud-testutils==1.2.0 \ No newline at end of file diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt new file mode 100644 index 00000000000..fb1552d8be7 --- /dev/null +++ b/bigquery-connection/snippets/requirements.txt @@ -0,0 +1 @@ +google-cloud-bigquery-connection==1.3.1 \ No newline at end of file From 9ceb033c11572d050f5b891a8b51d1e7dbb076a3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 3 Dec 2021 11:53:24 +0100 Subject: [PATCH 02/46] chore(deps): update dependency google-cloud-testutils to v1.3.0 (#143) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index d0e9e7d837f..66a342bfc1c 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ pytest==6.2.5 -google-cloud-testutils==1.2.0 \ No newline at end of file +google-cloud-testutils==1.3.0 \ No newline at end of file From d756eae0caf3bb91b5af7adb7a283f65897ec662 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 8 Jan 2022 12:06:15 +0100 Subject: [PATCH 03/46] chore(deps): update dependency google-cloud-testutils to v1.3.1 (#144) Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 66a342bfc1c..a8e40d36982 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ pytest==6.2.5 -google-cloud-testutils==1.3.0 \ No newline at end of file +google-cloud-testutils==1.3.1 \ No newline at end of file From 3cf14778dcf94b6edb7532b7bd4bf883251d9001 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 07:28:57 -0500 Subject: [PATCH 04/46] chore(samples): Add check for tests in directory (#152) Source-Link: https://github.com/googleapis/synthtool/commit/52aef91f8d25223d9dbdb4aebd94ba8eea2101f3 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 Co-authored-by: Owl Bot --- bigquery-connection/snippets/noxfile.py | 70 ++++++++++++++----------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 93a9122cc45..3bbef5d54f4 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,44 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From 757e145c59a4f6540cf2496ea305bc4efb038020 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 19 Jan 2022 01:37:00 +0100 Subject: [PATCH 05/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.3.2 (#156) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index fb1552d8be7..c107e6d718f 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.3.1 \ No newline at end of file +google-cloud-bigquery-connection==1.3.2 \ No newline at end of file From 7428be902578459a0bbf35d765e6427f8998576e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:53:30 -0500 Subject: [PATCH 06/46] chore(python): Noxfile recognizes that tests can live in a folder (#157) Source-Link: https://github.com/googleapis/synthtool/commit/4760d8dce1351d93658cb11d02a1b7ceb23ae5d7 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 Co-authored-by: Owl Bot --- bigquery-connection/snippets/noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 3bbef5d54f4..20cdfc62013 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: From cf3202c05c5ec9e48455ecdc3372d9ce3aaf396f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 7 Feb 2022 17:14:47 +0100 Subject: [PATCH 07/46] chore(deps): update dependency pytest to v7 (#164) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index a8e40d36982..3fcd10b6623 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==6.2.5 +pytest==7.0.0 google-cloud-testutils==1.3.1 \ No newline at end of file From 0b41a2d9262c2012c69cf43dbd58049bab57eaf2 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Feb 2022 16:52:54 +0100 Subject: [PATCH 08/46] chore(deps): update dependency pytest to v7.0.1 (#166) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 3fcd10b6623..1f422a02741 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.0.0 +pytest==7.0.1 google-cloud-testutils==1.3.1 \ No newline at end of file From ebb68e1f809478fe4bfbf7b66e9e703fbf81815f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 1 Mar 2022 12:17:59 +0100 Subject: [PATCH 09/46] chore(deps): update all dependencies (#170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index c107e6d718f..1d1078b768e 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.3.2 \ No newline at end of file +google-cloud-bigquery-connection==1.3.3 \ No newline at end of file From bf9e5fe46046ae26a192b4b86551478e5e226cf9 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 4 Mar 2022 13:14:04 -0500 Subject: [PATCH 10/46] chore: Adding support for pytest-xdist and pytest-parallel (#177) Source-Link: https://github.com/googleapis/synthtool/commit/82f5cb283efffe96e1b6cd634738e0e7de2cd90a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/noxfile.py | 78 ++++++++++++++----------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 20cdfc62013..85f5836dba3 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -188,42 +188,52 @@ def _session_tests( # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") test_list.extend(glob.glob("tests")) + if len(test_list) == 0: print("No tests found, skipping directory.") - else: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install( - "-r", "requirements-test.txt", "-c", "constraints-test.txt" - ) - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + return + + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + concurrent_args = [] + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + with open("requirements.txt") as rfile: + packages = rfile.read() + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") + else: + session.install("-r", "requirements-test.txt") + with open("requirements-test.txt") as rtfile: + packages += rtfile.read() + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + if "pytest-parallel" in packages: + concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) + elif "pytest-xdist" in packages: + concurrent_args.extend(["-n", "auto"]) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From c30570bc8e3e75aeddc4b5be1f8146da19388296 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 8 Mar 2022 02:49:04 +0100 Subject: [PATCH 11/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.3.4 (#180) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 1d1078b768e..9b6b9a11c49 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.3.3 \ No newline at end of file +google-cloud-bigquery-connection==1.3.4 \ No newline at end of file From 770e5ffcff6ac8227dad8cde1d2fc859acf06785 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 8 Mar 2022 18:14:17 +0100 Subject: [PATCH 12/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.4.0 (#183) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 9b6b9a11c49..1bd8e9f79a5 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.3.4 \ No newline at end of file +google-cloud-bigquery-connection==1.4.0 \ No newline at end of file From ca249de218c283d52013bc852b78ecc3502d3433 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sun, 13 Mar 2022 17:08:55 +0100 Subject: [PATCH 13/46] chore(deps): update dependency pytest to v7.1.0 (#185) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 1f422a02741..3e59759adee 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.0.1 +pytest==7.1.0 google-cloud-testutils==1.3.1 \ No newline at end of file From e269132d562f9bc93f5d942e2ee99537cc4522d8 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 19 Mar 2022 11:15:37 +0100 Subject: [PATCH 14/46] chore(deps): update dependency pytest to v7.1.1 (#186) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 3e59759adee..b3ff8cef2da 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.1.0 +pytest==7.1.1 google-cloud-testutils==1.3.1 \ No newline at end of file From 153d88f6f5a238f5df65dfbf449a6049aa6531a5 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:54:39 +0000 Subject: [PATCH 15/46] chore(python): use black==22.3.0 (#189) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- bigquery-connection/snippets/noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 85f5836dba3..25f87a215d4 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): From b068ebd460e7fd1efc4860958b7c4210ef966f42 Mon Sep 17 00:00:00 2001 From: Lo Ferris <50979514+loferris@users.noreply.github.com> Date: Fri, 15 Apr 2022 12:12:52 -0700 Subject: [PATCH 16/46] docs(samples): create connection sample for MySQL instance (#147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * setup for cloudsql connection sample * fleshed out sample * complete sample * changing region tag pattern * adding new environment variables * adding missing env variable * fixing fixture with correct env variable * refactor * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * refactor test imports * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * kokoro lint errors * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * changing fixture use * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * refactoring variables * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fixing imports * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * changing fixture syntax * fixing import * fixing typecasting * updating fixture usage * changing fixtures * refactor fixtures Co-authored-by: Anthonios Partheniou Co-authored-by: meredithslota Co-authored-by: Owl Bot --- bigquery-connection/snippets/conftest.py | 28 +++++- .../snippets/create_mysql_connection.py | 64 +++++++++++++ .../snippets/create_mysql_connection_test.py | 90 +++++++++++++++++++ 3 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 bigquery-connection/snippets/create_mysql_connection.py create mode 100644 bigquery-connection/snippets/create_mysql_connection_test.py diff --git a/bigquery-connection/snippets/conftest.py b/bigquery-connection/snippets/conftest.py index 8e39714b92f..eca2a7fd12d 100644 --- a/bigquery-connection/snippets/conftest.py +++ b/bigquery-connection/snippets/conftest.py @@ -19,15 +19,35 @@ @pytest.fixture(scope="session") -def project_id() -> str: - return os.environ["GOOGLE_CLOUD_PROJECT"] +def connection_client() -> connection_service.ConnectionServiceClient: + return connection_service.ConnectionServiceClient() @pytest.fixture(scope="session") -def connection_client() -> connection_service.ConnectionServiceClient: - return connection_service.ConnectionServiceClient() +def project_id() -> str: + return os.environ["GOOGLE_CLOUD_PROJECT"] @pytest.fixture(scope="session") def location() -> str: return "US" + + +@pytest.fixture(scope="session") +def database() -> str: + return os.environ["MYSQL_DATABASE"] + + +@pytest.fixture(scope="session") +def cloud_sql_conn_name() -> str: + return os.environ["MYSQL_INSTANCE"] + + +@pytest.fixture(scope="session") +def mysql_username() -> str: + return os.environ["MYSQL_USER"] + + +@pytest.fixture(scope="session") +def mysql_password() -> str: + return os.environ["MYSQL_PASSWORD"] diff --git a/bigquery-connection/snippets/create_mysql_connection.py b/bigquery-connection/snippets/create_mysql_connection.py new file mode 100644 index 00000000000..823fd1aaa98 --- /dev/null +++ b/bigquery-connection/snippets/create_mysql_connection.py @@ -0,0 +1,64 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# [START bigqueryconnection_connection_create] +from google.cloud import bigquery_connection_v1 as bq_connection + +"""This sample shows how to create a BigQuery connection with a Cloud SQL for MySQL database""" + + +def main() -> None: + # TODO(developer): Set all variables for your Cloud SQL for MySQL connection. + project_id = "your-project-id" # set project_id + location = "US" # set location + # See: https://cloud.google.com/bigquery/docs/locations for a list of + # available locations. + database = "my-database" # set database name + username = "my-username" # set database username + password = "my-password" # set database password + cloud_sql_conn_name = "" # set the name of your connection + + cloud_sql_credential = bq_connection.CloudSqlCredential( + { + "username": username, + "password": password, + } + ) + cloud_sql_properties = bq_connection.CloudSqlProperties( + { + "type_": bq_connection.CloudSqlProperties.DatabaseType.MYSQL, + "database": database, + "instance_id": cloud_sql_conn_name, + "credential": cloud_sql_credential, + } + ) + create_mysql_connection(project_id, location, cloud_sql_properties) + + +def create_mysql_connection( + project_id: str, + location: str, + cloud_sql_properties: bq_connection.CloudSqlProperties, +) -> None: + connection = bq_connection.types.Connection({"cloud_sql": cloud_sql_properties}) + client = bq_connection.ConnectionServiceClient() + parent = client.common_location_path(project_id, location) + request = bq_connection.CreateConnectionRequest( + {"parent": parent, "connection": connection} + ) + response = client.create_connection(request) + print(f"Created connection successfully: {response.name}") + + +# [END bigqueryconnection_connection_create] diff --git a/bigquery-connection/snippets/create_mysql_connection_test.py b/bigquery-connection/snippets/create_mysql_connection_test.py new file mode 100644 index 00000000000..9eda07da2d0 --- /dev/null +++ b/bigquery-connection/snippets/create_mysql_connection_test.py @@ -0,0 +1,90 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import google.api_core.exceptions +from google.cloud import bigquery_connection_v1 as bq_connection +from google.cloud.bigquery_connection_v1.services import connection_service +import pytest +import test_utils.prefixer + +from . import create_mysql_connection + +connection_prefixer = test_utils.prefixer.Prefixer("py-bq-r", "snippets", separator="-") + + +@pytest.fixture(scope="session") +def location_path( + connection_client: connection_service.ConnectionServiceClient(), + project_id: str, + location: str, +) -> str: + return connection_client.common_location_path(project_id, location) + + +@pytest.fixture(scope="module", autouse=True) +def cleanup_connection( + connection_client: connection_service.ConnectionServiceClient, location_path: str +) -> None: + for connection in connection_client.list_connections(parent=location_path): + connection_id = connection.name.split("/")[-1] + if connection_prefixer.should_cleanup(connection_id): + connection_client.delete_connection(name=connection.name) + + +@pytest.fixture(scope="session") +def connection_id( + connection_client: connection_service.ConnectionServiceClient, + project_id: str, + location: str, +) -> str: + id_ = connection_prefixer.create_prefix() + yield id_ + + connection_name = connection_client.connection_path(project_id, location, id_) + try: + connection_client.delete_connection(name=connection_name) + except google.api_core.exceptions.NotFound: + pass + + +def test_create_mysql_connection( + capsys: pytest.CaptureFixture, + mysql_username: str, + mysql_password: str, + database: str, + cloud_sql_conn_name: str, + project_id: str, + location: str, +) -> None: + cloud_sql_credential = bq_connection.CloudSqlCredential( + { + "username": mysql_username, + "password": mysql_password, + } + ) + cloud_sql_properties = bq_connection.CloudSqlProperties( + { + "type_": bq_connection.CloudSqlProperties.DatabaseType.MYSQL, + "database": database, + "instance_id": cloud_sql_conn_name, + "credential": cloud_sql_credential, + } + ) + create_mysql_connection.create_mysql_connection( + project_id=project_id, + location=location, + cloud_sql_properties=cloud_sql_properties, + ) + out, _ = capsys.readouterr() + assert "Created connection successfully:" in out From 091e8ec1dbb65bcfcfab29f563b986c27b83b38b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 20:04:36 -0400 Subject: [PATCH 17/46] chore(python): add nox session to sort python imports (#203) Source-Link: https://github.com/googleapis/synthtool/commit/1b71c10e20de7ed3f97f692f99a0e3399b67049f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot --- bigquery-connection/snippets/noxfile.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 25f87a215d4..3b3ffa5d2b0 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -22,7 +22,6 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # DO NOT EDIT THIS FILE EVER! @@ -30,6 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # From 01546abaf4f8c4ec6ac2b070744e9c07d0542fa4 Mon Sep 17 00:00:00 2001 From: Lo Ferris <50979514+loferris@users.noreply.github.com> Date: Thu, 21 Apr 2022 10:43:58 -0700 Subject: [PATCH 18/46] fix: region tags in create_mysql_connection.py (#205) Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/create_mysql_connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigquery-connection/snippets/create_mysql_connection.py b/bigquery-connection/snippets/create_mysql_connection.py index 823fd1aaa98..a71c9678db0 100644 --- a/bigquery-connection/snippets/create_mysql_connection.py +++ b/bigquery-connection/snippets/create_mysql_connection.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START bigqueryconnection_connection_create] +# [START bigqueryconnection_create_connection] from google.cloud import bigquery_connection_v1 as bq_connection """This sample shows how to create a BigQuery connection with a Cloud SQL for MySQL database""" @@ -61,4 +61,4 @@ def create_mysql_connection( print(f"Created connection successfully: {response.name}") -# [END bigqueryconnection_connection_create] +# [END bigqueryconnection_create_connection] From 88f872cbfee5bc8a01a80b41422a6684f2841703 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 25 Apr 2022 17:04:29 +0200 Subject: [PATCH 19/46] chore(deps): update dependency pytest to v7.1.2 (#207) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index b3ff8cef2da..c3ab9e0e2f7 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.1.1 +pytest==7.1.2 google-cloud-testutils==1.3.1 \ No newline at end of file From ec5e62b508d11345ef6963f345162311e84a98b7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 19 May 2022 18:15:48 +0200 Subject: [PATCH 20/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.5.0 (#214) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 1bd8e9f79a5..a001cd8faee 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.4.0 \ No newline at end of file +google-cloud-bigquery-connection==1.5.0 \ No newline at end of file From e3de096ff574bcb2a7a50bfccf72eb6565d20a71 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 7 Jun 2022 13:10:53 +0200 Subject: [PATCH 21/46] chore(deps): update all dependencies (#223) * chore(deps): update all dependencies * revert protobuf Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index c3ab9e0e2f7..0719c92761b 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ pytest==7.1.2 -google-cloud-testutils==1.3.1 \ No newline at end of file +google-cloud-testutils==1.3.2 \ No newline at end of file From fd3479359de1788b12577ccbb0abc59dddc3feb7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 10 Jul 2022 13:41:45 -0400 Subject: [PATCH 22/46] fix: require python 3.7+ (#231) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(python): drop python 3.6 Source-Link: https://github.com/googleapis/synthtool/commit/4f89b13af10d086458f9b379e56a614f9d6dab7b Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c * require python 3.7+ in setup.py * remove python 3.6 sample configs * add api_description to .repo-metadata.json * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 3b3ffa5d2b0..e9eb1cbfa5d 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -88,7 +88,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] From 16db7317cd94394066c93550a9c094ea5b334142 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 2 Aug 2022 16:08:20 +0200 Subject: [PATCH 23/46] chore(deps): update all dependencies (#239) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements-test.txt | 2 +- bigquery-connection/snippets/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 0719c92761b..18f53ca1bdb 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ pytest==7.1.2 -google-cloud-testutils==1.3.2 \ No newline at end of file +google-cloud-testutils==1.3.3 \ No newline at end of file diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index a001cd8faee..7e4e7ce1898 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.5.0 \ No newline at end of file +google-cloud-bigquery-connection==1.6.0 \ No newline at end of file From 87c8be04f6466b2033db0461d0f44aaeb9197ad1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 5 Aug 2022 21:59:58 +0200 Subject: [PATCH 24/46] chore(deps): update all dependencies (#241) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 7e4e7ce1898..e4e7eb3db64 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.6.0 \ No newline at end of file +google-cloud-bigquery-connection==1.7.0 \ No newline at end of file From 37b765341f9e5a85d28fd86d31e7b3cc685b1caa Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 15 Aug 2022 17:01:18 +0200 Subject: [PATCH 25/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.7.1 (#246) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index e4e7eb3db64..090c0a915d6 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.7.0 \ No newline at end of file +google-cloud-bigquery-connection==1.7.1 \ No newline at end of file From 407dbc40a735622ac172a9c318467ff3b3301557 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 6 Sep 2022 17:42:03 +0200 Subject: [PATCH 26/46] chore(deps): update dependency pytest to v7.1.3 (#256) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 18f53ca1bdb..16860dde366 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.1.2 +pytest==7.1.3 google-cloud-testutils==1.3.3 \ No newline at end of file From e3e3926723e4f6e24c2714f53600677ea4c8d8aa Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:20:25 +0000 Subject: [PATCH 27/46] chore: detect samples tests in nested directories (#260) Source-Link: https://github.com/googleapis/synthtool/commit/50db768f450a50d7c1fd62513c113c9bb96fd434 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978 --- bigquery-connection/snippets/noxfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index e9eb1cbfa5d..c1715136d64 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -207,8 +207,10 @@ def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: # check for presence of tests - test_list = glob.glob("*_test.py") + glob.glob("test_*.py") - test_list.extend(glob.glob("tests")) + test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob( + "**/test_*.py", recursive=True + ) + test_list.extend(glob.glob("**/tests", recursive=True)) if len(test_list) == 0: print("No tests found, skipping directory.") From 5a28647fc064c2b455bafcdcf78e84152999a3b6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 4 Oct 2022 15:43:08 +0200 Subject: [PATCH 28/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.7.2 (#264) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 090c0a915d6..6e15a487dc2 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.7.1 \ No newline at end of file +google-cloud-bigquery-connection==1.7.2 \ No newline at end of file From b3f0ada2c5a4f508db671696819e7d9236160132 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 10 Oct 2022 20:01:49 +0200 Subject: [PATCH 29/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.7.3 (#267) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 6e15a487dc2..b94a13d0fcf 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.7.2 \ No newline at end of file +google-cloud-bigquery-connection==1.7.3 \ No newline at end of file From 6a3233eb99ef47c73df9ca36c7e96b01c3826a0f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 26 Oct 2022 12:55:18 +0200 Subject: [PATCH 30/46] chore(deps): update dependency pytest to v7.2.0 (#269) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 16860dde366..f70f97ab8c0 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.1.3 +pytest==7.2.0 google-cloud-testutils==1.3.3 \ No newline at end of file From 1f86bba8657ebe58b60a71d186666b65e164db7d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 26 Nov 2022 19:12:06 -0500 Subject: [PATCH 31/46] chore(python): drop flake8-import-order in samples noxfile (#275) Source-Link: https://github.com/googleapis/synthtool/commit/6ed3a831cb9ff69ef8a504c353e098ec0192ad93 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3abfa0f1886adaf0b83f07cb117b24a639ea1cb9cffe56d43280b977033563eb Co-authored-by: Owl Bot --- bigquery-connection/snippets/noxfile.py | 26 +++---------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index c1715136d64..0577084695f 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -18,7 +18,7 @@ import os from pathlib import Path import sys -from typing import Callable, Dict, List, Optional +from typing import Callable, Dict, Optional import nox @@ -108,22 +108,6 @@ def get_pytest_env_vars() -> Dict[str, str]: # -def _determine_local_import_names(start_dir: str) -> List[str]: - """Determines all import names that should be considered "local". - - This is used when running the linter to insure that import order is - properly checked. - """ - file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] - return [ - basename - for basename, extension in file_ext_pairs - if extension == ".py" - or os.path.isdir(os.path.join(start_dir, basename)) - and basename not in ("__pycache__") - ] - - # Linting with flake8. # # We ignore the following rules: @@ -138,7 +122,6 @@ def _determine_local_import_names(start_dir: str) -> List[str]: "--show-source", "--builtin=gettext", "--max-complexity=20", - "--import-order-style=google", "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", "--max-line-length=88", @@ -148,14 +131,11 @@ def _determine_local_import_names(start_dir: str) -> List[str]: @nox.session def lint(session: nox.sessions.Session) -> None: if not TEST_CONFIG["enforce_type_hints"]: - session.install("flake8", "flake8-import-order") + session.install("flake8") else: - session.install("flake8", "flake8-import-order", "flake8-annotations") + session.install("flake8", "flake8-annotations") - local_names = _determine_local_import_names(".") args = FLAKE8_COMMON_ARGS + [ - "--application-import-names", - ",".join(local_names), ".", ] session.run("flake8", *args) From 6baccd15f93608eaf90e8c18fd87c271893cee0e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 16 Dec 2022 03:27:26 +0100 Subject: [PATCH 32/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.8.0 (#278) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index b94a13d0fcf..eda4342da96 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.7.3 \ No newline at end of file +google-cloud-bigquery-connection==1.8.0 \ No newline at end of file From d45497fad87afff6ce64a93ee1403f6f26221160 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 08:33:15 -0500 Subject: [PATCH 33/46] chore(python): add support for python 3.11 (#279) Source-Link: https://github.com/googleapis/synthtool/commit/7197a001ffb6d8ce7b0b9b11c280f0c536c1033a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 Co-authored-by: Owl Bot --- bigquery-connection/snippets/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py index 0577084695f..de104dbc64d 100644 --- a/bigquery-connection/snippets/noxfile.py +++ b/bigquery-connection/snippets/noxfile.py @@ -88,7 +88,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] From b2a0051bc948737ffdf128d1a604301e10c39718 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 11 Jan 2023 15:14:30 +0000 Subject: [PATCH 34/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.9.0 (#282) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index eda4342da96..dc6f1909a24 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.8.0 \ No newline at end of file +google-cloud-bigquery-connection==1.9.0 \ No newline at end of file From d1e5fd5812ddeb9168ead7baed6e429c24ab7b85 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 14 Jan 2023 18:13:17 +0000 Subject: [PATCH 35/46] chore(deps): update dependency pytest to v7.2.1 (#283) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index f70f97ab8c0..6dd46937c91 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.2.0 +pytest==7.2.1 google-cloud-testutils==1.3.3 \ No newline at end of file From c4e044c2a2ed090a571aab4a379a6e07250850c2 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 9 Feb 2023 16:00:42 +0000 Subject: [PATCH 36/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.9.1 (#286) Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index dc6f1909a24..30248e27a31 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.9.0 \ No newline at end of file +google-cloud-bigquery-connection==1.9.1 \ No newline at end of file From 3e292a4c48910f67032fb3aee7568cad30481c0c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:22:14 -0500 Subject: [PATCH 37/46] feat: enable "rest" transport in Python for services supporting numeric enums (#294) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: enable "rest" transport in Python for services supporting numeric enums PiperOrigin-RevId: 508143576 Source-Link: https://github.com/googleapis/googleapis/commit/7a702a989db3b413f39ff8994ca53fb38b6928c2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6ad1279c0e7aa787ac6b66c9fd4a210692edffcd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * use REST transport in samples/tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert changes to fixtures * revert * revert --------- Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/create_mysql_connection.py | 6 ++++-- .../snippets/create_mysql_connection_test.py | 3 +++ bigquery-connection/snippets/quickstart.py | 6 ++++-- bigquery-connection/snippets/quickstart_test.py | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bigquery-connection/snippets/create_mysql_connection.py b/bigquery-connection/snippets/create_mysql_connection.py index a71c9678db0..f4577afbb70 100644 --- a/bigquery-connection/snippets/create_mysql_connection.py +++ b/bigquery-connection/snippets/create_mysql_connection.py @@ -28,6 +28,7 @@ def main() -> None: username = "my-username" # set database username password = "my-password" # set database password cloud_sql_conn_name = "" # set the name of your connection + transport = "grpc" # Set the transport to either "grpc" or "rest" cloud_sql_credential = bq_connection.CloudSqlCredential( { @@ -43,16 +44,17 @@ def main() -> None: "credential": cloud_sql_credential, } ) - create_mysql_connection(project_id, location, cloud_sql_properties) + create_mysql_connection(project_id, location, cloud_sql_properties, transport) def create_mysql_connection( project_id: str, location: str, cloud_sql_properties: bq_connection.CloudSqlProperties, + transport: str, ) -> None: connection = bq_connection.types.Connection({"cloud_sql": cloud_sql_properties}) - client = bq_connection.ConnectionServiceClient() + client = bq_connection.ConnectionServiceClient(transport=transport) parent = client.common_location_path(project_id, location) request = bq_connection.CreateConnectionRequest( {"parent": parent, "connection": connection} diff --git a/bigquery-connection/snippets/create_mysql_connection_test.py b/bigquery-connection/snippets/create_mysql_connection_test.py index 9eda07da2d0..501af447d8b 100644 --- a/bigquery-connection/snippets/create_mysql_connection_test.py +++ b/bigquery-connection/snippets/create_mysql_connection_test.py @@ -58,6 +58,7 @@ def connection_id( pass +@pytest.mark.parametrize("transport", ["grpc", "rest"]) def test_create_mysql_connection( capsys: pytest.CaptureFixture, mysql_username: str, @@ -66,6 +67,7 @@ def test_create_mysql_connection( cloud_sql_conn_name: str, project_id: str, location: str, + transport: str, ) -> None: cloud_sql_credential = bq_connection.CloudSqlCredential( { @@ -85,6 +87,7 @@ def test_create_mysql_connection( project_id=project_id, location=location, cloud_sql_properties=cloud_sql_properties, + transport=transport, ) out, _ = capsys.readouterr() assert "Created connection successfully:" in out diff --git a/bigquery-connection/snippets/quickstart.py b/bigquery-connection/snippets/quickstart.py index 3c5107c1291..463bd8a87cc 100644 --- a/bigquery-connection/snippets/quickstart.py +++ b/bigquery-connection/snippets/quickstart.py @@ -17,9 +17,11 @@ from google.cloud import bigquery_connection_v1 as bq_connection -def main(project_id: str = "your-project-id", location: str = "US") -> None: +def main( + project_id: str = "your-project-id", location: str = "US", transport: str = "grpc" +) -> None: """Prints details and summary information about connections for a given admin project and location""" - client = bq_connection.ConnectionServiceClient() + client = bq_connection.ConnectionServiceClient(transport=transport) print(f"List of connections in project {project_id} in location {location}") req = bq_connection.ListConnectionsRequest( parent=client.common_location_path(project_id, location) diff --git a/bigquery-connection/snippets/quickstart_test.py b/bigquery-connection/snippets/quickstart_test.py index 615134b5124..2a8df8f59ea 100644 --- a/bigquery-connection/snippets/quickstart_test.py +++ b/bigquery-connection/snippets/quickstart_test.py @@ -17,9 +17,10 @@ from . import quickstart +@pytest.mark.parametrize("transport", ["grpc", "rest"]) def test_quickstart( - capsys: pytest.CaptureFixture, project_id: str, location: str + capsys: pytest.CaptureFixture, project_id: str, location: str, transport: str ) -> None: - quickstart.main(project_id, location) + quickstart.main(project_id, location, transport) out, _ = capsys.readouterr() assert "List of connections in project" in out From bb8f52b5bfddeb32d968a75293d06a374f149a04 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 10:25:36 +0000 Subject: [PATCH 38/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.10.0 (#298) Co-authored-by: Anthonios Partheniou --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 30248e27a31..6097b4358e9 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.9.1 \ No newline at end of file +google-cloud-bigquery-connection==1.10.0 \ No newline at end of file From 1fa5e325af89351fc652efa03bfc284fabadbb8e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 1 Mar 2023 20:42:36 +0000 Subject: [PATCH 39/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.11.0 (#300) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 6097b4358e9..2978f90e6ee 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.10.0 \ No newline at end of file +google-cloud-bigquery-connection==1.11.0 \ No newline at end of file From ff09d7a5a0df63d578cdea611e8da371fc1fe707 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Sat, 4 Mar 2023 11:27:39 +0000 Subject: [PATCH 40/46] chore(deps): update dependency pytest to v7.2.2 (#301) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 6dd46937c91..95453f3241a 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.2.1 +pytest==7.2.2 google-cloud-testutils==1.3.3 \ No newline at end of file From 2a7932b01b65d485fc387f56537c8c84c2770fe7 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 6 Apr 2023 17:16:24 +0100 Subject: [PATCH 41/46] chore(deps): update dependency google-cloud-bigquery-connection to v1.12.0 (#308) --- bigquery-connection/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements.txt b/bigquery-connection/snippets/requirements.txt index 2978f90e6ee..9339b226aaf 100644 --- a/bigquery-connection/snippets/requirements.txt +++ b/bigquery-connection/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery-connection==1.11.0 \ No newline at end of file +google-cloud-bigquery-connection==1.12.0 \ No newline at end of file From a827e5f07b30060b1b142c97d1e2d2ddda36f686 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 18 Apr 2023 18:00:54 +0200 Subject: [PATCH 42/46] chore(deps): update dependency pytest to v7.3.0 (#309) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 95453f3241a..0d2cb327bca 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.2.2 +pytest==7.3.0 google-cloud-testutils==1.3.3 \ No newline at end of file From 4c171b084e479c88b8b73439100056a1c08e4bba Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 18 Apr 2023 18:06:56 +0200 Subject: [PATCH 43/46] chore(deps): update dependency pytest to v7.3.1 (#310) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 0d2cb327bca..45499513e7c 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.3.0 +pytest==7.3.1 google-cloud-testutils==1.3.3 \ No newline at end of file From 301dc84db0e553ee2912215fe89ba274712b39f2 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 12 Jun 2023 23:02:53 +0200 Subject: [PATCH 44/46] chore(deps): update dependency pytest to v7.3.2 (#315) --- bigquery-connection/snippets/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery-connection/snippets/requirements-test.txt b/bigquery-connection/snippets/requirements-test.txt index 45499513e7c..8e8f5c2707e 100644 --- a/bigquery-connection/snippets/requirements-test.txt +++ b/bigquery-connection/snippets/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==7.3.1 +pytest==7.3.2 google-cloud-testutils==1.3.3 \ No newline at end of file From 770059c8d53323dfc7348c3a5ceed258ec844511 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Thu, 15 Jun 2023 13:32:27 -0700 Subject: [PATCH 45/46] remove snippet/noxfile.py and omit python 3.6 in noxfile_config.py --- bigquery-connection/snippets/noxfile.py | 292 ------------------ .../snippets/noxfile_config.py | 2 +- 2 files changed, 1 insertion(+), 293 deletions(-) delete mode 100644 bigquery-connection/snippets/noxfile.py diff --git a/bigquery-connection/snippets/noxfile.py b/bigquery-connection/snippets/noxfile.py deleted file mode 100644 index de104dbc64d..00000000000 --- a/bigquery-connection/snippets/noxfile.py +++ /dev/null @@ -1,292 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import print_function - -import glob -import os -from pathlib import Path -import sys -from typing import Callable, Dict, Optional - -import nox - -# WARNING - WARNING - WARNING - WARNING - WARNING -# WARNING - WARNING - WARNING - WARNING - WARNING -# DO NOT EDIT THIS FILE EVER! -# WARNING - WARNING - WARNING - WARNING - WARNING -# WARNING - WARNING - WARNING - WARNING - WARNING - -BLACK_VERSION = "black==22.3.0" -ISORT_VERSION = "isort==5.10.1" - -# Copy `noxfile_config.py` to your directory and modify it instead. - -# `TEST_CONFIG` dict is a configuration hook that allows users to -# modify the test configurations. The values here should be in sync -# with `noxfile_config.py`. Users will copy `noxfile_config.py` into -# their directory and modify it. - -TEST_CONFIG = { - # You can opt out from the test for specific Python versions. - "ignored_versions": [], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", - # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} - - -try: - # Ensure we can import noxfile_config in the project's directory. - sys.path.append(".") - from noxfile_config import TEST_CONFIG_OVERRIDE -except ImportError as e: - print("No user noxfile_config found: detail: {}".format(e)) - TEST_CONFIG_OVERRIDE = {} - -# Update the TEST_CONFIG with the user supplied values. -TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) - - -def get_pytest_env_vars() -> Dict[str, str]: - """Returns a dict for pytest invocation.""" - ret = {} - - # Override the GCLOUD_PROJECT and the alias. - env_key = TEST_CONFIG["gcloud_project_env"] - # This should error out if not set. - ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] - - # Apply user supplied envs. - ret.update(TEST_CONFIG["envs"]) - return ret - - -# DO NOT EDIT - automatically generated. -# All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"] - -# Any default versions that should be ignored. -IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] - -TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) - -INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( - "True", - "true", -) - -# Error if a python version is missing -nox.options.error_on_missing_interpreters = True - -# -# Style Checks -# - - -# Linting with flake8. -# -# We ignore the following rules: -# E203: whitespace before ‘:’ -# E266: too many leading ‘#’ for block comment -# E501: line too long -# I202: Additional newline in a section of imports -# -# We also need to specify the rules which are ignored by default: -# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] -FLAKE8_COMMON_ARGS = [ - "--show-source", - "--builtin=gettext", - "--max-complexity=20", - "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", - "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", - "--max-line-length=88", -] - - -@nox.session -def lint(session: nox.sessions.Session) -> None: - if not TEST_CONFIG["enforce_type_hints"]: - session.install("flake8") - else: - session.install("flake8", "flake8-annotations") - - args = FLAKE8_COMMON_ARGS + [ - ".", - ] - session.run("flake8", *args) - - -# -# Black -# - - -@nox.session -def blacken(session: nox.sessions.Session) -> None: - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - python_files = [path for path in os.listdir(".") if path.endswith(".py")] - - session.run("black", *python_files) - - -# -# format = isort + black -# - - -@nox.session -def format(session: nox.sessions.Session) -> None: - """ - Run isort to sort imports. Then run black - to format code to uniform standard. - """ - session.install(BLACK_VERSION, ISORT_VERSION) - python_files = [path for path in os.listdir(".") if path.endswith(".py")] - - # Use the --fss option to sort imports using strict alphabetical order. - # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections - session.run("isort", "--fss", *python_files) - session.run("black", *python_files) - - -# -# Sample Tests -# - - -PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] - - -def _session_tests( - session: nox.sessions.Session, post_install: Callable = None -) -> None: - # check for presence of tests - test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob( - "**/test_*.py", recursive=True - ) - test_list.extend(glob.glob("**/tests", recursive=True)) - - if len(test_list) == 0: - print("No tests found, skipping directory.") - return - - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - concurrent_args = [] - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - with open("requirements.txt") as rfile: - packages = rfile.read() - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - with open("requirements-test.txt") as rtfile: - packages += rtfile.read() - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - if "pytest-parallel" in packages: - concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"]) - elif "pytest-xdist" in packages: - concurrent_args.extend(["-n", "auto"]) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) - - -@nox.session(python=ALL_VERSIONS) -def py(session: nox.sessions.Session) -> None: - """Runs py.test for a sample using the specified version of Python.""" - if session.python in TESTED_VERSIONS: - _session_tests(session) - else: - session.skip( - "SKIPPED: {} tests are disabled for this sample.".format(session.python) - ) - - -# -# Readmegen -# - - -def _get_repo_root() -> Optional[str]: - """Returns the root folder of the project.""" - # Get root of this repository. Assume we don't have directories nested deeper than 10 items. - p = Path(os.getcwd()) - for i in range(10): - if p is None: - break - if Path(p / ".git").exists(): - return str(p) - # .git is not available in repos cloned via Cloud Build - # setup.py is always in the library's root, so use that instead - # https://github.com/googleapis/synthtool/issues/792 - if Path(p / "setup.py").exists(): - return str(p) - p = p.parent - raise Exception("Unable to detect repository root.") - - -GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")]) - - -@nox.session -@nox.parametrize("path", GENERATED_READMES) -def readmegen(session: nox.sessions.Session, path: str) -> None: - """(Re-)generates the readme for a sample.""" - session.install("jinja2", "pyyaml") - dir_ = os.path.dirname(path) - - if os.path.exists(os.path.join(dir_, "requirements.txt")): - session.install("-r", os.path.join(dir_, "requirements.txt")) - - in_file = os.path.join(dir_, "README.rst.in") - session.run( - "python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file - ) diff --git a/bigquery-connection/snippets/noxfile_config.py b/bigquery-connection/snippets/noxfile_config.py index 0887541b3fa..4abe361c51f 100644 --- a/bigquery-connection/snippets/noxfile_config.py +++ b/bigquery-connection/snippets/noxfile_config.py @@ -22,7 +22,7 @@ TEST_CONFIG_OVERRIDE = { # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], + "ignored_versions": ["2.7", "3.6"], # Old samples are opted out of enforcing Python type hints # All new samples should feature them "enforce_type_hints": True, From f49858189964e8c793bfc72cb9306e31930c2568 Mon Sep 17 00:00:00 2001 From: Yu-Han Liu Date: Thu, 15 Jun 2023 13:36:34 -0700 Subject: [PATCH 46/46] update .github/CODEOWNERS and blunderbuss.yml --- .github/CODEOWNERS | 1 + .github/blunderbuss.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d1c7b49c8be..c6cb406334c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -71,6 +71,7 @@ /texttospeech/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers /translate/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers /video/transcoder/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers +/bigquery-connection/**/* @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/python-samples-reviewers # Cloud SDK Databases & Data Analytics teams # ---* Cloud Native DB diff --git a/.github/blunderbuss.yml b/.github/blunderbuss.yml index 23bca271ca5..a4c13da37e9 100644 --- a/.github/blunderbuss.yml +++ b/.github/blunderbuss.yml @@ -70,6 +70,7 @@ assign_issues_by: - "api: texttospeech" - "api: translate" - "api: vision" + - "api: bigquery" to: - GoogleCloudPlatform/dee-data-ai