driftwatch 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. driftwatch-0.2.0/LICENSE +21 -0
  2. driftwatch-0.2.0/PKG-INFO +144 -0
  3. driftwatch-0.2.0/README.md +83 -0
  4. driftwatch-0.2.0/pyproject.toml +211 -0
  5. driftwatch-0.2.0/setup.cfg +4 -0
  6. driftwatch-0.2.0/src/driftwatch/__init__.py +22 -0
  7. driftwatch-0.2.0/src/driftwatch/cli/__init__.py +5 -0
  8. driftwatch-0.2.0/src/driftwatch/cli/main.py +274 -0
  9. driftwatch-0.2.0/src/driftwatch/core/__init__.py +6 -0
  10. driftwatch-0.2.0/src/driftwatch/core/monitor.py +153 -0
  11. driftwatch-0.2.0/src/driftwatch/core/report.py +162 -0
  12. driftwatch-0.2.0/src/driftwatch/detectors/__init__.py +6 -0
  13. driftwatch-0.2.0/src/driftwatch/detectors/base.py +67 -0
  14. driftwatch-0.2.0/src/driftwatch/detectors/categorical.py +145 -0
  15. driftwatch-0.2.0/src/driftwatch/detectors/numerical.py +198 -0
  16. driftwatch-0.2.0/src/driftwatch/detectors/registry.py +71 -0
  17. driftwatch-0.2.0/src/driftwatch/integrations/__init__.py +5 -0
  18. driftwatch-0.2.0/src/driftwatch/integrations/alerting.py +211 -0
  19. driftwatch-0.2.0/src/driftwatch/integrations/fastapi.py +297 -0
  20. driftwatch-0.2.0/src/driftwatch/py.typed +1 -0
  21. driftwatch-0.2.0/src/driftwatch/simulation/__init__.py +1 -0
  22. driftwatch-0.2.0/src/driftwatch.egg-info/PKG-INFO +144 -0
  23. driftwatch-0.2.0/src/driftwatch.egg-info/SOURCES.txt +26 -0
  24. driftwatch-0.2.0/src/driftwatch.egg-info/dependency_links.txt +1 -0
  25. driftwatch-0.2.0/src/driftwatch.egg-info/entry_points.txt +2 -0
  26. driftwatch-0.2.0/src/driftwatch.egg-info/requires.txt +37 -0
  27. driftwatch-0.2.0/src/driftwatch.egg-info/top_level.txt +1 -0
  28. driftwatch-0.2.0/tests/test_slack_alerting.py +226 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DriftWatch Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: driftwatch
3
+ Version: 0.2.0
4
+ Summary: Lightweight ML drift monitoring, built for real-world pipelines
5
+ Author-email: Your Name <your.email@example.com>
6
+ Maintainer-email: Your Name <your.email@example.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/YOUR_USERNAME/driftwatch
9
+ Project-URL: Documentation, https://driftwatch.readthedocs.io
10
+ Project-URL: Repository, https://github.com/YOUR_USERNAME/driftwatch
11
+ Project-URL: Issues, https://github.com/YOUR_USERNAME/driftwatch/issues
12
+ Project-URL: Changelog, https://github.com/YOUR_USERNAME/driftwatch/blob/main/CHANGELOG.md
13
+ Keywords: machine-learning,mlops,drift-detection,monitoring,data-quality,model-monitoring
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy>=1.21.0
31
+ Requires-Dist: pandas>=1.3.0
32
+ Requires-Dist: scipy>=1.7.0
33
+ Requires-Dist: pydantic>=2.0.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
38
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
39
+ Requires-Dist: black>=23.0.0; extra == "dev"
40
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
41
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
42
+ Requires-Dist: pandas-stubs>=2.0.0; extra == "dev"
43
+ Provides-Extra: cli
44
+ Requires-Dist: typer>=0.9.0; extra == "cli"
45
+ Requires-Dist: rich>=13.0.0; extra == "cli"
46
+ Provides-Extra: fastapi
47
+ Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
48
+ Requires-Dist: uvicorn>=0.23.0; extra == "fastapi"
49
+ Provides-Extra: mlflow
50
+ Requires-Dist: mlflow>=2.0.0; extra == "mlflow"
51
+ Provides-Extra: alerting
52
+ Requires-Dist: httpx>=0.24.0; extra == "alerting"
53
+ Requires-Dist: aiosmtplib>=2.0.0; extra == "alerting"
54
+ Provides-Extra: all
55
+ Requires-Dist: driftwatch[alerting,cli,fastapi,mlflow]; extra == "all"
56
+ Provides-Extra: docs
57
+ Requires-Dist: mkdocs>=1.5.0; extra == "docs"
58
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
59
+ Requires-Dist: mkdocstrings[python]>=0.23.0; extra == "docs"
60
+ Dynamic: license-file
61
+
62
+ # DriftWatch
63
+
64
+ <div align="center">
65
+
66
+ **Lightweight ML drift monitoring, built for real-world pipelines**
67
+
68
+ [![Documentation](https://img.shields.io/badge/docs-vincentcotella.github.io%2FDriftWatch-blue.svg)](https://vincentcotella.github.io/DriftWatch/)
69
+ [![CI](https://github.com/VincentCotella/DriftWatch/actions/workflows/ci.yml/badge.svg)](https://github.com/VincentCotella/DriftWatch/actions/workflows/ci.yml)
70
+ [![PyPI version](https://badge.fury.io/py/driftwatch.svg)](https://pypi.org/project/driftwatch/)
71
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
72
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
73
+
74
+ </div>
75
+
76
+ ---
77
+
78
+ ## 📖 Documentation
79
+
80
+ **Read the full documentation here:** [vincentcotella.github.io/DriftWatch](https://vincentcotella.github.io/DriftWatch/)
81
+
82
+ ## 🚀 Features
83
+
84
+ - **Simple API**: Detect drift in 3 lines of code.
85
+ - **Multiple Detectors**: **PSI**, **KS-Test**, **Wasserstein Distance**, **Chi-Squared**.
86
+ - **Production-Ready**:
87
+ - ⚡ **FastAPI Integration** (Middleware included).
88
+ - 🔔 **Slack Alerts** built-in.
89
+ - 🛠️ **CLI** for batch processing.
90
+ - **Lightweight**: Minimal dependencies (`numpy`, `pandas`, `scipy`).
91
+ - **Type-Safe**: 100% typed code with `mypy` support.
92
+
93
+ ## 📦 Installation
94
+
95
+ ```bash
96
+ pip install driftwatch
97
+ ```
98
+
99
+ For extras (CLI, FastAPI, Alerting):
100
+ ```bash
101
+ pip install driftwatch[all]
102
+ ```
103
+
104
+ ## ⚡ Quick Start
105
+
106
+ ```python
107
+ from driftwatch import Monitor
108
+ import pandas as pd
109
+
110
+ # 1. Initialize monitor with reference data (e.g., training set)
111
+ monitor = Monitor(reference_data=pd.read_parquet("train.parquet"))
112
+
113
+ # 2. Check production data for drift
114
+ report = monitor.check(pd.read_parquet("production.parquet"))
115
+
116
+ # 3. Act on results
117
+ if report.has_drift():
118
+ print(f"⚠️ Drift detected! Ratio: {report.drift_ratio():.1%}")
119
+ print(f"Drifted features: {report.drifted_features()}")
120
+ else:
121
+ print("✅ All systems normal.")
122
+ ```
123
+
124
+ ## 🛠️ Usage Scenarios
125
+
126
+ | Scenario | Solution |
127
+ |----------|----------|
128
+ | **Real-time API** | Use `DriftMiddleware` in FastAPI to monitor every request. |
129
+ | **Batch Job** | Use `driftwatch check` CLI in your Airflow/Cron jobs. |
130
+ | **CI/CD** | Block deployments if validation data drifts from training data. |
131
+ | **Alerting** | Send Slack notifications automatically when drift is critical. |
132
+
133
+ ## 🤝 Contributing
134
+
135
+ We welcome contributions! Please see our [Contributing Guide](https://vincentcotella.github.io/DriftWatch/contributing/) for details.
136
+
137
+ 1. Fork the repo.
138
+ 2. Install dev dependencies: `pip install -e ".[dev,all]"`
139
+ 3. Run tests: `pytest`
140
+ 4. Submit a PR!
141
+
142
+ ## 📄 License
143
+
144
+ MIT © [Vincent Cotella](https://github.com/VincentCotella)
@@ -0,0 +1,83 @@
1
+ # DriftWatch
2
+
3
+ <div align="center">
4
+
5
+ **Lightweight ML drift monitoring, built for real-world pipelines**
6
+
7
+ [![Documentation](https://img.shields.io/badge/docs-vincentcotella.github.io%2FDriftWatch-blue.svg)](https://vincentcotella.github.io/DriftWatch/)
8
+ [![CI](https://github.com/VincentCotella/DriftWatch/actions/workflows/ci.yml/badge.svg)](https://github.com/VincentCotella/DriftWatch/actions/workflows/ci.yml)
9
+ [![PyPI version](https://badge.fury.io/py/driftwatch.svg)](https://pypi.org/project/driftwatch/)
10
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## 📖 Documentation
18
+
19
+ **Read the full documentation here:** [vincentcotella.github.io/DriftWatch](https://vincentcotella.github.io/DriftWatch/)
20
+
21
+ ## 🚀 Features
22
+
23
+ - **Simple API**: Detect drift in 3 lines of code.
24
+ - **Multiple Detectors**: **PSI**, **KS-Test**, **Wasserstein Distance**, **Chi-Squared**.
25
+ - **Production-Ready**:
26
+ - ⚡ **FastAPI Integration** (Middleware included).
27
+ - 🔔 **Slack Alerts** built-in.
28
+ - 🛠️ **CLI** for batch processing.
29
+ - **Lightweight**: Minimal dependencies (`numpy`, `pandas`, `scipy`).
30
+ - **Type-Safe**: 100% typed code with `mypy` support.
31
+
32
+ ## 📦 Installation
33
+
34
+ ```bash
35
+ pip install driftwatch
36
+ ```
37
+
38
+ For extras (CLI, FastAPI, Alerting):
39
+ ```bash
40
+ pip install driftwatch[all]
41
+ ```
42
+
43
+ ## ⚡ Quick Start
44
+
45
+ ```python
46
+ from driftwatch import Monitor
47
+ import pandas as pd
48
+
49
+ # 1. Initialize monitor with reference data (e.g., training set)
50
+ monitor = Monitor(reference_data=pd.read_parquet("train.parquet"))
51
+
52
+ # 2. Check production data for drift
53
+ report = monitor.check(pd.read_parquet("production.parquet"))
54
+
55
+ # 3. Act on results
56
+ if report.has_drift():
57
+ print(f"⚠️ Drift detected! Ratio: {report.drift_ratio():.1%}")
58
+ print(f"Drifted features: {report.drifted_features()}")
59
+ else:
60
+ print("✅ All systems normal.")
61
+ ```
62
+
63
+ ## 🛠️ Usage Scenarios
64
+
65
+ | Scenario | Solution |
66
+ |----------|----------|
67
+ | **Real-time API** | Use `DriftMiddleware` in FastAPI to monitor every request. |
68
+ | **Batch Job** | Use `driftwatch check` CLI in your Airflow/Cron jobs. |
69
+ | **CI/CD** | Block deployments if validation data drifts from training data. |
70
+ | **Alerting** | Send Slack notifications automatically when drift is critical. |
71
+
72
+ ## 🤝 Contributing
73
+
74
+ We welcome contributions! Please see our [Contributing Guide](https://vincentcotella.github.io/DriftWatch/contributing/) for details.
75
+
76
+ 1. Fork the repo.
77
+ 2. Install dev dependencies: `pip install -e ".[dev,all]"`
78
+ 3. Run tests: `pytest`
79
+ 4. Submit a PR!
80
+
81
+ ## 📄 License
82
+
83
+ MIT © [Vincent Cotella](https://github.com/VincentCotella)
@@ -0,0 +1,211 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "driftwatch"
7
+ version = "0.2.0"
8
+ description = "Lightweight ML drift monitoring, built for real-world pipelines"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ authors = [
12
+ {name = "Your Name", email = "your.email@example.com"}
13
+ ]
14
+ maintainers = [
15
+ {name = "Your Name", email = "your.email@example.com"}
16
+ ]
17
+ keywords = [
18
+ "machine-learning",
19
+ "mlops",
20
+ "drift-detection",
21
+ "monitoring",
22
+ "data-quality",
23
+ "model-monitoring"
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Developers",
28
+ "Intended Audience :: Science/Research",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ "Typing :: Typed",
39
+ ]
40
+ requires-python = ">=3.9"
41
+ dependencies = [
42
+ "numpy>=1.21.0",
43
+ "pandas>=1.3.0",
44
+ "scipy>=1.7.0",
45
+ "pydantic>=2.0.0",
46
+ ]
47
+
48
+ [project.optional-dependencies]
49
+ dev = [
50
+ "pytest>=7.0.0",
51
+ "pytest-cov>=4.0.0",
52
+ "pytest-asyncio>=0.21.0",
53
+ "ruff>=0.1.0",
54
+ "black>=23.0.0",
55
+ "mypy>=1.0.0",
56
+ "pre-commit>=3.0.0",
57
+ "pandas-stubs>=2.0.0",
58
+ ]
59
+ cli = [
60
+ "typer>=0.9.0",
61
+ "rich>=13.0.0",
62
+ ]
63
+ fastapi = [
64
+ "fastapi>=0.100.0",
65
+ "uvicorn>=0.23.0",
66
+ ]
67
+ mlflow = [
68
+ "mlflow>=2.0.0",
69
+ ]
70
+ alerting = [
71
+ "httpx>=0.24.0",
72
+ "aiosmtplib>=2.0.0",
73
+ ]
74
+ all = [
75
+ "driftwatch[cli,fastapi,mlflow,alerting]",
76
+ ]
77
+ docs = [
78
+ "mkdocs>=1.5.0",
79
+ "mkdocs-material>=9.0.0",
80
+ "mkdocstrings[python]>=0.23.0",
81
+ ]
82
+
83
+ [project.scripts]
84
+ driftwatch = "driftwatch.cli.main:app"
85
+
86
+ [project.urls]
87
+ Homepage = "https://github.com/YOUR_USERNAME/driftwatch"
88
+ Documentation = "https://driftwatch.readthedocs.io"
89
+ Repository = "https://github.com/YOUR_USERNAME/driftwatch"
90
+ Issues = "https://github.com/YOUR_USERNAME/driftwatch/issues"
91
+ Changelog = "https://github.com/YOUR_USERNAME/driftwatch/blob/main/CHANGELOG.md"
92
+
93
+ [tool.setuptools.packages.find]
94
+ where = ["src"]
95
+
96
+ [tool.setuptools.package-data]
97
+ driftwatch = ["py.typed"]
98
+
99
+ # ============================================================================
100
+ # RUFF CONFIGURATION
101
+ # ============================================================================
102
+ [tool.ruff]
103
+ target-version = "py39"
104
+ line-length = 88
105
+ src = ["src", "tests"]
106
+
107
+ [tool.ruff.lint]
108
+ select = [
109
+ "E", # pycodestyle errors
110
+ "W", # pycodestyle warnings
111
+ "F", # pyflakes
112
+ "I", # isort
113
+ "B", # flake8-bugbear
114
+ "C4", # flake8-comprehensions
115
+ "UP", # pyupgrade
116
+ "ARG", # flake8-unused-arguments
117
+ "SIM", # flake8-simplify
118
+ "TCH", # flake8-type-checking
119
+ "PTH", # flake8-use-pathlib
120
+ "RUF", # Ruff-specific rules
121
+ ]
122
+ ignore = [
123
+ "E501", # line too long (handled by formatter)
124
+ "B008", # do not perform function calls in argument defaults
125
+ "B905", # zip without explicit strict
126
+ ]
127
+
128
+ [tool.ruff.lint.isort]
129
+ known-first-party = ["driftwatch"]
130
+
131
+ # ============================================================================
132
+ # BLACK CONFIGURATION
133
+ # ============================================================================
134
+ [tool.black]
135
+ line-length = 88
136
+ target-version = ['py39', 'py310', 'py311', 'py312']
137
+ include = '\.pyi?$'
138
+
139
+ # ============================================================================
140
+ # MYPY CONFIGURATION
141
+ # ============================================================================
142
+ [tool.mypy]
143
+ python_version = "3.9"
144
+ mypy_path = "src"
145
+ warn_return_any = true
146
+ warn_unused_configs = true
147
+ disallow_untyped_defs = true
148
+ disallow_incomplete_defs = true
149
+ check_untyped_defs = true
150
+ strict_optional = true
151
+ warn_redundant_casts = true
152
+ warn_unused_ignores = true
153
+ show_error_codes = true
154
+ namespace_packages = true
155
+ explicit_package_bases = true
156
+
157
+ [[tool.mypy.overrides]]
158
+ module = [
159
+ "scipy.*",
160
+ "mlflow.*",
161
+ "starlette.*",
162
+ "fastapi.*",
163
+ "pandas.*",
164
+ "numpy.*",
165
+ "typer.*",
166
+ "rich.*",
167
+ "httpx.*",
168
+ ]
169
+ ignore_missing_imports = true
170
+
171
+ # ============================================================================
172
+ # PYTEST CONFIGURATION
173
+ # ============================================================================
174
+ [tool.pytest.ini_options]
175
+ testpaths = ["tests"]
176
+ python_files = ["test_*.py"]
177
+ python_functions = ["test_*"]
178
+ addopts = [
179
+ "-v",
180
+ "--tb=short",
181
+ "--strict-markers",
182
+ "-ra",
183
+ ]
184
+ markers = [
185
+ "slow: marks tests as slow",
186
+ "integration: marks tests as integration tests",
187
+ ]
188
+
189
+ # ============================================================================
190
+ # COVERAGE CONFIGURATION
191
+ # ============================================================================
192
+ [tool.coverage.run]
193
+ source = ["src/driftwatch"]
194
+ branch = true
195
+ omit = [
196
+ "*/tests/*",
197
+ "*/__init__.py",
198
+ "*/integrations/*", # Optional integrations require external deps
199
+ "*/cli/*", # Optional CLI interface
200
+ ]
201
+
202
+ [tool.coverage.report]
203
+ exclude_lines = [
204
+ "pragma: no cover",
205
+ "def __repr__",
206
+ "raise NotImplementedError",
207
+ "if TYPE_CHECKING:",
208
+ "if __name__ == .__main__.:",
209
+ ]
210
+ fail_under = 80
211
+ show_missing = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ """
2
+ DriftWatch - Lightweight ML drift monitoring, built for real-world pipelines.
3
+
4
+ DriftWatch is an open-source Python library for detecting data drift and
5
+ model drift in machine learning systems.
6
+
7
+ Basic Usage:
8
+ >>> from driftwatch import Monitor
9
+ >>> monitor = Monitor(reference_data=train_df, features=["age", "income"])
10
+ >>> report = monitor.check(production_df)
11
+ >>> print(report.summary())
12
+ """
13
+
14
+ from driftwatch.core.monitor import Monitor
15
+ from driftwatch.core.report import DriftReport
16
+
17
+ __version__ = "0.2.0"
18
+ __all__ = [
19
+ "DriftReport",
20
+ "Monitor",
21
+ "__version__",
22
+ ]
@@ -0,0 +1,5 @@
1
+ """Command-line interface for DriftWatch."""
2
+
3
+ from driftwatch.cli.main import app
4
+
5
+ __all__ = ["app"]