Skip to main content

Python client for creating new Zeno projects and uploading data.

Project description

Zeno Python Client

The Zeno Python client lets you create and manage Zeno projects from Python.

Example

A Zeno project has a base dataset and any number of systems (AI models) to evaluate on a dataset. The following example shows how to upload a dataset and a system to a Zeno project.

from zeno_client import ZenoClient
import pandas as pd

# Create a Zeno client with your API key
client = ZenoClient("YOUR_API_KEY")

# Create a project with a specific data renderer, e.g. "text-classification" or "image-classification"
# See view options at https://zenoml.com/docs/views/
project = zeno_client.create_project(
    "test project", 
    view="text-classification",
    metrics=[ZenoMetric(name="accuracy", type="mean", columns=["correct"])]
)
# Upload a simple dataset
# You need to provide at least an id column.
# Your dataframe can contain additional metadata which will be usable in Zeno.
df = pd.DataFrame({
    "id": [1, 2, 3],
    "text": ["Zeno", "of", "Elea"],
    "label": ["A", "B", "B"]
})
project.upload_dataset(df, id_column="id", label_column="label", data_column="text")

# Upload a system to the project
# ... run inference on your model ...
df_out = pd.DataFrame({"id": [1, 2, 3], "output": ["A", "B", "A"]})
df_out['correct'] = df_out['output'] == df['label']
project.upload_system("System A", df_out, output_column="output", id_column="id")

See the examples directory for more in-depth examples.

API Documentation

Documentation generated with pydoc-markdown.

pydoc-markdown -I zeno_client -m client --render-toc > docs.md

Table of Contents

client

Functions to upload data to Zeno's backend.

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.
  • columns list[str] - The columns to calculate the metric on.

ZenoProject Objects

class ZenoProject()

Provides data upload functionality for a Zeno project.

Attributes:

  • api_key str - The API key to authenticate uploads with.
  • project_uuid str - The ID of the project to add data to.
  • endpoint str - The base URL of the Zeno backend.

__init__

def __init__(api_key: str, project_uuid: str, endpoint: str = DEFAULT_BACKEND)

Initialize the Project object for API upload calls.

Arguments:

  • api_key str - the API key to authenticate uploads with.
  • project_uuid str - the ID of the project to add data to.
  • endpoint str, optional - the base URL of the Zeno backend.

upload_dataset

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

Upload a dataset to a Zeno project.

Arguments:

  • df pd.DataFrame - The dataset to upload.
  • id_column str - The name of the column containing the instance IDs.
  • label_column str | None, optional - The name of the column containing the instance labels. Defaults to None.
  • data_column str | None, optional - The name of the column containing the raw data. Only works for small text data. Defaults to None.

upload_system

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

Upload a system to a Zeno project.

Arguments:

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

ZenoClient Objects

class ZenoClient()

Client class for data upload functionality to Zeno.

Attributes:

  • api_key str - The API key to authenticate uploads with.
  • endpoint str - The base URL of the Zeno backend.

__init__

def __init__(api_key, endpoint=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: str,
                   metrics: List[ZenoMetric] = [],
                   data_url: str = "",
                   calculate_histogram_metrics: bool = True,
                   samples_per_page: int = 10,
                   public: bool = True) -> 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.
  • project - str,
  • view str - The view to use for the project.
  • metrics list[ZenoMetric], optional - The metrics to calculate for the project. Defaults to [].
  • data_url str, optional - The URL to the data to use for the project. Defaults to "".
  • calculate_histogram_metrics bool, optional - Whether to calculate histogram metrics. Defaults to True.
  • 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.
  • HTTPError - If the project could not be created.

get_project

def get_project(project_name: str) -> ZenoProject

Get a project object by its name. Names are split into owner/project_name.

Arguments:

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

Returns:

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

Raises:

  • HTTPError - If the project could not be found.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeno_client-0.1.7.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

zeno_client-0.1.7-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file zeno_client-0.1.7.tar.gz.

File metadata

  • Download URL: zeno_client-0.1.7.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1011-azure

File hashes

Hashes for zeno_client-0.1.7.tar.gz
Algorithm Hash digest
SHA256 124126b267bd9c38790d23b713feeebc4e5d8e3fec1784dc94da96fcbaafac73
MD5 df000de2def535d28b0d33254c710377
BLAKE2b-256 e71ba097df025b9147df95a85811dec71bd7c418643114fe9193259ef80d8a4c

See more details on using hashes here.

File details

Details for the file zeno_client-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: zeno_client-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1011-azure

File hashes

Hashes for zeno_client-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8418913b6b556af71a8553b32a5853c243ad25d28482ca9620f64494eb2fa422
MD5 4c37c77913c9830d49ad76fc77497bc8
BLAKE2b-256 398bdb7a400af5811e672a33dd0c5c3d604b9471e2fd90fb0078dd7f1e563267

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page