[AIRFLOW-2512][AIRFLOW-2522] Use google-auth instead of oauth2client#3488
[AIRFLOW-2512][AIRFLOW-2522] Use google-auth instead of oauth2client#3488tswast wants to merge 1 commit intoapache:masterfrom
Conversation
93e2afe to
4cc1bef
Compare
|
Thank You for this PR. Can you please have a look at the failing travis build? |
|
Yeah, just pushed what I hope will be a fix. |
kaxil
left a comment
There was a problem hiding this comment.
LGTM. Let's wait for the results from Travis CI now.
|
@tswast Can you please rebase against the master? The CI was failing for unrelated tests which are now fixed. |
|
Rebased. 🤞 |
Codecov Report
@@ Coverage Diff @@
## master #3488 +/- ##
==========================================
+ Coverage 77.16% 77.16% +<.01%
==========================================
Files 203 203
Lines 15123 15123
==========================================
+ Hits 11669 11670 +1
+ Misses 3454 3453 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Is this going to work with users that don't want to use a service account? Developers often times want to oauth using their Google account rather than using a service account. Will this continue to work?
There was a problem hiding this comment.
Yes, it will work. google-auth does read credentials from the Google Cloud SDK.
Note: those developers will get an annoying warning message. See: googleapis/google-auth-library-python#271
If that's a concern we could possibly add a user-auth option as is done in pandas-gbq, but that's quite a bit more code to do. I'd prefer to do that in a separate PR, as it would be additional functionality as opposed to this which is a 1:1 replacement.
There was a problem hiding this comment.
Great, I'm fine with a 1:1 replacement. Just want to make sure that we don't lose functionality that we rely on. :)
Fokko
left a comment
There was a problem hiding this comment.
Could you also update the docs?
MacBook-Pro-van-Fokko:incubator-airflow fokkodriesprong$ grep -R oauth2client .
./docs/conf.py: 'oauth2client.service_account',
Binary file ./airflow/contrib/hooks/gcp_api_base_hook.pyc matches
grep: ./airflow/www/static/docs: No such file or directory
grep: ./airflow/www_rbac/static/docs: No such file or directory
./scripts/ci/requirements.txt:oauth2client>=2.0.2,<2.1.0
|
I'm a bit curious why they are mocking out so many modules in |
|
I'm not an expert on intersphinx, but feel free to PR some of your knowledge to Airflow ;) |
* Updates the GCP hooks to use the google-auth library and removes dependencies on the deprecated oauth2client package. * Removes inconsistent handling of the scope parameter for different auth methods. Note: using google-auth for credentials requires a newer version of the google-api-python-client package, so this commit also updates the minimum version for that. To avoid some annoying warnings about the discovery cache not being supported, so disable the discovery cache explicitly as recommend here: https://stackoverflow.com/a/44518587/101923 Tested by running: nosetests tests/contrib/operators/test_dataflow_operator.py \ tests/contrib/operators/test_gcs*.py \ tests/contrib/operators/test_mlengine_*.py \ tests/contrib/operators/test_pubsub_operator.py \ tests/contrib/hooks/test_gcp*.py \ tests/contrib/hooks/test_gcs_hook.py \ tests/contrib/hooks/test_bigquery_hook.py and also tested by running some GCP-related DAGs locally, such as the Dataproc DAG example at https://cloud.google.com/composer/docs/quickstart
|
@Fokko Done. Regarding Intersphinx, I've filed https://issues.apache.org/jira/browse/AIRFLOW-2603 to get to in a separate PR. |
|
Great work @tswast . Thanks 👍 |
* Updates the GCP hooks to use the google-auth library and removes dependencies on the deprecated oauth2client package. * Removes inconsistent handling of the scope parameter for different auth methods. Note: using google-auth for credentials requires a newer version of the google-api-python-client package, so this commit also updates the minimum version for that. To avoid some annoying warnings about the discovery cache not being supported, so disable the discovery cache explicitly as recommend here: https://stackoverflow.com/a/44518587/101923 Tested by running: nosetests tests/contrib/operators/test_dataflow_operator.py \ tests/contrib/operators/test_gcs*.py \ tests/contrib/operators/test_mlengine_*.py \ tests/contrib/operators/test_pubsub_operator.py \ tests/contrib/hooks/test_gcp*.py \ tests/contrib/hooks/test_gcs_hook.py \ tests/contrib/hooks/test_bigquery_hook.py and also tested by running some GCP-related DAGs locally, such as the Dataproc DAG example at https://cloud.google.com/composer/docs/quickstart Closes #3488 from tswast/google-auth (cherry picked from commit 0f4d681) Signed-off-by: Bolke de Bruin <bolke@xs4all.nl>
* Updates the GCP hooks to use the google-auth library and removes dependencies on the deprecated oauth2client package. * Removes inconsistent handling of the scope parameter for different auth methods. Note: using google-auth for credentials requires a newer version of the google-api-python-client package, so this commit also updates the minimum version for that. To avoid some annoying warnings about the discovery cache not being supported, so disable the discovery cache explicitly as recommend here: https://stackoverflow.com/a/44518587/101923 Tested by running: nosetests tests/contrib/operators/test_dataflow_operator.py \ tests/contrib/operators/test_gcs*.py \ tests/contrib/operators/test_mlengine_*.py \ tests/contrib/operators/test_pubsub_operator.py \ tests/contrib/hooks/test_gcp*.py \ tests/contrib/hooks/test_gcs_hook.py \ tests/contrib/hooks/test_bigquery_hook.py and also tested by running some GCP-related DAGs locally, such as the Dataproc DAG example at https://cloud.google.com/composer/docs/quickstart Closes apache#3488 from tswast/google-auth
Make sure you have checked all steps below.
JIRA
Description
dependencies on the deprecated oauth2client package.
auth methods.
Note: using google-auth for credentials requires a newer version of the
google-api-python-client package, so this commit also updates the
minimum version for that.
To avoid some annoying warnings about the discovery cache not being
supported, so disable the discovery cache explicitly as recommend here:
https://stackoverflow.com/a/44518587/101923
No UI changes.
Tests
Added
test_gcp_api_base_hook.pyto test fix for [AIRFLOW-2522] (allowing scopes for default credentials).Tested by running:
and also tested by running some GCP-related DAGs locally, such as the
Dataproc DAG example at
https://cloud.google.com/composer/docs/quickstart
Commits
Documentation
Tweaked explanation of default credentials since they can be many different kinds of credentials besides those from the
gcloudcommand.Code Quality
git diff upstream/master -u -- "*.py" | flake8 --diff