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:
idint - The ID of the metric. -1 if not set.namestr - The name of the metric.typestr - The type of metric to calculate. Currently only "mean".columnslist[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:
dfpd.DataFrame - The dataset to upload as a Pandas DataFrame.id_columnstr - Column name containing unique instance IDs.data_columnstr | 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_columnstr | 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:
dfpd.DataFrame - The dataset to upload.namestr - The name of the system to upload.id_columnstr - The name of the column containing the instance IDs.output_columnstr - The name of the column containing the system output.
delete_system
def delete_system(name: str)
Delete a system from a Zeno project.
Arguments:
namestr - 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_keystr - the API key to authenticate uploads with.endpointstr, 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:
namestr - The name of the project to be created. The project will be created under the current user, e.g. username/name.viewUnion[str, Dict], optional - The view to use for the project. Defaults to "".descriptionstr, optional - The description of the project. Defaults to "".metricslist[ZenoMetric], optional - The metrics to calculate for the project. Defaults to [].samples_per_pageint, optional - The number of samples to show per page. Defaults to 10.publicbool, 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_namestr - The owner of the project to get.project_namestr - 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.