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

Pass kwargs to discovery.build() when instantiating GSCClient. #2291

Merged

Conversation

danthelion
Copy link
Contributor

Description

https://github.com/google/google-api-python-client/blob/89906ac33b37c6017c893841743aa4f45729c91f/googleapiclient/discovery.py#L175

https://github.com/google/google-api-python-client/blob/89906ac33b37c6017c893841743aa4f45729c91f/googleapiclient/discovery.py#L297

The build and build_from_document methods has some useful keyword arguments that are currently not useable from the GSCClient interface.

Motivation and Context

My use case for these changes is getting rid of warning log spam because of a default argument (cache_discovery=True)

googleapis/google-api-python-client#299
googleapis/oauth2client#673

Have you tested this? If so, how?

Locally, running my pipeline with the cache_discovery=False argument passed on instantiation.

@danthelion danthelion force-pushed the gcs_client_discovery_build_kwargs branch from 1841585 to 97c140e Compare November 22, 2017 05:56
@ADiegoCAlonso
Copy link

@dlstadther These changes are quite simple and would help a lot to debug using the logs. Any possibility of an admin having a look?

@dlstadther
Copy link
Collaborator

@danthelion could you rebase this branch with the new version of gcs?

@danthelion danthelion force-pushed the gcs_client_discovery_build_kwargs branch from 97c140e to e802bc3 Compare March 8, 2018 14:06
@danthelion
Copy link
Contributor Author

@dlstadther Done.

else:
self.client = discovery.build('storage', 'v1', cache_discovery=False, **authenticate_kwargs)
self.client = discovery.build('storage', 'v1', **build_kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've undone the default cache_discovery value supplied by #2361 . This addition was recommended by @himikof . Did you intentionally remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the original intention of my PR was regarding this parameter a well.
I think it's better to modify it on the client side (by propagating it with build_kwargs) and True is always a sane default for caching functionalities.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@himikof Would you like to voice your opinion on moving the default back to True?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, though I in general agree that turning caching on is a sane default in general, I do disagree in this particular case. The discovery caching in googleapiclient is mostly broken, as indicated in the linked issues, and nobody tried to fix this upstream for several years. The chances of file caching working are even more reduced by #2361 dropping oauth2client dependency.
The best solution would be to have some kind of simple in-memory cache without external dependencies by default in the upstream googleapiclient, but I do not believe this is a Luigi issue.
What Luigi can do, though, is to ensure GCP-related functionality works out of the box, without getting scary ImportError log spam or learning about API discovery caching (which is not that important to know about).
So I would say that getting a way to pass custom discovery kwargs is certainly an improvement, but I feel that Luigi should change the default of the cache_discovery value, at least until the discovery caching works out of the box in the upstream library. It is a simple matter of doing kwargs.setdefault('cache_discovery', False).

@danthelion danthelion force-pushed the gcs_client_discovery_build_kwargs branch from e802bc3 to 8d927f4 Compare March 11, 2018 14:33
@danthelion
Copy link
Contributor Author

@himikof I have added 'cache_discovery' = False as a default parameter for the discovery build call, I think you are right about it, produces way too many logs when caching is enabled and it should be fixed in upstream.

Copy link
Collaborator

@dlstadther dlstadther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (ignoring codecov stuff - only care about travis build status)

@dlstadther dlstadther merged commit b583a5b into spotify:master Mar 14, 2018
This was referenced Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants