Skip to content

file_cache is unavailable when using oauth2client >= 4.0.0 #299

Closed

Description

@bivald

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.

Activity

  1. theacodes commented on Oct 24, 2016

    @theacodes
    Contributor

    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)
    
  2. bivald commented on Oct 25, 2016

    @bivald
    Author

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

  3. theacodes commented on Oct 25, 2016

    @theacodes
    Contributor

    No worries. :)

  4. dsoprea commented on Dec 8, 2016

    @dsoprea

    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?

  5. dsoprea commented on Dec 8, 2016

    @dsoprea

    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.

  6. theacodes commented on Dec 8, 2016

    @theacodes
    Contributor

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

  7. dsoprea commented on Dec 8, 2016

    @dsoprea

    @jonparrott I've asked. Thanks.

  8. xmedeko commented on Dec 22, 2016

    @xmedeko
    Contributor

    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.

  9. maxrp commented on Dec 22, 2016

    @maxrp

    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.

  10. added a commit that references this issue on Feb 24, 2017
  11. WiliTest commented on Mar 21, 2017

    @WiliTest

    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)

  12. added a commit that references this issue on Sep 5, 2017
  13. sendvibe commented on Nov 9, 2017

    @sendvibe

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

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

  14. 26 remaining items

  15. mohitjoshi155 commented on May 20, 2022

    @mohitjoshi155

    file_cache is only supported with oauth2client<4.0.0
    i am getting this error still

  16. sabuhigr commented on Jun 21, 2022

    @sabuhigr

    init: file_cache is only supported with oauth2client<4.0.0

    Still getting error.

  17. mabusdogma commented on Nov 11, 2022

    @mabusdogma

    Still... still getting this error

  18. rnag commented on Apr 13, 2023

    @rnag

    Same.. please fix. Tuning down error log messages is a workaround rather than a fix.

  19. trizko commented on Aug 9, 2023

    @trizko

    For anyone landing on this issue in 2023, maxrp's solution from 2016 still works, setting cache_discovery=False:

    from googleapiclient.discovery import build
    
    client = build('drive', 'v3', cache_discovery=False)
  20. added a commit that references this issue on Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨triage me

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions