Skip to content
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

file_cache is unavailable when using oauth2client >= 4.0.0 #299

Closed
bivald opened this Issue Oct 23, 2016 · 16 comments

Comments

Projects
None yet
@bivald
Copy link

bivald commented Oct 23, 2016

This is related to #294

After upgrading google-api-python-client and oauth2client I get:

Oct 23 11:26:30 admin [11:26:30][WARNING] googleapiclient.discovery_cache init.py:autodetect:44 | file_cache is unavailable when using oauth2client >= 4.0.0#012Traceback (most recent call last):#12 File "/usr/share/python/.../local/lib/python2.7/site-packages/googleapiclient/discovery_cache/init.py", line 41, in autodetect#012 from . import file_cache#012 File "/usr/share/python/..../local/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in #12 'file_cache is unavailable when using oauth2client >= 4.0.0')#012ImportError: file_cache is unavailable when using oauth2client >= 4.0.0

I know that it was added to add oauth2client support (which I appreciate) and from what I can see doesn't actually abort any action - but would it be possible to remove the WARNING as well - or is it meant as a future todo?

It's not a huge issue, but possibly confusing to others - not to mention my eyes stopping at it every time I view any logs or monitoring.

@theacodes

This comment has been minimized.

Copy link
Member

theacodes commented Oct 24, 2016

You can silence this the same way you can silence any other log using the standard library logging infrastructure:

import logging

logging.getLogger('googleapicliet.discovery_cache').setLevel(logging.ERROR)

@theacodes theacodes closed this Oct 24, 2016

@bivald

This comment has been minimized.

Copy link
Author

bivald commented Oct 25, 2016

Of course you can! I apologize, I blame the lack of coffee for my ignorance.

@theacodes

This comment has been minimized.

Copy link
Member

theacodes commented Oct 25, 2016

No worries. :)

@dsoprea

This comment has been minimized.

Copy link

dsoprea commented Dec 8, 2016

Are we sure that this is that simple? I have a project that I'm getting reports of seizing/crashing/weirdness with and I'm seeing these all over the log (no other issues):

2016-12-08 20:11:27,816 [googleapiclient.discovery_cache WARNING] file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/usr/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0

These are ImportErrors, not just mere log verbosity. Thoughts?

@dsoprea

This comment has been minimized.

Copy link

dsoprea commented Dec 8, 2016

It's worth mentioning that my version reference to google-api-python-client hasn't changed in over 2.5 years. I can't fathom why I haven't seen this error before and why it appears to be an issue now. But, it does appear to be an exception which must be disrupting something whether it's specifically related to my user's issue or something silent from the logs is responsible for that.

@theacodes

This comment has been minimized.

Copy link
Member

theacodes commented Dec 8, 2016

@dsoprea if you silence the logs as above, do you still see the stacktrace?

@dsoprea

This comment has been minimized.

Copy link

dsoprea commented Dec 8, 2016

@jonparrott I've asked. Thanks.

@xmedeko

This comment has been minimized.

Copy link
Contributor

xmedeko commented Dec 22, 2016

I apologize to comment on closed issue, but is there any performance penalty when the file_cache is not used with oauth2client 4.0.0? I.e. should I keep the oauth2client 3.0.0 or may I safely upgrade and ignore the warning? Thanks.

@maxrp

This comment has been minimized.

Copy link

maxrp commented Dec 22, 2016

It seems to be the better way to silence this error, if one does not care about the cache, is to simply specify cache_discovery=False when performing discovery.build() -- this avoids the broken code path.

@bachp bachp referenced this issue Feb 12, 2017

Merged

Update google component dependencies #5904

2 of 2 tasks complete

@lwis lwis referenced this issue Feb 20, 2017

Merged

[google] suppress file_cache warning #6128

1 of 1 task complete

SathyaBhat added a commit to SathyaBhat/spotify-dl that referenced this issue Feb 24, 2017

disable discovery cache to prevent
"file_cache is unavailable when using oauth2client >= 4.0.0" errors
 as hinted in googleapis/google-api-python-client#299 (comment)
@WiliTest

This comment has been minimized.

Copy link

WiliTest commented Mar 21, 2017

maxrp solution worked (python3.6) for most logging message: discovery.build('drive', 'v3', http=http, cache_discovery=False)

but I also needed to set the logging level of the googleapiclient.discovery using jonparrott proposition:
logging.getLogger('googleapiclient.discovery').setLevel(logging.CRITICAL)

@sendvibe

This comment has been minimized.

Copy link

sendvibe commented Nov 9, 2017

jonparrott's answer almost worked for me.... you just have to fix the typo:

import logging
logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR)

rasmi added a commit to rasmi/tensor2tensor that referenced this issue Mar 27, 2018

rsepassi added a commit to tensorflow/tensor2tensor that referenced this issue Mar 30, 2018

Fixed small issues with ML Engine script. (#670)
* Fixed typo in flags.

* Fixed indentation.

* Clarified machine type documentation.

* Disable cache discovery.

See googleapis/google-api-python-client#299
@phgachoud

This comment has been minimized.

Copy link

phgachoud commented Apr 7, 2018

as per this answer disable it adding cache_discovery=False in discover.build(api, version, http=http, cache_discovery=False)

@mundaneken

This comment has been minimized.

Copy link

mundaneken commented Jun 11, 2018

OMG, I could kiss you guys. I've been shoving beans up my nose for days trying to find the cause of the empty rows. Confirmed: change scope and re-auth fixes the problem.

@Chronial

This comment has been minimized.

Copy link

Chronial commented Sep 7, 2018

For anybody else looking for this: The open issue tracking this is #325. It also contains some better workarounds.

@alexaugustoribeiro

This comment has been minimized.

Copy link

alexaugustoribeiro commented Oct 4, 2018

It seems to be the better way to silence this error, if one does not care about the cache, is to simply specify cache_discovery=False when performing discovery.build() -- this avoids the broken code path.

EXCELLENT! that worked for me.
when calling the auth I just added cache_discovery=False as a new parameter
service = build('admin', 'directory_v1', cache_discovery=False, http=creds.authorize(Http()))

@khushbuparakh

This comment has been minimized.

Copy link

khushbuparakh commented Apr 19, 2019

GCP_discovery.build('compute', 'v1', credentials=self.credentials, cache_discovery=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.