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

Discovery caching with file_cache is unsupported #2272

Open
peterkappelt opened this issue Oct 29, 2023 · 2 comments
Open

Discovery caching with file_cache is unsupported #2272

peterkappelt opened this issue Oct 29, 2023 · 2 comments
Labels
needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@peterkappelt
Copy link

peterkappelt commented Oct 29, 2023

Hey everyone, this is a follow-up related to #1490 and #299.

If I understand correctly, discovery_cache.file_cache is broken (since it relies on oauth2client<4.0.0 which is deprecated) and there is no way of using the discovery cache currently (outside of app engine environments), right?

This is far from optimal, especially for a current project of mine, where API client objects are built frequently with different credentials - and I'd definitely prefer to avoid unnecessary discovery requests.

Do you have a plan/ strategy for supporting file_cache again in the future? If not, I'd suggest simply copying the oauth2client.contrib.locked_file module over to this repository. It is self-contained and thus should be fairly easy to maintain. Would that be a workaround you'd consider acceptable?

Cheers, Peter

@parthea
Copy link
Contributor

parthea commented Jan 26, 2024

In version 2.x of this library, a new feature was added to build clients using a cached copy of discovery artifacts.

The new feature is captured in the README (link below)
https://github.com/googleapis/google-api-python-client?tab=readme-ov-file#version-20-release

Discovery documents will no longer be retrieved dynamically when you call discovery.build(). The discovery documents will instead be retrieved from the client library directly. 

See the Migration Guide below which includes code samples
https://github.com/googleapis/google-api-python-client/blob/main/UPGRADING.md#200-migration-guide

This solution should work as long as the service and API version appear in the static discovery document directory here: https://github.com/googleapis/google-api-python-client/tree/main/googleapiclient/discovery_cache/documents

Please can you clarify if you require any discovery documents which are not in that directory?

@parthea parthea added type: question Request for information or clarification. Not an issue. needs more info This issue needs more information from the customer to proceed. labels Jan 26, 2024
@jupblb
Copy link

jupblb commented Feb 25, 2024

In version 2.x of this library, a new feature was added to build clients using a cached copy of discovery artifacts.

The new feature is captured in the README (link below) https://github.com/googleapis/google-api-python-client?tab=readme-ov-file#version-20-release

Discovery documents will no longer be retrieved dynamically when you call discovery.build(). The discovery documents will instead be retrieved from the client library directly. 

See the Migration Guide below which includes code samples https://github.com/googleapis/google-api-python-client/blob/main/UPGRADING.md#200-migration-guide

This solution should work as long as the service and API version appear in the static discovery document directory here: https://github.com/googleapis/google-api-python-client/tree/main/googleapiclient/discovery_cache/documents

Please can you clarify if you require any discovery documents which are not in that directory?

I think @peterkappelt was talking about cache_discovery while you've described static_discovery.

One way to solve this issue on your own is to add a custom implementation of Cache and use it as the cache argument of the googleapiclient.discovery.build function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants