Metadata-Version: 2.4
Name: stayready
Version: 0.2.0
Summary: Push drift events and audit entries from your MLOps pipeline to Compass StayReady.
Project-URL: Homepage, https://stayready.dendrons.ai
Project-URL: Repository, https://github.com/dendrons-ai/compass
Author-email: "Dendrons.ai" <np@dendrons.ai>
License: MIT
Keywords: ai,compass,drift,governance,mlops,monitoring,stayready
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# StayReady Python SDK

Push drift events and audit entries from your MLOps pipeline to [Compass StayReady](https://stayready.dendrons.ai) — continuous AI governance monitoring for regulated sectors.

## Install

```bash
pip install stayready
```

## Quick start

```python
import os
from stayready import StayReady

sr = StayReady(
    api_key=os.environ["STAYREADY_API_KEY"],
    model_id="your-model-uuid",  # from your StayReady dashboard
)

# Report drift when your monitoring detects it — StayReady computes severity
# itself from value/threshold/direction and this metric's own history; you
# don't set it.
sr.drift(
    type="data_drift",              # data_drift | concept_drift | performance_degradation | regulatory_change
    metric="PSI",
    value=0.28,
    threshold=0.20,
    description="Population Stability Index exceeded threshold on income feature.",
    affected_domains=["Data Quality", "Model Monitoring"],
    action_required="Retrain on recent data and re-validate before next production cycle.",
)

# Log lifecycle events to the immutable audit trail
sr.audit("model_retrained", "Retrained on Q2 data, Gini improved to 0.61", actor="ml-pipeline")
```

Severity is computed server-side by comparing `value` against `threshold` and
this model+metric's own trailing baseline — not something you set. Critical
and High results trigger an email alert (and webhook, if configured), deduped
so repeated near-identical events don't re-notify, and can flag your linked
GovernReady audit for re-assessment.

Most metrics are "higher is worse" (PSI, KS, error rate) — the default. If a
*drop* is what's bad for your metric (Gini, accuracy, F1), pass
`direction="lower_is_worse"` on the **first** call you ever make for that
model+metric; it registers the metric's polarity and is ignored on later
calls, so you can't accidentally flip it mid-stream.

## Integration examples

**Evidently AI**

```python
psi = report.as_dict()["metrics"][0]["result"]["dataset_drift_share"]
sr.drift(type="data_drift", metric="PSI", value=psi,
         threshold=0.2, description="Evidently reported this drift share.")
```

**Airflow (post-training validation)**

```python
def report_validation(**ctx):
    gini = ctx["ti"].xcom_pull(key="gini")
    sr.drift(type="performance_degradation", metric="Gini", value=gini,
             threshold=0.55, direction="lower_is_worse",
             description="Gini after retrain.")
```

## Requirements

Python 3.9+. Zero dependencies (standard library only).

## Support

np@dendrons.ai · [stayready.dendrons.ai](https://stayready.dendrons.ai)
