Skip to main content

No project description provided

Project description

Aporia Python SDK

Aporia's Python SDK is a powerful tool designed to streamline ML monitoring and observability.

Define your models, monitors, dashboards, segments, custom metrics, and other ML Observability resources as code, just like in Terraform or Pulumi. The SDK also enables you to query metrics from Aporia to integrate with other platforms.

Key Features

  • ML Monitoring as Code: Make it easier to manage and track changes by managing your models, dashboards, segments, and other ML Observability resources as code.
  • CI/CD Integration: Integrate with your CI/CD pipeline to automatically monitor all your models with Aporia.
  • Query Metrics: Fetch metrics directly from Aporia's platform to inform decisions or to use in other applications.
  • Data Source Integration: You can define and integrate multiple types of data sources, like S3, Snowflake, Glue Data Catalog, Databricks, and others. This allows your models to leverage a wide range of data for training and inference.
  • Pythonic Interface: Use the familiar Python programming paradigm to interact with Aporia.

Installation

You can install the Aporia SDK using pip:

pip install aporia

Quickstart

Define models as code

import datetime
import os

from aporia import Aporia, MetricDataset, MetricParameters, TimeRange
import aporia.as_code as aporia

aporia_token = os.environ["APORIA_TOKEN"]
aporia_account = os.environ["APORIA_ACCOUNT"]
aporia_workspace = os.environ["APORIA_WORKSPACE"]

stack = aporia.Stack(
    token=aporia_token,
    account=aporia_account,
    workspace=aporia_workspace,
)

# Your model definition code goes here

stack.apply(yes=True, rollback=False, config_path="config.json")

Query Metrics using the SDK

This example shows how you can use the Aporia SDK to query metrics from a model:

from datetime import datetime
from aporia import (
    Aporia,
    MetricDataset,
    MetricParameters,
    TimeRange,
    DatasetType,
)

aporia_token = os.environ["APORIA_TOKEN"]
aporia_account = os.environ["APORIA_ACCOUNT"]
aporia_workspace = os.environ["APORIA_WORKSPACE"]

aporia_client = Aporia(
    token=aporia_token,
    account_name=aporia_account,
    workspace_name=aporia_workspace,
)

last_week_dataset = MetricDataset(
    dataset_type=DatasetType.SERVING,
    time_range=TimeRange(
        start=datetime.now() - datetime.timedelta(days=7),
        end=datetime.now(),
    ),
)

metrics = aporia_client.query_metrics(
    model_id=model_id,
    metrics=[
        MetricParameters(
            dataset=MetricDataset(dataset_type=DatasetType.SERVING),
            name="count",
        ),
    ],
)

print(f"The model had {metrics[0]} predictions last week")

Refer to the official Aporia documentation for detailed information on how to use the SDK.

Development

This package uses Poetry for dependency management. To install dependencies, use:

poetry install

Project details


Release history Release notifications | RSS feed

This version

3.4.0

Download files

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

Source Distribution

aporia-3.4.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

aporia-3.4.0-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file aporia-3.4.0.tar.gz.

File metadata

  • Download URL: aporia-3.4.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for aporia-3.4.0.tar.gz
Algorithm Hash digest
SHA256 c91338cc439eecba6917e3d4f555fd1fa33ecabd3ef720c0523141d356d0bdb8
MD5 8c67e9aec762ae5f580859aa95ea7440
BLAKE2b-256 71372fa5ab425dbdd474c5f6c78e7a9c1f3489f332a5a854f817cd5445e4a25e

See more details on using hashes here.

File details

Details for the file aporia-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: aporia-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for aporia-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbc89b116ae77e7e7b6e165a6163c2d1716868f4e41d75048026968ae911758b
MD5 46d0d4514cbb54713ff89484366e8a90
BLAKE2b-256 341a4b0f1a963be16d4203a93852ed52d8cf130301b315899ff8ebdd8e0673e3

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