whylogs.api.writer.gcs#

Module Contents#

Classes#

GCSWriter

A whylogs writer to upload DatasetProfileViews onto Google Cloud Storage (GCS).

Attributes#

whylogs.api.writer.gcs.logger#
class whylogs.api.writer.gcs.GCSWriter(gcs_client: Optional[google.cloud.storage.Client] = None, object_name: Optional[str] = None, bucket_name: Optional[str] = None)#

Bases: whylogs.api.writer.Writer

A whylogs writer to upload DatasetProfileViews onto Google Cloud Storage (GCS).

>**IMPORTANT**: In order to correctly connect to your GCS container, make sure you have the following environment variables set: [GOOGLE_APPLICATION_CREDENTIALS]

Parameters
  • "your-bucket-name" (bucket_name =) –

  • "local/path/to/file" (source_file_name =) –

  • "storage-object-name" (destination_blob_name =) –

  • gcs_client (Optional[google.cloud.storage.Client]) –

  • object_name (Optional[str]) –

  • bucket_name (Optional[str]) –

Returns

Return type

None

Examples

An example usage of this method can be represented with the simple code above. Here we are assuming the user has already assigned a pandas.DataFrame to the df variable.

```python import whylogs as why

profile = why.log(pandas=df) profile.writer(“gcs”).option(bucket_name=”my_bucket”).write() ```

write(file: whylogs.api.writer.writer._Writable, dest: Optional[str] = None, **kwargs: Any) Tuple[bool, Union[str, List[Tuple[bool, str]]]]#

Calls Writable::write() to serialize the Wriable file to temporary file(s), then “sends” the temporary file(s) to dest according to the type of Writer. If dest is None, it uses the Writer’s default destination.

kwargs:

zip: bool Create a ZipFile containing the Writable’s file(s) if the Writer supports it zip_name: str Name of the ZipFile, will be auto-generated if None

Parameters
  • file (whylogs.api.writer.writer._Writable) –

  • dest (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, Union[str, List[Tuple[bool, str]]]]

option(**kwargs: Any) whylogs.api.writer.Writer#

bucket_name: str GCS bucket name to write to object_name: str GCS object name to create gcs_client: ? GCS client object

Parameters

kwargs (Any) –

Return type

whylogs.api.writer.Writer

check_interval(interval_seconds: int) None#

Validate an interval configuration for a given writer.

Some writers only accepts certain interval configuration. Raise BadConfigError for an unacceptable interval.

Parameters

interval_seconds (int) –

Return type

None