class gretel_client.files.interface.File(*, id: str, object: str, bytes: int, created_at: int, filename: str, purpose: str)

Represents a file that has been uploaded/interacted with in the Gretel ecosystem.

bytes: int

The size of the file in bytes.

created_at: int

The timestamp when the file was created.

filename: str

The name of the file.

id: str

The unique identifier for this file.

object: str

type which is always ‘file’

purpose: str

The purpose of the file. (i.e. dataset, pydantic model, etc.)

class gretel_client.files.interface.FileClient(session: ClientConfig | None = None, api_endpoint: str | None = None)

A client for interacting with files in the Gretel ecosystem.

Provides methods for uploading, deleting files.

delete(file_id: str) None

Delete a file from Gretel.

Parameters:

file_id – The unique identifier of the file to delete from the File object

download_dataset(file_id: str) DataFrame

Download a dataset object into memory as a DataFrame.

Assumes that the dataset file is stored in Parquet format. An exception will be raised if the downloaded octet-stream cannot be loaded as a parquet file.

Parameters:

file_id – The unique identifier of the file to download.

Raises:

ValueError – If returned octet-stream cannot be loaded as a parquet file.

get(file_id: str) File

Get a file from Gretel.

Parameters:

file_id – The unique identifier of the file to retrieve from the File object

Returns:

The File object

Return type:

File

upload(file: IO[bytes] | BinaryIO | DataFrame | Path | str, purpose: str) File

Uploads a file to Gretel.

Parameters:
  • file – The file to upload. This can be a file-like object, a pandas DataFrame, or a path to a file.

  • purpose – The purpose of the file. (i.e. dataset, pydantic model, etc.)

Returns:

The uploaded File object containing metadata.

Return type:

File