From 8d927f435318b600dbf68b3a247273c5a49fa864 Mon Sep 17 00:00:00 2001 From: danthelion Date: Tue, 21 Nov 2017 20:44:17 +0100 Subject: [PATCH] Pass kwargs to `discovery.build()` when instantiating `GSCClient`. --- luigi/contrib/gcs.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/luigi/contrib/gcs.py b/luigi/contrib/gcs.py index 203fd4c150..c1e8964e38 100644 --- a/luigi/contrib/gcs.py +++ b/luigi/contrib/gcs.py @@ -108,14 +108,18 @@ class GCSClient(luigi.target.FileSystem): as the ``descriptor`` argument. """ def __init__(self, oauth_credentials=None, descriptor='', http_=None, - chunksize=CHUNKSIZE): + chunksize=CHUNKSIZE, **discovery_build_kwargs): self.chunksize = chunksize authenticate_kwargs = gcp.get_authenticate_kwargs(oauth_credentials, http_) + build_kwargs = authenticate_kwargs.copy() + build_kwargs.update(discovery_build_kwargs) + if descriptor: - self.client = discovery.build_from_document(descriptor, **authenticate_kwargs) + self.client = discovery.build_from_document(descriptor, **build_kwargs) else: - self.client = discovery.build('storage', 'v1', cache_discovery=False, **authenticate_kwargs) + build_kwargs.setdefault('cache_discovery', False) + self.client = discovery.build('storage', 'v1', **build_kwargs) def _path_to_bucket_and_key(self, path): (scheme, netloc, path, _, _) = urlsplit(path)