Metadata-Version: 2.5
Name: mlops_abp
Version: 0.1.2
Summary: Shared MLOps platform tooling: MLflow tracking/registry, quality gate, Great Expectations validation, Evidently drift detection
Author: ABP
License-Expression: MIT
License-File: LICENSE
Keywords: evidently,great-expectations,mlflow,mlops,prefect
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: evidently>=0.4
Requires-Dist: great-expectations>=0.18
Requires-Dist: mlflow<3.0,>=2.14
Requires-Dist: pandas>=2.2
Requires-Dist: prefect>=3.8.5
Requires-Dist: pydantic-settings>=2.3
Description-Content-Type: text/markdown

# mlops

Shared MLOps **platform package** — not a machine learning project of its own. It gives every ML
project the generic building blocks of a training pipeline (data validation, experiment tracking,
quality gates, drift monitoring), so each project imports them instead of re-writing the same
tracking/quality-gate/validation/monitoring logic:

- `mlops.validation.run_expectations(df, rules)` — run Great Expectations rules
- `mlops.mlflow_tracking.log_and_register(...)` / `promote_model_to_production(...)` — MLflow
  experiment tracking and model registry
- `mlops.quality_gate.check_threshold(...)` — stop a pipeline if a metric regressed
- `mlops.monitoring.check_drift(reference_data, current_data)` — Evidently drift detection
- `mlops.git_info.get_current_commit_hash()` — commit hash for run metadata

Everything project-specific (data source, feature engineering, model training, API serving, the
orchestration flow that wires these steps together) stays in each consuming project's own repo —
`mlops` only provides the reusable building blocks above.

## Install

```bash
pip install mlops_abp
# or with uv
uv add mlops_abp
```

The distribution is named `mlops_abp` on PyPI; the importable package is `mlops`:

```python
from mlops import log_and_register, check_threshold, run_expectations, check_drift
```

For local development against a checkout of this repo instead of the published release:

```bash
cd /path/to/your-project
uv add --editable /path/to/mlops
```

## Usage

```python
from mlops import check_threshold, log_and_register, run_expectations

run_expectations(df_train, rules=[
    {"expectation": "expect_column_values_to_not_be_null", "kwargs": {"column": "target"}},
])

run_id = log_and_register(
    model=model,
    run_name="baseline",
    params=params,
    metrics=metrics,
    model_name="your_model_name",
    experiment_name="your_project_experiment",  # distinct per project
)
check_threshold(metrics["accuracy"], threshold=0.85, metric_name="accuracy")
```

Drift monitoring:

```python
from mlops import check_drift

if check_drift(reference_data=baseline_df, current_data=recent_df):
    print("Drift detected — consider retraining")
```

## Shared platform infrastructure (optional, for self-hosting MLflow/Prefect)

```bash
git clone <this-repo>
cd mlops
cp .env.example .env
docker compose up -d   # postgres (MLflow backend store) + mlflow-server + prefect-server
```

- MLflow UI: http://localhost:5000
- Prefect UI: http://localhost:4200

## Development

```bash
uv sync
uv run pytest tests/ -v
uv run ruff check mlops/ tests/
```

## License

MIT — see [LICENSE](LICENSE).
