Skip to content

Commit

Permalink
Merging of the google ads vendored-in code. (apache#30399)
Browse files Browse the repository at this point in the history
Following google ads disabling v11 of their API, we are vendoring in
google adds code. This is the first commit that just vendors in the
original code of google-ads v. 20.0.0

It will be followed by a second PR where the code will be
modified following the new package. Separating those two
commits will help in case we have a need to migrate to another
version of the library as then we will just revert this one
and apply the second and resolve conflicts.
  • Loading branch information
potiuk authored Apr 1, 2023
1 parent 3c9369a commit 2e65c70
Show file tree
Hide file tree
Showing 1,308 changed files with 196,775 additions and 40 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ omit =
airflow/migrations/**
airflow/providers/**/example_dags/**
airflow/www/node_modules/**
airflow/providers/google/ads/_vendor/**

[report]
skip_empty = True
Expand Down
74 changes: 38 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
name: Add TOC for Markdown and RST files
files:
^CONTRIBUTING\.md$|^README\.md$|^UPDATING.*\.md$|^chart/UPDATING.*\.md$|^dev/.*\.md$|^dev/.*\.rst$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
args:
- "--maxlevel"
- "2"
Expand All @@ -47,7 +47,7 @@ repos:
exclude: |
(?x)
^\.github/|
^airflow/_vendor/
^.*/_vendor/
args:
- --comment-style
- "/*||*/"
Expand All @@ -56,7 +56,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all RST files
exclude: ^\.github/.*$|^airflow/_vendor/|newsfragments/.*\.rst$
exclude: ^\.github/.*$|^.*/_vendor/|newsfragments/.*\.rst$
args:
- --comment-style
- "||"
Expand All @@ -67,7 +67,7 @@ repos:
- id: insert-license
name: Add license for all CSS/JS/JSX/PUML/TS/TSX files
files: \.(css|jsx?|puml|tsx?)$
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
args:
- --comment-style
- "/*!| *| */"
Expand All @@ -77,7 +77,7 @@ repos:
- id: insert-license
name: Add license for all JINJA template files
files: ^airflow/www/templates/.*\.html$
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
args:
- --comment-style
- "{#||#}"
Expand All @@ -86,7 +86,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all Shell files
exclude: ^\.github/.*$|^airflow/_vendor/|^dev/breeze/autocomplete/.*$
exclude: ^\.github/.*$|^.*/_vendor/|^dev/breeze/autocomplete/.*$
files: \.bash$|\.sh$
args:
- --comment-style
Expand All @@ -96,7 +96,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all Python files
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
files: \.py$|\.pyi$
args:
- --comment-style
Expand All @@ -106,7 +106,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all XML files
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
files: \.xml$
args:
- --comment-style
Expand All @@ -116,7 +116,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all YAML files
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
types: [yaml]
files: \.ya?ml$
args:
Expand All @@ -128,7 +128,7 @@ repos:
- id: insert-license
name: Add license for all Markdown files
files: \.md$
exclude: ^\.github/.*$|PROVIDER_CHANGES.*\.md$|^airflow/_vendor/
exclude: ^\.github/.*$|PROVIDER_CHANGES.*\.md$|^.*/_vendor/
args:
- --comment-style
- "<!--|| -->"
Expand All @@ -137,7 +137,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all other files
exclude: ^\.github/.*$|^airflow/_vendor/
exclude: ^\.github/.*$|^.*/_vendor/
args:
- --comment-style
- "|#|"
Expand All @@ -152,7 +152,7 @@ repos:
- id: black
name: Run black (Python formatter)
args: [--config=./pyproject.toml]
exclude: ^airflow/_vendor/|^airflow/contrib/
exclude: ^.*/_vendor/|^airflow/contrib/
- repo: local
hooks:
- id: update-common-sql-api-stubs
Expand Down Expand Up @@ -181,7 +181,7 @@ repos:
entry: ruff --fix --no-update-check --force-exclude
additional_dependencies: ['ruff==0.0.226']
files: \.pyi?$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
Expand All @@ -204,28 +204,28 @@ repos:
name: Detect accidentally committed debug statements
- id: check-builtin-literals
name: Require literal syntax when initializing Python builtin types
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: detect-private-key
name: Detect if private key is added to the repository
exclude: ^docs/apache-airflow-providers-ssh/connections/ssh.rst$
- id: end-of-file-fixer
name: Make sure that there is an empty line at the end
exclude: ^airflow/_vendor/|^docs/apache-airflow/img/.*\.dot|^docs/apache-airflow/img/.*\.sha256
exclude: ^.*/_vendor/|^docs/apache-airflow/img/.*\.dot|^docs/apache-airflow/img/.*\.sha256
- id: mixed-line-ending
name: Detect if mixed line ending is used (\r vs. \r\n)
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: check-executables-have-shebangs
name: Check that executables have shebang
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: check-xml
name: Check XML files with xmllint
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: trailing-whitespace
name: Remove trailing whitespace at end of line
exclude: ^airflow/_vendor/|^docs/apache-airflow/img/.*\.dot|^images/breeze/output.*$
exclude: ^.*/_vendor/|^docs/apache-airflow/img/.*\.dot|^images/breeze/output.*$
- id: fix-encoding-pragma
name: Remove encoding header from Python files
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
args:
- --remove
- id: pretty-format-json
Expand All @@ -242,26 +242,26 @@ repos:
hooks:
- id: rst-backticks
name: Check if RST files use double backticks for code
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: python-no-log-warn
name: Check if there are no deprecate log warn
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- repo: https://github.com/adrienverge/yamllint
rev: v1.29.0
hooks:
- id: yamllint
name: Check YAML files with yamllint
entry: yamllint -c yamllint-config.yml --strict
types: [yaml]
exclude: ^.*airflow\.template\.yaml$|^.*init_git_sync\.template\.yaml$|^airflow/_vendor/|^chart/(?:templates|files)/.*\.yaml$|openapi/.*\.yaml$|^\.pre-commit-config\.yaml$
exclude: ^.*airflow\.template\.yaml$|^.*init_git_sync\.template\.yaml$|^.*/_vendor/|^chart/(?:templates|files)/.*\.yaml$|openapi/.*\.yaml$|^\.pre-commit-config\.yaml$
- repo: https://github.com/ikamensh/flynt
rev: '0.77'
hooks:
- id: flynt
name: Run flynt string format converter for Python
exclude: |
(?x)
^airflow/_vendor/
^.*/_vendor/
args:
# If flynt detects too long text it ignores it. So we set a very large limit to make it easy
# to split the text by hand. Too long lines are detected by flake8 (below),
Expand All @@ -278,7 +278,7 @@ repos:
The word(s) should be in lowercase." && exec codespell "$@"' --
language: python
types: [text]
exclude: ^airflow/_vendor/|^airflow/www/static/css/material-icons\.css$|^images/.*$|^RELEASE_NOTES\.txt$|^.*package-lock\.json$
exclude: ^.*/_vendor/|^airflow/www/static/css/material-icons\.css$|^images/.*$|^RELEASE_NOTES\.txt$|^.*package-lock\.json$
args:
- --ignore-words=docs/spelling_wordlist.txt
- --skip=airflow/providers/*/*.rst,airflow/www/*.log,docs/*/commits.rst,docs/apache-airflow/tutorial/pipeline_example.csv,*.min.js,*.lock,INTHEWILD.md
Expand All @@ -290,7 +290,7 @@ repos:
entry: ./scripts/ci/pre_commit/pre_commit_replace_bad_characters.py
language: python
types: [file, text]
exclude: ^airflow/_vendor/|^clients/gen/go\.sh$|^\.gitmodules$
exclude: ^.*/_vendor/|^clients/gen/go\.sh$|^\.gitmodules$
additional_dependencies: ['rich>=12.4.4']
- id: lint-openapi
name: Lint OpenAPI using spectral
Expand Down Expand Up @@ -419,7 +419,7 @@ repos:
entry: "^\\s*from\\s+\\."
pass_filenames: true
files: \.py$
exclude: ^airflow/_vendor/|^docs/|^tests/
exclude: ^.*/_vendor/|^docs/|^tests/
- id: check-urlparse-usage-in-code
language: pygrep
name: Don't use urlparse in code
Expand Down Expand Up @@ -483,6 +483,7 @@ repos:
^airflow/www/static/css/bootstrap-theme.css$|
^airflow/www/static/js/types/api-generated.ts$|
^airflow/www/templates/appbuilder/flash.html$|
^.*/_vendor/|
^dev/|
^docs/README.rst$|
^docs/apache-airflow-providers-amazon/secrets-backends/aws-ssm-parameter-store.rst$|
Expand Down Expand Up @@ -535,7 +536,7 @@ repos:
files: >
(?x)
^airflow/providers/.*\.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
- id: check-decorated-operator-implements-custom-name
name: Check @task decorator implements custom_operator_name
language: python
Expand All @@ -556,28 +557,28 @@ repos:
to avoid import cycles.
entry: "from airflow\\.utils\\.db import.* (provide_session|create_session)"
files: \.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
pass_filenames: true
- id: check-incorrect-use-of-LoggingMixin
language: pygrep
name: Make sure LoggingMixin is not used alone
entry: "LoggingMixin\\(\\)"
files: \.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
pass_filenames: true
- id: check-daysago-import-from-utils
language: pygrep
name: Make sure days_ago is imported from airflow.utils.dates
entry: "(airflow\\.){0,1}utils\\.dates\\.days_ago"
files: \.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
pass_filenames: true
- id: check-start-date-not-used-in-defaults
language: pygrep
name: "'start_date' not to be defined in default_args in example_dags"
entry: "default_args\\s*=\\s*{\\s*(\"|')start_date(\"|')|(\"|')start_date(\"|'):"
files: \.*example_dags.*\.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
pass_filenames: true
- id: check-apache-license-rat
name: Check if licenses are OK for Apache
Expand Down Expand Up @@ -723,7 +724,7 @@ repos:
language: python
pass_filenames: true
files: .*\.schema\.json$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
require_serial: true
additional_dependencies: ['jsonschema>=3.2.0,<5.0', 'PyYAML==5.3.1', 'requests==2.25.0']
- id: lint-json-schema
Expand Down Expand Up @@ -808,7 +809,7 @@ repos:
language: python
pass_filenames: true
files: \.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
additional_dependencies: ['rich>=12.4.4']
- id: lint-chart-schema
name: Lint chart/values.schema.json file
Expand Down Expand Up @@ -868,7 +869,7 @@ repos:
language: python
pass_filenames: true
files: \.py$
exclude: ^airflow/_vendor/
exclude: ^.*/_vendor/
additional_dependencies: ['rich>=12.4.4', 'astor']
- id: create-missing-init-py-files-tests
name: Create missing init.py files in tests
Expand Down Expand Up @@ -899,14 +900,15 @@ repos:
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: \.py$
exclude: ^airflow/_vendor/|^airflow/migrations|^airflow/providers|^dev|^docs|^provider_packages|^tests/providers|^tests/system/providers
exclude: ^.*/_vendor/|^airflow/migrations|^airflow/providers|^dev|^docs|^provider_packages|^tests/providers|^tests/system/providers
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout']
- id: run-mypy
name: Run mypy for providers
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: ^airflow/providers/.*\.py$|^tests/providers/\*\.py$|^tests/system/providers/\*\.py$
exclude: ^.*/_vendor/
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout']
- id: run-mypy
Expand Down
1 change: 1 addition & 0 deletions .rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ tmp

# Vendored-in code
_vendor
./airflow/providers/google/ads/_vendor

# generated doc-only-changes.txt
.latest-doc-only-change.txt
Expand Down
37 changes: 37 additions & 0 deletions airflow/providers/google/ads/_vendor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Vendor package

## What vendored packages are for

The `_vendor` package is foreseen for vendoring in packages, that we have to modify ourselves
because authors of the packages do not have time to modify them themselves. This is often temporary
and once the packages implement fixes that we need, and then we remove the packages from
the `_vendor` package.

All Vendored libraries must follow these rules:

1. Vendored libraries must be pure Python--no compiling (so that we do not have to release multi-platform airflow packages on PyPI).
2. Source code for the libary is included in this directory.
3. License must be included in this repo and in the [LICENSE](../../LICENSE) file and in the
[licenses](../../licenses) folder.
4. Requirements of the library become requirements of airflow core.
5. Version of the library should be included in the [vendor.md](vendor.md) file.
6. No modifications to the library may be made in the initial commit.
7. Apply the fixes necessary to use the vendored library as separate commits - each package separately,
so that they can be cherry-picked later if we upgrade the vendored package. Changes to airflow code to
use the vendored packages should be applied as separate commits/PRs.
8. The `_vendor` packages should be excluded from any refactorings, static checks and automated fixes.

## Adding and upgrading a vendored package

Way to vendor a library or update a version:

1. Update ``vendor.md`` with the library, version, and SHA256 (`pypi` provides hashes as of recently)
2. Remove all old files and directories of the old version.
3. Replace them with new files (only replace relevant python packages:move LICENSE )
* move licence files to [licenses](../../licenses) folder
* remove README and any other supporting files (they can be found in PyPI)
* make sure to add requirements from setup.py to airflow's setup.py with appropriate comment stating
why the requirements are added and when they should be removed
4. If you replace previous version, re-apply historical fixes from the "package" folder by
cherry-picking them.

Empty file.
19 changes: 19 additions & 0 deletions airflow/providers/google/ads/_vendor/googleads/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 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.ads.googleads.client
import google.ads.googleads.errors
import google.ads.googleads.util

VERSION = "20.0.0"
Loading

0 comments on commit 2e65c70

Please sign in to comment.