-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Save BigQuery account credentials in a hidden user folder #83
ENH: Save BigQuery account credentials in a hidden user folder #83
Conversation
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
===========================================
- Coverage 73.38% 28.01% -45.38%
===========================================
Files 4 4
Lines 1563 1578 +15
===========================================
- Hits 1147 442 -705
- Misses 416 1136 +720
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it.
Will need a corresponding update to pandas.io.gbq to document the new parameter.
pandas_gbq/gbq.py
Outdated
# Create a pandas_gbq directory in an application-specific hidden | ||
# user folder on the operating system. | ||
if not os.path.exists(config_path): | ||
os.mkdir(config_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this recursive if .config doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! os.mkdir
is not recursive. Fixed.
else: | ||
config_path = os.path.join(os.path.expanduser('~'), '.config') | ||
|
||
config_path = os.path.join(config_path, 'pandas_gbq') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know this better than I do, but is there a case for having the default path be the default gcloud path, rather than anything specific to pandas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great question! I've given this some thought and I don't feel comfortable writing default credentials into the gcloud
path in case some users don't want to have their default gcloud
credentials set (and I'm also worried about colliding with gcloud
). Alternatively, users could run gcloud auth application-default login
if they want to configure default credentials and the default gcloud
credentials should be picked up. In that case, we shouldn't hit this code path. https://github.com/pydata/pandas-gbq/blob/master/pandas_gbq/gbq.py#L222
@tswast Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to not clobbering gcloud
credentials. The token we save doesn't have the full Google Cloud Platform scope so that would break other applications that depend on those credentials.
If folks set up application default credentials it won't hit this code anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users could run gcloud auth application-default login
If folks set up application default credentials it won't hit this code anyway.
👍
I've also made the changes required for pandas.io.gbq in the following branch: I'll hold off on creating a PR in pandas until this is merged. |
e455f18
to
0c713b6
Compare
0c713b6
to
d0cd4f2
Compare
docs/source/changelog.rst
Outdated
@@ -1,12 +1,12 @@ | |||
Changelog | |||
========= | |||
|
|||
0.2.1 / 2017-??-?? | |||
0.3.0 / 2017-??-?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should do an incremental release before 0.3.0
if we plan to have that be the one where we swap to the google-cloud-python libraries? Seems like that PR has stalled and I don't have time to rebase it either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Closes #41
This PR adds ability for users to choose the location where BigQuery user account credentials will be stored via the
credentials_path
parameter.This PR also changes the location of the file
bigquery_credentials.dat
that contains the BigQuery user account credentials. Previously this file was saved in the current working directory. The credentials file will now be stored in an application-specific hidden user folder on the operating system. On windows, this path is specified in theAPPDATA
environment variable as defined here which is typically'C:\Documents and Settings\username\Application Data\pandas-gbq\'
. Otherwise, credentials will be stored in'~/.config/pandas-gbq/'
. If the filebigquery_credentials.dat
is found in the current working directory, the file will be moved to the new location.@tswast @jreback Please could you take a look at your earliest convenience?