-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
In gbq, use googleapiclient instead of apiclient #13458
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,12 @@ def _test_google_api_imports(): | |
|
||
try: | ||
import httplib2 # noqa | ||
from apiclient.discovery import build # noqa | ||
from apiclient.errors import HttpError # noqa | ||
try: | ||
from googleapiclient.discovery import build # noqa | ||
from googleapiclient.errors import HttpError # noqa | ||
except: | ||
from apiclient.discovery import build # noqa | ||
from apiclient.errors import HttpError # noqa | ||
from oauth2client.client import AccessTokenRefreshError # noqa | ||
from oauth2client.client import OAuth2WebServerFlow # noqa | ||
from oauth2client.file import Storage # noqa | ||
|
@@ -266,7 +270,10 @@ def sizeof_fmt(num, suffix='b'): | |
|
||
def get_service(self): | ||
import httplib2 | ||
from apiclient.discovery import build | ||
try: | ||
from googleapiclient.discovery import build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IOW the ci should be testing the original one & the new one (in different builds); so at least import checking should work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For python 2.7, we are using google-api-python-client version 1.2 doesn't support module googleapiclient (This was before apiclient was deprecated). In CI, we will test the original one when we run python 2.7, and the new one when we run python 3.4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a test to confirm that
I manually downgraded my google api python client to 1.2 and ran all unit tests locally to confirm that the old code still works using
|
||
except: | ||
from apiclient.discovery import build | ||
|
||
http = httplib2.Http() | ||
http = self.credentials.authorize(http) | ||
|
@@ -315,7 +322,10 @@ def process_insert_errors(self, insert_errors): | |
raise StreamingInsertError | ||
|
||
def run_query(self, query): | ||
from apiclient.errors import HttpError | ||
try: | ||
from googleapiclient.errors import HttpError | ||
except: | ||
from apiclient.errors import HttpError | ||
from oauth2client.client import AccessTokenRefreshError | ||
|
||
_check_google_client_version() | ||
|
@@ -420,7 +430,10 @@ def run_query(self, query): | |
return schema, result_pages | ||
|
||
def load_data(self, dataframe, dataset_id, table_id, chunksize): | ||
from apiclient.errors import HttpError | ||
try: | ||
from googleapiclient.errors import HttpError | ||
except: | ||
from apiclient.errors import HttpError | ||
|
||
job_id = uuid.uuid4().hex | ||
rows = [] | ||
|
@@ -474,7 +487,10 @@ def load_data(self, dataframe, dataset_id, table_id, chunksize): | |
self._print("\n") | ||
|
||
def verify_schema(self, dataset_id, table_id, schema): | ||
from apiclient.errors import HttpError | ||
try: | ||
from googleapiclient.errors import HttpError | ||
except: | ||
from apiclient.errors import HttpError | ||
|
||
try: | ||
return (self.service.tables().get( | ||
|
@@ -765,7 +781,10 @@ class _Table(GbqConnector): | |
|
||
def __init__(self, project_id, dataset_id, reauth=False, verbose=False, | ||
private_key=None): | ||
from apiclient.errors import HttpError | ||
try: | ||
from googleapiclient.errors import HttpError | ||
except: | ||
from apiclient.errors import HttpError | ||
self.http_error = HttpError | ||
self.dataset_id = dataset_id | ||
super(_Table, self).__init__(project_id, reauth, verbose, private_key) | ||
|
@@ -865,7 +884,10 @@ class _Dataset(GbqConnector): | |
|
||
def __init__(self, project_id, reauth=False, verbose=False, | ||
private_key=None): | ||
from apiclient.errors import HttpError | ||
try: | ||
from googleapiclient.errors import HttpError | ||
except: | ||
from apiclient.errors import HttpError | ||
self.http_error = HttpError | ||
super(_Dataset, self).__init__(project_id, reauth, verbose, | ||
private_key) | ||
|
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 don't know the detail of GBQ, but does it breaks user codes using
apiclient
now? Can there be any fallback logic?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.
Ah read your original doc. Pls ignore.
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 agree its better to fallback so that older versions don't break. I've pushed a new version
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.
Thx. Can you move them under
pandas/compat/gbq_compat
?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 think ok here - these r not used anywhere else