Class GcsClient (2.10.0)

GcsClient(bucket_name=None, client=None, credentials=None, project=None)

Uploads Pandas DataFrame to a bucket in Google Cloud Storage.

Methods

GcsClient

GcsClient(bucket_name=None, client=None, credentials=None, project=None)

Constructor.

Parameters
NameDescription
bucket_name Optional[str]

The name of Google Cloud Storage bucket for this client to send requests to.

client Optional[storage.Client]

A Google Cloud Storage Client instance.

credentials Optional[google.auth.credentials.Credentials]

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment.

project Optional[str]

The project ID of the GCP project to attach to the underlying storage client. If none is specified, the client will attempt to ascertain the credentials from the environment.

ensure_bucket_exists

ensure_bucket_exists(project, region)

Checks if a bucket named '{project}-automl-tables-staging' exists.

If this bucket doesn't exist, creates one. If this bucket already exists in project, do nothing. If this bucket exists in a different project that we don't have access to, creates a bucket named '{project}-automl-tables-staging-{create_timestamp}' because bucket's name must be globally unique. Save the created bucket's name and reuse this for future requests.

Parameters
NameDescription
project str

The ID of the project that stores the bucket.

region str

The region of the bucket.

upload_pandas_dataframe

upload_pandas_dataframe(dataframe, uploaded_csv_name=None)

Uploads a Pandas DataFrame as CSV to the bucket.

Parameters
NameDescription
dataframe pandas.DataFrame

The Pandas Dataframe to be uploaded.

uploaded_csv_name Optional[str]

The name for the uploaded CSV.