cleancore 0.1.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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025 [Sidra Saqlain]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: cleancore
3
+ Version: 0.1.0
4
+ Summary: Dependency-free data transformation audit framework
5
+ Author-email: Sidra <sidrasaqlain11@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # CleanCore
13
+
14
+ CleanCore is a **dependency-free data transformation audit framework**.
15
+
16
+ Unlike data profilers, CleanCore tracks:
17
+ - What changed
18
+ - Which rows were affected
19
+ - Before / after values
20
+ - Why it changed (business rule)
21
+ - Compliance-ready audit trail
22
+
23
+ ## Example
24
+
25
+ ```python
26
+ from cleancore import CleanEngine, print_audit_report
27
+
28
+ engine = CleanEngine(df)
29
+ cleaned_df, audit_log = engine.run()
30
+ print_audit_report(audit_log)
@@ -0,0 +1,19 @@
1
+ # CleanCore
2
+
3
+ CleanCore is a **dependency-free data transformation audit framework**.
4
+
5
+ Unlike data profilers, CleanCore tracks:
6
+ - What changed
7
+ - Which rows were affected
8
+ - Before / after values
9
+ - Why it changed (business rule)
10
+ - Compliance-ready audit trail
11
+
12
+ ## Example
13
+
14
+ ```python
15
+ from cleancore import CleanEngine, print_audit_report
16
+
17
+ engine = CleanEngine(df)
18
+ cleaned_df, audit_log = engine.run()
19
+ print_audit_report(audit_log)
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cleancore"
7
+ version = "0.1.0"
8
+ description = "Dependency-free data transformation audit framework"
9
+ authors = [
10
+ { name = "Sidra", email = "sidrasaqlain11@gmail.com" }
11
+ ]
12
+ readme = "README.md"
13
+ license = { text = "MIT" }
14
+ requires-python = ">=3.8"
15
+
16
+ dependencies = []
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="cleancore",
5
+ version="0.1.0",
6
+ package_dir={"": "src"},
7
+ packages=find_packages(where="src"),
8
+ )
@@ -0,0 +1,2 @@
1
+ from .engine import CleanEngine
2
+ from .report import print_audit_report
@@ -0,0 +1,24 @@
1
+ class AuditEvent:
2
+ def __init__(
3
+ self,
4
+ audit_id,
5
+ timestamp,
6
+ transformation,
7
+ problem,
8
+ solution,
9
+ rule_id,
10
+ affected_rows,
11
+ before_hash,
12
+ after_hash,
13
+ status
14
+ ):
15
+ self.audit_id = audit_id
16
+ self.timestamp = timestamp
17
+ self.transformation = transformation
18
+ self.problem = problem
19
+ self.solution = solution
20
+ self.rule_id = rule_id
21
+ self.affected_rows = affected_rows
22
+ self.before_hash = before_hash
23
+ self.after_hash = after_hash
24
+ self.status = status
@@ -0,0 +1,70 @@
1
+ from datetime import datetime
2
+ from .audit import AuditEvent
3
+ from .transform import dataframe_hash
4
+
5
+ class CleanEngine:
6
+ def __init__(self, df, id_column="CustomerID"):
7
+ self.df = df
8
+ self.id_column = id_column
9
+ self.audit_log = []
10
+ self.audit_id = "AUD20241219001"
11
+
12
+ def run(self):
13
+ self._impute_missing_age()
14
+ self._detect_constant_salary()
15
+ return self.df, self.audit_log
16
+
17
+ def _impute_missing_age(self):
18
+ if self.df["Age"].isna().sum() == 0:
19
+ return
20
+
21
+ before_hash = dataframe_hash(self.df)
22
+ median_age = self.df["Age"].median()
23
+
24
+ affected = []
25
+
26
+ for idx, row in self.df[self.df["Age"].isna()].iterrows():
27
+ affected.append({
28
+ "row_index": int(idx),
29
+ "customer_id": row[self.id_column],
30
+ "column": "Age",
31
+ "before": None,
32
+ "after": median_age
33
+ })
34
+ self.df.at[idx, "Age"] = median_age
35
+
36
+ after_hash = dataframe_hash(self.df)
37
+
38
+ event = AuditEvent(
39
+ audit_id=self.audit_id,
40
+ timestamp=datetime.utcnow().isoformat(),
41
+ transformation="Missing values imputation",
42
+ problem=f"Age has missing values ({len(affected)} rows)",
43
+ solution=f"Filled with median ({median_age})",
44
+ rule_id="GDPR_COMPLIANT_IMPUTATION_v2",
45
+ affected_rows=affected,
46
+ before_hash=before_hash,
47
+ after_hash=after_hash,
48
+ status="AUTO_FIXED"
49
+ )
50
+
51
+ self.audit_log.append(event)
52
+
53
+ def _detect_constant_salary(self):
54
+ if self.df["Salary"].std() != 0:
55
+ return
56
+
57
+ event = AuditEvent(
58
+ audit_id=self.audit_id,
59
+ timestamp=datetime.utcnow().isoformat(),
60
+ transformation="Constant column detection",
61
+ problem="Salary has zero variance",
62
+ solution="Flagged for manual review",
63
+ rule_id="FINANCE_RULE_001",
64
+ affected_rows=[],
65
+ before_hash=dataframe_hash(self.df),
66
+ after_hash=dataframe_hash(self.df),
67
+ status="PENDING_REVIEW"
68
+ )
69
+
70
+ self.audit_log.append(event)
@@ -0,0 +1,44 @@
1
+ def print_audit_report(audit_log):
2
+ if not audit_log:
3
+ print("No transformations applied.")
4
+ return
5
+
6
+ audit_id = audit_log[0].audit_id
7
+
8
+ print(f"\nAUDIT TRAIL #{audit_id}")
9
+ print("=" * 40)
10
+
11
+ for i, event in enumerate(audit_log, 1):
12
+ print(f"\nTRANSFORMATION {i}: {event.transformation}")
13
+ print(f"• Problem: {event.problem}")
14
+ print(f"• Solution: {event.solution}")
15
+ print(f"• Business Rule: {event.rule_id}")
16
+
17
+ if event.affected_rows:
18
+ print("• Affected Records:")
19
+ for r in event.affected_rows:
20
+ print(
21
+ f" - Row {r['row_index']} "
22
+ f"(Customer: {r['customer_id']}): "
23
+ f"{r['before']} → {r['after']}"
24
+ )
25
+
26
+ print(
27
+ f"• Validation Hash: "
28
+ f"sha256:{event.before_hash[:6]} → sha256:{event.after_hash[:6]}"
29
+ )
30
+
31
+ if event.status == "AUTO_FIXED":
32
+ print("• Status: Auto-fixed")
33
+ else:
34
+ print("• Status: Pending review")
35
+
36
+ print("\nSUMMARY:")
37
+ total = len(audit_log)
38
+ auto_fixed = sum(e.status == "AUTO_FIXED" for e in audit_log)
39
+ pending = sum(e.status == "PENDING_REVIEW" for e in audit_log)
40
+
41
+ print(f"• Total problems: {total}")
42
+ print(f"• Auto-fixed: {auto_fixed}")
43
+ print(f"• Manual review: {pending}")
44
+ print(f"• Audit ID: {audit_id} (save for compliance)")
@@ -0,0 +1,10 @@
1
+ RULES = {
2
+ "GDPR_COMPLIANT_IMPUTATION_v2": {
3
+ "description": "Fill missing values using median",
4
+ "owner": "Data Protection Office"
5
+ },
6
+ "FINANCE_RULE_001": {
7
+ "description": "Constant salary requires HR approval",
8
+ "owner": "Finance Department"
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ import hashlib
2
+
3
+ def dataframe_hash(df):
4
+ """
5
+ Deterministic hash of dataframe content (stdlib only)
6
+ """
7
+ raw = df.to_csv(index=True).encode("utf-8")
8
+ return hashlib.sha256(raw).hexdigest()
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: cleancore
3
+ Version: 0.1.0
4
+ Summary: Dependency-free data transformation audit framework
5
+ Author-email: Sidra <sidrasaqlain11@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+ # CleanCore
13
+
14
+ CleanCore is a **dependency-free data transformation audit framework**.
15
+
16
+ Unlike data profilers, CleanCore tracks:
17
+ - What changed
18
+ - Which rows were affected
19
+ - Before / after values
20
+ - Why it changed (business rule)
21
+ - Compliance-ready audit trail
22
+
23
+ ## Example
24
+
25
+ ```python
26
+ from cleancore import CleanEngine, print_audit_report
27
+
28
+ engine = CleanEngine(df)
29
+ cleaned_df, audit_log = engine.run()
30
+ print_audit_report(audit_log)
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ src/cleancore/__init__.py
6
+ src/cleancore/audit.py
7
+ src/cleancore/engine.py
8
+ src/cleancore/report.py
9
+ src/cleancore/rules.py
10
+ src/cleancore/transform.py
11
+ src/cleancore.egg-info/PKG-INFO
12
+ src/cleancore.egg-info/SOURCES.txt
13
+ src/cleancore.egg-info/dependency_links.txt
14
+ src/cleancore.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ cleancore