Skip to main content

Python Client API

The Python client is used to create projects and upload data.

pip install zeno-client

Please see Creating a Project to learn how to use the client.

ZenoMetric Objects

class ZenoMetric(BaseModel)

A metric to calculate for a Zeno project.

Attributes:

  • id int - The ID of the metric. -1 if not set.
  • name str - The name of the metric.
  • type str - The type of metric to calculate. Currently only "mean".
  • columns list[str] - The columns to calculate the metric on. Empty list if not set.

ZenoProject Objects

class ZenoProject()

Provides data upload functionality for a Zeno project.

Should NOT be initialized directly, but rather through the ZenoClient.

upload_dataset

def upload_dataset(df: pd.DataFrame,
*,
id_column: str,
data_column: Optional[str] = None,
label_column: Optional[str] = None)

Upload a dataset to a Zeno project.

Arguments:

  • df pd.DataFrame - The dataset to upload as a Pandas DataFrame.
  • id_column str - Column name containing unique instance IDs.
  • data_column str | None, optional - Column containing the instance data. This can be raw data for data types such as text, or URLs for large media data such as images and videos. Defaults to None.
  • label_column str | None, optional - Column containing the instance labels. Defaults to None.

upload_system

def upload_system(df: pd.DataFrame, *, name: str, id_column: str,
output_column: str)

Upload a system to a Zeno project.

Arguments:

  • df pd.DataFrame - The dataset to upload.
  • name str - The name of the system to upload.
  • id_column str - The name of the column containing the instance IDs.
  • output_column str - The name of the column containing the system output.

delete_system

def delete_system(name: str)

Delete a system from a Zeno project.

Arguments:

  • name str - The name of the system to delete.

delete_all_systems

def delete_all_systems()

Delete all systems from a Zeno project.

ZenoClient Objects

class ZenoClient()

Client class for data upload functionality to Zeno.

__init__

def __init__(api_key: str, *, endpoint: str = DEFAULT_BACKEND) -> None

Initialize the ZenoClient object for API upload calls.

Arguments:

  • api_key str - the API key to authenticate uploads with.
  • endpoint str, optional - the base URL of the Zeno backend. Defaults to DEFAULT_BACKEND.

create_project

def create_project(*,
name: str,
view: Union[str, Dict] = "",
description: str = "",
metrics: List[ZenoMetric] = [],
samples_per_page: int = 10,
public: bool = False) -> ZenoProject

Creates an empty project in Zeno's backend.

Arguments:

  • name str - The name of the project to be created. The project will be created under the current user, e.g. username/name.
  • view Union[str, Dict], optional - The view to use for the project. Defaults to "".
  • description str, optional - The description of the project. Defaults to "".
  • metrics list[ZenoMetric], optional - The metrics to calculate for the project. Defaults to [].
  • samples_per_page int, optional - The number of samples to show per page. Defaults to 10.
  • public bool, optional - Whether the project is public. Defaults to False.

Returns:

ZenoProject | None: The created project object or None if the project could not be created.

Raises:

  • ValidationError - If the config does not match the ProjectConfig schema.
  • APIError - If the project could not be created.

get_project

def get_project(owner_name: str, project_name: str) -> ZenoProject

Get a project object by its owner and name.

Arguments:

  • owner_name str - The owner of the project to get.
  • project_name str - The name of the project to get.

Returns:

Project | None: The project object or None if the project could not be found.

Raises:

  • APIError - If the project could not be found.