universal-data-cleaner 2.5.2__tar.gz → 2.7.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.
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/PKG-INFO +8 -1
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/README.md +7 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/pyproject.toml +4 -1
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/__init__.py +6 -0
- universal_data_cleaner-2.7.0/src/data_cleaner/__main__.py +148 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/_version.py +1 -1
- universal_data_cleaner-2.7.0/src/data_cleaner/ingestion.py +712 -0
- universal_data_cleaner-2.7.0/src/data_cleaner/reporting.py +615 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/universal_data_cleaner.egg-info/PKG-INFO +8 -1
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/universal_data_cleaner.egg-info/SOURCES.txt +6 -0
- universal_data_cleaner-2.7.0/src/universal_data_cleaner.egg-info/entry_points.txt +2 -0
- universal_data_cleaner-2.7.0/tests/test_ingestion.py +246 -0
- universal_data_cleaner-2.7.0/tests/test_reporting.py +319 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/LICENSE +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/setup.cfg +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/_roles.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/artifacts.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/cleaner.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/config.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/contract.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/decisions.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/integration.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/ml_audit.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/profiling.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/py.typed +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/data_cleaner/validation.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/universal_data_cleaner.egg-info/dependency_links.txt +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/universal_data_cleaner.egg-info/requires.txt +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/src/universal_data_cleaner.egg-info/top_level.txt +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/tests/test_data_cleaner.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/tests/test_ml_audit.py +0 -0
- {universal_data_cleaner-2.5.2 → universal_data_cleaner-2.7.0}/tests/test_validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: universal-data-cleaner
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Production-ready, scikit-learn-compatible data cleaning transformer for pandas.
|
|
5
5
|
Author: Haseeb Khan
|
|
6
6
|
License-Expression: MIT
|
|
@@ -58,12 +58,15 @@ The docs site is the central reference. This README is the short entry point.
|
|
|
58
58
|
| [Leak-safe workflow](https://devlprkhan.github.io/universal-data-cleaner/leak-safe-workflow/) | The fit/transform contract and common mistakes |
|
|
59
59
|
| [Cleaning data](https://devlprkhan.github.io/universal-data-cleaner/cleaning/) | Config, roles, imputation, outliers, datetimes |
|
|
60
60
|
| [Contracts & drift](https://devlprkhan.github.io/universal-data-cleaner/contracts/) | `ColumnSpec`, `DataContract`, drift checks |
|
|
61
|
+
| [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV reads and ingestion reports |
|
|
62
|
+
| [Batch reporting](https://devlprkhan.github.io/universal-data-cleaner/reporting/) | `CleanerReport` and the `data-cleaner audit` CLI |
|
|
61
63
|
| [Validation, joins & dedup](https://devlprkhan.github.io/universal-data-cleaner/validation-joins/) | Expectations, join diagnostics, integrity, dedup |
|
|
62
64
|
| [ML split audit](https://devlprkhan.github.io/universal-data-cleaner/ml-split-audit/) | Duplicate, group, temporal, and target leakage |
|
|
63
65
|
| [Artifacts & reproducibility](https://devlprkhan.github.io/universal-data-cleaner/artifacts/) | Decision log, manifests, fingerprints, save/load |
|
|
64
66
|
| [Production guide](https://devlprkhan.github.io/universal-data-cleaner/production/) | Deployment checklist and failure modes |
|
|
65
67
|
| [API reference](https://devlprkhan.github.io/universal-data-cleaner/api/) | Generated from the package docstrings |
|
|
66
68
|
| [Changelog](https://devlprkhan.github.io/universal-data-cleaner/changelog/) | Release notes |
|
|
69
|
+
| [Upcoming](https://devlprkhan.github.io/universal-data-cleaner/upcoming/) | What ships next and what is out of scope |
|
|
67
70
|
|
|
68
71
|
## Install
|
|
69
72
|
|
|
@@ -131,6 +134,10 @@ for the full explanation.
|
|
|
131
134
|
- boolean coercion and imputation
|
|
132
135
|
- datetime parsing plus calendar feature extraction
|
|
133
136
|
- optional missing-value indicators and constant-column dropping
|
|
137
|
+
- safe CSV ingestion with contract-driven coercion, identifier protection, date
|
|
138
|
+
and boolean guards, and an audit report
|
|
139
|
+
- `CleanerReport` combining profile, contract drift, validation, ingestion, and
|
|
140
|
+
cleaner decisions, plus a `data-cleaner audit` CLI
|
|
134
141
|
- declarative contracts with roles, allowed values, ranges, patterns, and uniqueness
|
|
135
142
|
- automatic train-schema contract inference and transform-time drift reports
|
|
136
143
|
- expectation checks and validation reports
|
|
@@ -24,12 +24,15 @@ The docs site is the central reference. This README is the short entry point.
|
|
|
24
24
|
| [Leak-safe workflow](https://devlprkhan.github.io/universal-data-cleaner/leak-safe-workflow/) | The fit/transform contract and common mistakes |
|
|
25
25
|
| [Cleaning data](https://devlprkhan.github.io/universal-data-cleaner/cleaning/) | Config, roles, imputation, outliers, datetimes |
|
|
26
26
|
| [Contracts & drift](https://devlprkhan.github.io/universal-data-cleaner/contracts/) | `ColumnSpec`, `DataContract`, drift checks |
|
|
27
|
+
| [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV reads and ingestion reports |
|
|
28
|
+
| [Batch reporting](https://devlprkhan.github.io/universal-data-cleaner/reporting/) | `CleanerReport` and the `data-cleaner audit` CLI |
|
|
27
29
|
| [Validation, joins & dedup](https://devlprkhan.github.io/universal-data-cleaner/validation-joins/) | Expectations, join diagnostics, integrity, dedup |
|
|
28
30
|
| [ML split audit](https://devlprkhan.github.io/universal-data-cleaner/ml-split-audit/) | Duplicate, group, temporal, and target leakage |
|
|
29
31
|
| [Artifacts & reproducibility](https://devlprkhan.github.io/universal-data-cleaner/artifacts/) | Decision log, manifests, fingerprints, save/load |
|
|
30
32
|
| [Production guide](https://devlprkhan.github.io/universal-data-cleaner/production/) | Deployment checklist and failure modes |
|
|
31
33
|
| [API reference](https://devlprkhan.github.io/universal-data-cleaner/api/) | Generated from the package docstrings |
|
|
32
34
|
| [Changelog](https://devlprkhan.github.io/universal-data-cleaner/changelog/) | Release notes |
|
|
35
|
+
| [Upcoming](https://devlprkhan.github.io/universal-data-cleaner/upcoming/) | What ships next and what is out of scope |
|
|
33
36
|
|
|
34
37
|
## Install
|
|
35
38
|
|
|
@@ -97,6 +100,10 @@ for the full explanation.
|
|
|
97
100
|
- boolean coercion and imputation
|
|
98
101
|
- datetime parsing plus calendar feature extraction
|
|
99
102
|
- optional missing-value indicators and constant-column dropping
|
|
103
|
+
- safe CSV ingestion with contract-driven coercion, identifier protection, date
|
|
104
|
+
and boolean guards, and an audit report
|
|
105
|
+
- `CleanerReport` combining profile, contract drift, validation, ingestion, and
|
|
106
|
+
cleaner decisions, plus a `data-cleaner audit` CLI
|
|
100
107
|
- declarative contracts with roles, allowed values, ranges, patterns, and uniqueness
|
|
101
108
|
- automatic train-schema contract inference and transform-time drift reports
|
|
102
109
|
- expectation checks and validation reports
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "universal-data-cleaner"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.7.0"
|
|
8
8
|
description = "Production-ready, scikit-learn-compatible data cleaning transformer for pandas."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -50,6 +50,9 @@ Repository = "https://github.com/devlprkhan/universal-data-cleaner"
|
|
|
50
50
|
Issues = "https://github.com/devlprkhan/universal-data-cleaner/issues"
|
|
51
51
|
Changelog = "https://github.com/devlprkhan/universal-data-cleaner/blob/main/CHANGELOG.md"
|
|
52
52
|
|
|
53
|
+
[project.scripts]
|
|
54
|
+
data-cleaner = "data_cleaner.__main__:main"
|
|
55
|
+
|
|
53
56
|
[dependency-groups]
|
|
54
57
|
docs = [
|
|
55
58
|
"mkdocs-material>=9.5",
|
|
@@ -22,6 +22,7 @@ from .cleaner import DataCleaner
|
|
|
22
22
|
from .config import CleanerConfig
|
|
23
23
|
from .contract import ColumnSpec, Contract, DataContract, DriftReport
|
|
24
24
|
from .decisions import CleaningDecision
|
|
25
|
+
from .ingestion import IngestionError, IngestionReport, read_csv_safe
|
|
25
26
|
from .integration import (
|
|
26
27
|
DeduplicationReport,
|
|
27
28
|
JoinDiagnosis,
|
|
@@ -37,6 +38,7 @@ from .profiling import (
|
|
|
37
38
|
drop_duplicate_rows,
|
|
38
39
|
profile_dataframe,
|
|
39
40
|
)
|
|
41
|
+
from .reporting import CleanerReport
|
|
40
42
|
from .validation import (
|
|
41
43
|
Expectation,
|
|
42
44
|
ValidationReport,
|
|
@@ -53,6 +55,7 @@ from .validation import (
|
|
|
53
55
|
|
|
54
56
|
__all__ = [
|
|
55
57
|
"CleanerConfig",
|
|
58
|
+
"CleanerReport",
|
|
56
59
|
"CleaningDecision",
|
|
57
60
|
"ColumnSpec",
|
|
58
61
|
"Contract",
|
|
@@ -61,6 +64,8 @@ __all__ = [
|
|
|
61
64
|
"DeduplicationReport",
|
|
62
65
|
"DriftReport",
|
|
63
66
|
"Expectation",
|
|
67
|
+
"IngestionError",
|
|
68
|
+
"IngestionReport",
|
|
64
69
|
"JoinDiagnosis",
|
|
65
70
|
"ReferentialIntegrityReport",
|
|
66
71
|
"SplitAudit",
|
|
@@ -83,6 +88,7 @@ __all__ = [
|
|
|
83
88
|
"matches_pattern",
|
|
84
89
|
"not_null",
|
|
85
90
|
"profile_dataframe",
|
|
91
|
+
"read_csv_safe",
|
|
86
92
|
"row_count_between",
|
|
87
93
|
"unique",
|
|
88
94
|
"validate",
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"""Command-line entry point for local batch audits."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from ._version import __version__
|
|
10
|
+
from .cleaner import DataCleaner
|
|
11
|
+
from .contract import DataContract
|
|
12
|
+
from .ingestion import read_csv_safe
|
|
13
|
+
from .reporting import CleanerReport
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
17
|
+
"""Build the ``python -m data_cleaner`` argument parser."""
|
|
18
|
+
parser = argparse.ArgumentParser(
|
|
19
|
+
prog="data-cleaner",
|
|
20
|
+
description="Leak-safe data cleaning and batch audits.",
|
|
21
|
+
)
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"--version",
|
|
24
|
+
action="version",
|
|
25
|
+
version=f"%(prog)s {__version__}",
|
|
26
|
+
)
|
|
27
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
28
|
+
|
|
29
|
+
audit = subparsers.add_parser(
|
|
30
|
+
"audit",
|
|
31
|
+
help="Audit a CSV batch and print a report.",
|
|
32
|
+
description=(
|
|
33
|
+
"Read a CSV safely, then report its profile, contract findings, "
|
|
34
|
+
"and cleaner decisions."
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
audit.add_argument("csv", type=Path, help="CSV file to audit.")
|
|
38
|
+
source = audit.add_mutually_exclusive_group()
|
|
39
|
+
source.add_argument(
|
|
40
|
+
"--contract",
|
|
41
|
+
type=Path,
|
|
42
|
+
help="JSON contract file used for ingestion and drift checks.",
|
|
43
|
+
)
|
|
44
|
+
source.add_argument(
|
|
45
|
+
"--cleaner",
|
|
46
|
+
type=Path,
|
|
47
|
+
help="Fitted DataCleaner artifact; uses its contract and decisions.",
|
|
48
|
+
)
|
|
49
|
+
audit.add_argument(
|
|
50
|
+
"--name",
|
|
51
|
+
default=None,
|
|
52
|
+
help="Dataset name shown in the profile (defaults to the file stem).",
|
|
53
|
+
)
|
|
54
|
+
audit.add_argument(
|
|
55
|
+
"--format",
|
|
56
|
+
choices=("markdown", "json"),
|
|
57
|
+
default="markdown",
|
|
58
|
+
help="Report format written to stdout or --output.",
|
|
59
|
+
)
|
|
60
|
+
audit.add_argument(
|
|
61
|
+
"--output",
|
|
62
|
+
type=Path,
|
|
63
|
+
default=None,
|
|
64
|
+
help="Write the report to this file instead of stdout.",
|
|
65
|
+
)
|
|
66
|
+
audit.add_argument(
|
|
67
|
+
"--no-profile",
|
|
68
|
+
action="store_true",
|
|
69
|
+
help="Skip the column-level profile for faster large-file audits.",
|
|
70
|
+
)
|
|
71
|
+
audit.add_argument(
|
|
72
|
+
"--fail-on-warning",
|
|
73
|
+
action="store_true",
|
|
74
|
+
help="Exit with status 1 when warnings are present.",
|
|
75
|
+
)
|
|
76
|
+
return parser
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _load_contract(path: Path) -> DataContract:
|
|
80
|
+
return DataContract.from_json(path.read_text(encoding="utf-8"))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _run_audit(args: argparse.Namespace) -> int:
|
|
84
|
+
contract: DataContract | None = None
|
|
85
|
+
cleaner: DataCleaner | None = None
|
|
86
|
+
if args.contract is not None:
|
|
87
|
+
contract = _load_contract(args.contract)
|
|
88
|
+
if args.cleaner is not None:
|
|
89
|
+
cleaner = DataCleaner.load(args.cleaner)
|
|
90
|
+
contract = cleaner.fitted_contract()
|
|
91
|
+
|
|
92
|
+
frame, ingestion = read_csv_safe(
|
|
93
|
+
args.csv,
|
|
94
|
+
contract=contract,
|
|
95
|
+
on_error="ignore",
|
|
96
|
+
)
|
|
97
|
+
dataset_name = args.name or args.csv.stem
|
|
98
|
+
if cleaner is not None:
|
|
99
|
+
report = CleanerReport.from_cleaner(
|
|
100
|
+
cleaner,
|
|
101
|
+
frame,
|
|
102
|
+
source=ingestion.source,
|
|
103
|
+
name=dataset_name,
|
|
104
|
+
ingestion=ingestion,
|
|
105
|
+
include_profile=not args.no_profile,
|
|
106
|
+
)
|
|
107
|
+
else:
|
|
108
|
+
report = CleanerReport.from_frame(
|
|
109
|
+
frame,
|
|
110
|
+
source=ingestion.source,
|
|
111
|
+
name=dataset_name,
|
|
112
|
+
contract=contract,
|
|
113
|
+
ingestion=ingestion,
|
|
114
|
+
include_profile=not args.no_profile,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
rendered = (
|
|
118
|
+
report.to_markdown()
|
|
119
|
+
if args.format == "markdown"
|
|
120
|
+
else report.to_json(indent=2) + "\n"
|
|
121
|
+
)
|
|
122
|
+
if args.output is None:
|
|
123
|
+
print(rendered, end="")
|
|
124
|
+
else:
|
|
125
|
+
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
126
|
+
args.output.write_text(rendered, encoding="utf-8")
|
|
127
|
+
print(f"Wrote {args.format} report to {args.output}", file=sys.stderr)
|
|
128
|
+
|
|
129
|
+
failed = not report.success or (args.fail_on_warning and report.has_warnings)
|
|
130
|
+
return 1 if failed else 0
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def main(argv: list[str] | None = None) -> int:
|
|
134
|
+
"""Run the CLI and return a process exit status."""
|
|
135
|
+
parser = build_parser()
|
|
136
|
+
args = parser.parse_args(argv)
|
|
137
|
+
if args.command == "audit":
|
|
138
|
+
try:
|
|
139
|
+
return _run_audit(args)
|
|
140
|
+
except (OSError, ValueError, TypeError) as exc:
|
|
141
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
142
|
+
return 2
|
|
143
|
+
parser.print_help()
|
|
144
|
+
return 2
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
if __name__ == "__main__": # pragma: no cover - exercised via `python -m`
|
|
148
|
+
raise SystemExit(main())
|