Skip to content

Commit

Permalink
chore: migrate to owl bot (googleapis#663)
Browse files Browse the repository at this point in the history
* chore: migrate to owl bot

* chore: copy files from googleapis-gen f2de93abafa306b2ebadf1d10d947db8bcf2bf15

* chore: run the post processor
  • Loading branch information
parthea authored May 13, 2021
1 parent 506b268 commit e8838a7
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 207 deletions.
4 changes: 4 additions & 0 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker:
digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e
image: gcr.io/repo-automation-bots/owlbot-python:latest

26 changes: 26 additions & 0 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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/repo-automation-bots/owlbot-python:latest

deep-remove-regex:
- /owl-bot-staging

deep-copy-regex:
- source: /google/cloud/bigquery/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/$1/$2

begin-after-commit-hash: f2de93abafa306b2ebadf1d10d947db8bcf2bf15

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ repos:
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
rev: 3.9.1
hooks:
- id: flake8
16 changes: 1 addition & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,7 @@ Running System Tests
auth settings and change some configuration in your project to
run all the tests.

- System tests will be run against an actual project and
so you'll need to provide some environment variables to facilitate
authentication to your project:

- ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file;
Such a file can be downloaded directly from the developer's console by clicking
"Generate new JSON key". See private key
`docs <https://cloud.google.com/storage/docs/authentication#generating-a-private-key>`__
for more details.

- Once you have downloaded your json keys, set the environment variable
``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file::

$ export GOOGLE_APPLICATION_CREDENTIALS="/Users/<your_username>/path/to/app_credentials.json"

- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication <https://cloud.google.com/docs/authentication/best-practices-applications#local_development_and_testing_with_the>`__. Some tests require a service account. For those tests see `Authenticating as a service account <https://cloud.google.com/docs/authentication/production>`__.

*************
Test Coverage
Expand Down
110 changes: 53 additions & 57 deletions synth.py → owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,61 @@
from synthtool import gcp
from synthtool.languages import python

gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()
version = "v2"

library = gapic.py_library(
service="bigquery",
version=version,
bazel_target=f"//google/cloud/bigquery/{version}:bigquery-{version}-py",
include_protos=True,
)

s.move(
library,
excludes=[
"*.tar.gz",
"docs/index.rst",
"docs/bigquery_v2/*_service.rst",
"docs/bigquery_v2/services.rst",
"README.rst",
"noxfile.py",
"setup.py",
"scripts/fixup_bigquery_v2_keywords.py",
library / f"google/cloud/bigquery/__init__.py",
library / f"google/cloud/bigquery/py.typed",
# There are no public API endpoints for the generated ModelServiceClient,
# thus there's no point in generating it and its tests.
library / f"google/cloud/bigquery_{version}/services/**",
library / f"tests/unit/gapic/bigquery_{version}/**",
],
)
default_version = "v2"

for library in s.get_staging_dirs(default_version):
# Do not expose ModelServiceClient, as there is no public API endpoint for the
# models service.
s.replace(
library / f"google/cloud/bigquery_{library.name}/__init__.py",
r"from \.services\.model_service import ModelServiceClient",
"",
)
s.replace(
library / f"google/cloud/bigquery_{library.name}/__init__.py",
r"""["']ModelServiceClient["'],""",
"",
)

# Adjust Model docstring so that Sphinx does not think that "predicted_" is
# a reference to something, issuing a false warning.
s.replace(
library / f"google/cloud/bigquery_{library.name}/types/model.py",
r'will have a "predicted_"',
"will have a `predicted_`",
)

# Avoid breaking change due to change in field renames.
# https://github.com/googleapis/python-bigquery/issues/319
s.replace(
library / f"google/cloud/bigquery_{library.name}/types/standard_sql.py",
r"type_ ",
"type "
)

s.move(
library,
excludes=[
"*.tar.gz",
"docs/index.rst",
f"docs/bigquery_{library.name}/*_service.rst",
f"docs/bigquery_{library.name}/services.rst",
"README.rst",
"noxfile.py",
"setup.py",
f"scripts/fixup_bigquery_{library.name}_keywords.py",
f"google/cloud/bigquery/__init__.py",
f"google/cloud/bigquery/py.typed",
# There are no public API endpoints for the generated ModelServiceClient,
# thus there's no point in generating it and its tests.
f"google/cloud/bigquery_{library.name}/services/**",
f"tests/unit/gapic/bigquery_{library.name}/**",
],
)

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
# Add templated files
Expand Down Expand Up @@ -79,41 +104,12 @@

python.py_samples()

# Do not expose ModelServiceClient, as there is no public API endpoint for the
# models service.
s.replace(
"google/cloud/bigquery_v2/__init__.py",
r"from \.services\.model_service import ModelServiceClient",
"",
)
s.replace(
"google/cloud/bigquery_v2/__init__.py",
r"""["']ModelServiceClient["'],""",
"",
)

# Adjust Model docstring so that Sphinx does not think that "predicted_" is
# a reference to something, issuing a false warning.
s.replace(
"google/cloud/bigquery_v2/types/model.py",
r'will have a "predicted_"',
"will have a `predicted_`",
)

s.replace(
"docs/conf.py",
r'\{"members": True\}',
'{"members": True, "inherited-members": True}'
)

# Avoid breaking change due to change in field renames.
# https://github.com/googleapis/python-bigquery/issues/319
s.replace(
"google/cloud/bigquery_v2/types/standard_sql.py",
r"type_ ",
"type "
)

# Tell Sphinx to ingore autogenerated docs files.
s.replace(
"docs/conf.py",
Expand Down
134 changes: 0 additions & 134 deletions synth.metadata

This file was deleted.

0 comments on commit e8838a7

Please sign in to comment.