Skip to content

Commit 619bcc9

Browse files
mcollins42tseaver
authored andcommitted
enhancement(automl): add support for passing project to 'GcsClient' (googleapis#9299)
1 parent abd022f commit 619bcc9

File tree

4 files changed

+358
-258
lines changed

4 files changed

+358
-258
lines changed

automl/google/cloud/automl_v1beta1/tables/gcs_client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class GcsClient(object):
4242
"""Uploads Pandas DataFrame to a bucket in Google Cloud Storage."""
4343

44-
def __init__(self, bucket_name=None, client=None, credentials=None):
44+
def __init__(self, bucket_name=None, client=None, credentials=None, project=None):
4545
"""Constructor.
4646
4747
Args:
@@ -54,14 +54,18 @@ def __init__(self, bucket_name=None, client=None, credentials=None):
5454
credentials identify this application to the service. If none
5555
are specified, the client will attempt to ascertain the
5656
credentials from the environment.
57+
project (Optional[str]): The project ID of the GCP project to
58+
attach to the underlying storage client. If none is specified,
59+
the client will attempt to ascertain the credentials from the
60+
environment.
5761
"""
5862
if storage is None:
5963
raise ImportError(_STORAGE_REQUIRED)
6064

6165
if client is not None:
6266
self.client = client
6367
elif credentials is not None:
64-
self.client = storage.Client(credentials=credentials)
68+
self.client = storage.Client(credentials=credentials, project=project)
6569
else:
6670
self.client = storage.Client()
6771

@@ -79,7 +83,7 @@ def ensure_bucket_exists(self, project, region):
7983
Save the created bucket's name and reuse this for future requests.
8084
8185
Args:
82-
project (str): The project that stores the bucket.
86+
project (str): The ID of the project that stores the bucket.
8387
region (str): The region of the bucket.
8488
8589
Returns:

0 commit comments

Comments
 (0)