diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 000000000..cea9eb68f --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,17 @@ +# Copyright 2025 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. +docker: + image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest + digest: sha256:3b3a31be60853477bc39ed8d9bac162cac3ba083724cecaad54eb81d4e4dae9c +# created: 2025-04-16T22:40:03.123475241Z diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 000000000..8b142686c --- /dev/null +++ b/.github/.OwlBot.yaml @@ -0,0 +1,22 @@ +# 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. + +docker: + image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest + +deep-remove-regex: + - /owl-bot-staging + +begin-after-commit-hash: f2de93abafa306b2ebadf1d10d947db8bcf2bf15 + diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..6763f258c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# Code owners file. +# This file controls who is tagged for review for any given pull request. +# +# For syntax help see: +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax + +# The @googleapis/api-bigquery is the default owner for changes in this repo +* @googleapis/api-bigquery @googleapis/yoshi-python + +# The python-samples-reviewers team is the default owner for samples changes +/samples/ @googleapis/api-bigquery @googleapis/python-samples-owners @googleapis/yoshi-python diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..939e5341e --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google.com/conduct/). diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..65ceeeb5e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: +- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea +- [ ] Ensure the tests and linter pass +- [ ] Code coverage does not decrease (if any source code was changed) +- [ ] Appropriate docs were updated (if necessary) + +Fixes # 🦕 diff --git a/.github/release-please.yml b/.github/release-please.yml new file mode 100644 index 000000000..5161ab347 --- /dev/null +++ b/.github/release-please.yml @@ -0,0 +1,14 @@ +releaseType: python +handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v2 + handleGHRelease: true + releaseType: python +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 000000000..b975c190d --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1,2 @@ +enabled: true +multiScmName: python-bigquery diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..d06fd2a7c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,40 @@ +on: + pull_request: + branches: + - autogen + # Trigger workflow on GitHub merge queue events + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group + merge_group: + types: [checks_requested] +name: lint + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + # Use a fetch-depth of 2 to avoid error `fatal: origin/main...HEAD: no merge base` + # See https://github.com/googleapis/google-cloud-python/issues/12013 + # and https://github.com/actions/checkout#checkout-head. + with: + fetch-depth: 2 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + env: + BUILD_TYPE: presubmit + TEST_TYPE: lint + # TODO(https://github.com/googleapis/google-cloud-python/issues/13775): Specify `PY_VERSION` rather than relying on the default python version of the nox session. + PY_VERSION: "unused" + run: | + nox -s blacken lint diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 000000000..4f118eca0 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,87 @@ +on: + pull_request: + branches: + - autogen + # Trigger workflow on GitHub merge queue events + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group + merge_group: + types: [checks_requested] +name: unittest + +permissions: + contents: read + +jobs: + unit: + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed. + # Use ubuntu-22.04 until Python 3.7 is removed from the test matrix + # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories + runs-on: ubuntu-22.04 + strategy: + matrix: + python: ['3.9', '3.10', "3.11", "3.12", "3.13"] + steps: + - name: Checkout + uses: actions/checkout@v4 + # Use a fetch-depth of 2 to avoid error `fatal: origin/main...HEAD: no merge base` + # See https://github.com/googleapis/google-cloud-python/issues/12013 + # and https://github.com/actions/checkout#checkout-head. + with: + fetch-depth: 2 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + BUILD_TYPE: presubmit + TEST_TYPE: unit + PY_VERSION: ${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v4 + with: + name: coverage-artifact-${{ '{{' }} matrix.python {{ '}}' }} + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v4 + # Use a fetch-depth of 2 to avoid error `fatal: origin/main...HEAD: no merge base` + # See https://github.com/googleapis/google-cloud-python/issues/12013 + # and https://github.com/actions/checkout#checkout-head. + with: + fetch-depth: 2 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Set number of files changes in packages directory + id: packages + run: echo "::set-output name=num_files_changed::$(git diff HEAD~1 -- packages | wc -l)" + - name: Install coverage + if: steps.packages.num_files_changed > 0 + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + if: ${{ steps.date.packages.num_files_changed > 0 }} + uses: actions/download-artifact@v4 + with: + path: .coverage-results/ + - name: Report coverage results + if: ${{ steps.date.packages.num_files_changed > 0 }} + run: | + find .coverage-results -type f -name '*.zip' -exec unzip {} \; + coverage combine .coverage-results/**/.coverage* + coverage report --show-missing --fail-under=100 \ No newline at end of file diff --git a/google/cloud/bigquery_v2/services/centralized_services/client.py b/google/cloud/bigquery_v2/services/centralized_services/client.py index aa581d2ab..63c403dcb 100644 --- a/google/cloud/bigquery_v2/services/centralized_services/client.py +++ b/google/cloud/bigquery_v2/services/centralized_services/client.py @@ -158,23 +158,3 @@ def list_models( """ kwargs = _drop_self_key(locals()) return self.model_service_client.list_models(**kwargs) - - -# =============================================== -# Sample TODO: Relocate this to a samples file -# =============================================== - -# Instantiate BQClient class -bqclient = BigQueryClient() - -# Instantiate Request class -get_dataset_request = GetDatasetRequest( - project_id=PROJECT_ID, - dataset_id="experimental", -) - -# Generate response -dataset = bqclient.get_dataset(request=get_dataset_request) - -# Display response -print(f"GET DATASET:\n\t{dataset.id=}\n") diff --git a/google/cloud/bigquery_v2/services/dataset_service/pagers.py b/google/cloud/bigquery_v2/services/dataset_service/pagers.py index c94c0b76a..de0afd87f 100644 --- a/google/cloud/bigquery_v2/services/dataset_service/pagers.py +++ b/google/cloud/bigquery_v2/services/dataset_service/pagers.py @@ -67,7 +67,6 @@ def __init__( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): """Instantiate the pager. diff --git a/google/cloud/bigquery_v2/services/model_service/pagers.py b/google/cloud/bigquery_v2/services/model_service/pagers.py index 567324a11..2a3fc6233 100644 --- a/google/cloud/bigquery_v2/services/model_service/pagers.py +++ b/google/cloud/bigquery_v2/services/model_service/pagers.py @@ -67,7 +67,6 @@ def __init__( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): """Instantiate the pager. diff --git a/google/cloud/bigquery_v2/services/routine_service/pagers.py b/google/cloud/bigquery_v2/services/routine_service/pagers.py index 7a67a9cd5..807f01503 100644 --- a/google/cloud/bigquery_v2/services/routine_service/pagers.py +++ b/google/cloud/bigquery_v2/services/routine_service/pagers.py @@ -67,7 +67,6 @@ def __init__( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): """Instantiate the pager. diff --git a/google/cloud/bigquery_v2/services/row_access_policy_service/pagers.py b/google/cloud/bigquery_v2/services/row_access_policy_service/pagers.py index 13a621b23..0b7d99f81 100644 --- a/google/cloud/bigquery_v2/services/row_access_policy_service/pagers.py +++ b/google/cloud/bigquery_v2/services/row_access_policy_service/pagers.py @@ -67,7 +67,6 @@ def __init__( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): """Instantiate the pager. diff --git a/google/cloud/bigquery_v2/services/table_service/pagers.py b/google/cloud/bigquery_v2/services/table_service/pagers.py index 1555d74c0..108e79eff 100644 --- a/google/cloud/bigquery_v2/services/table_service/pagers.py +++ b/google/cloud/bigquery_v2/services/table_service/pagers.py @@ -67,7 +67,6 @@ def __init__( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ): """Instantiate the pager.