wowdata 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.
wowdata-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 sci2pro
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
wowdata-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: wowdata
3
+ Version: 0.1.0
4
+ Summary: A human-centred, teachable data wrangling and pipeline framework.
5
+ Author: WowData Contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/sci2pro/wowdata
8
+ Project-URL: Repository, https://github.com/sci2pro/wowdata
9
+ Project-URL: Issues, https://github.com/sci2pro/wowdata/issues
10
+ Keywords: data-engineering,etl,data-pipelines,education,data-wrangling
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: petl>=1.7
25
+ Requires-Dist: frictionless>=5.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov; extra == "dev"
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: mypy; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: mkdocs; extra == "docs"
34
+ Requires-Dist: mkdocs-material; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # WowData™
38
+
39
+ WowData™ is a human-centred data wrangling and pipeline framework designed to make real-world data cleanup understandable, teachable, and inspectable.
40
+
41
+ ## Install
42
+
43
+ From PyPI:
44
+
45
+ ```bash
46
+ pip install wowdata
47
+ ```
48
+
49
+ From source (editable):
50
+
51
+ ```bash
52
+ git clone https://github.com/sci2pro/wowdata.git
53
+ cd wowdata
54
+ pip install -e .
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ Create a small input CSV:
60
+
61
+ ```csv
62
+ person_id,age,country
63
+ 1,30,KE
64
+ 2,17,UG
65
+ 3,41,KE
66
+ ```
67
+
68
+ Run with Python API:
69
+
70
+ ```python
71
+ from wowdata import Pipeline, Sink, Source, Transform
72
+
73
+ pipe = (
74
+ Pipeline(Source("people.csv"))
75
+ .then(Transform("cast", params={"types": {"age": "integer"}, "on_error": "null"}))
76
+ .then(Transform("filter", params={"where": "age >= 18 and country == 'KE'"}))
77
+ .then(Sink("adults_ke.csv"))
78
+ )
79
+
80
+ pipe.run()
81
+ ```
82
+
83
+ Run from YAML with CLI:
84
+
85
+ ```bash
86
+ wow run pipeline.yaml
87
+ ```
88
+
89
+ Fallback command if `wow` conflicts in your shell:
90
+
91
+ ```bash
92
+ wowdata run pipeline.yaml
93
+ ```
94
+
95
+ ## Documentation
96
+
97
+ - Philosophy: [docs/philosophy.md](docs/philosophy.md)
98
+ - Examples: [EXAMPLES.md](EXAMPLES.md)
99
+ - Reference: [REFERENCE.md](REFERENCE.md)
100
+ - Docs site source: [docs/](docs/) + [mkdocs.yml](mkdocs.yml)
101
+
102
+ To preview docs locally:
103
+
104
+ ```bash
105
+ pip install -e .[docs]
106
+ mkdocs serve
107
+ ```
108
+
109
+ The same docs can be published to GitHub Pages (for `wowdata.github.io`).
@@ -0,0 +1,73 @@
1
+ # WowData™
2
+
3
+ WowData™ is a human-centred data wrangling and pipeline framework designed to make real-world data cleanup understandable, teachable, and inspectable.
4
+
5
+ ## Install
6
+
7
+ From PyPI:
8
+
9
+ ```bash
10
+ pip install wowdata
11
+ ```
12
+
13
+ From source (editable):
14
+
15
+ ```bash
16
+ git clone https://github.com/sci2pro/wowdata.git
17
+ cd wowdata
18
+ pip install -e .
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ Create a small input CSV:
24
+
25
+ ```csv
26
+ person_id,age,country
27
+ 1,30,KE
28
+ 2,17,UG
29
+ 3,41,KE
30
+ ```
31
+
32
+ Run with Python API:
33
+
34
+ ```python
35
+ from wowdata import Pipeline, Sink, Source, Transform
36
+
37
+ pipe = (
38
+ Pipeline(Source("people.csv"))
39
+ .then(Transform("cast", params={"types": {"age": "integer"}, "on_error": "null"}))
40
+ .then(Transform("filter", params={"where": "age >= 18 and country == 'KE'"}))
41
+ .then(Sink("adults_ke.csv"))
42
+ )
43
+
44
+ pipe.run()
45
+ ```
46
+
47
+ Run from YAML with CLI:
48
+
49
+ ```bash
50
+ wow run pipeline.yaml
51
+ ```
52
+
53
+ Fallback command if `wow` conflicts in your shell:
54
+
55
+ ```bash
56
+ wowdata run pipeline.yaml
57
+ ```
58
+
59
+ ## Documentation
60
+
61
+ - Philosophy: [docs/philosophy.md](docs/philosophy.md)
62
+ - Examples: [EXAMPLES.md](EXAMPLES.md)
63
+ - Reference: [REFERENCE.md](REFERENCE.md)
64
+ - Docs site source: [docs/](docs/) + [mkdocs.yml](mkdocs.yml)
65
+
66
+ To preview docs locally:
67
+
68
+ ```bash
69
+ pip install -e .[docs]
70
+ mkdocs serve
71
+ ```
72
+
73
+ The same docs can be published to GitHub Pages (for `wowdata.github.io`).
@@ -0,0 +1,95 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "wowdata"
7
+ version = "0.1.0"
8
+ description = "A human-centred, teachable data wrangling and pipeline framework."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [
12
+ { name = "WowData Contributors" }
13
+ ]
14
+ requires-python = ">=3.10"
15
+
16
+ dependencies = [
17
+ "petl>=1.7",
18
+ "frictionless>=5.0",
19
+ ]
20
+
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Education",
24
+ "Intended Audience :: Developers",
25
+ "Topic :: Software Development :: Libraries",
26
+ "Topic :: Scientific/Engineering :: Information Analysis",
27
+ "License :: OSI Approved :: Apache Software License",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ ]
33
+
34
+ keywords = [
35
+ "data-engineering",
36
+ "etl",
37
+ "data-pipelines",
38
+ "education",
39
+ "data-wrangling",
40
+ ]
41
+
42
+ [project.optional-dependencies]
43
+ dev = [
44
+ "pytest>=7.0",
45
+ "pytest-cov",
46
+ "black",
47
+ "ruff",
48
+ "mypy",
49
+ ]
50
+
51
+ docs = [
52
+ "mkdocs",
53
+ "mkdocs-material",
54
+ ]
55
+
56
+ [project.urls]
57
+ Homepage = "https://github.com/sci2pro/wowdata"
58
+ Repository = "https://github.com/sci2pro/wowdata"
59
+ Issues = "https://github.com/sci2pro/wowdata/issues"
60
+
61
+ [project.scripts]
62
+ wow = "wowdata.cli:main"
63
+ wowdata = "wowdata.cli:main"
64
+
65
+ [tool.setuptools]
66
+ packages = ["wowdata"]
67
+
68
+ [tool.setuptools.package-data]
69
+ wowdata = ["py.typed"]
70
+
71
+ [tool.pytest.ini_options]
72
+ testpaths = ["wowdata/tests"]
73
+ addopts = "-q"
74
+
75
+ [tool.black]
76
+ line-length = 88
77
+ target-version = ["py310"]
78
+
79
+ [tool.ruff]
80
+ line-length = 88
81
+ select = ["E", "F", "W", "I"]
82
+ ignore = ["E501"]
83
+
84
+ [tool.mypy]
85
+ python_version = "3.10"
86
+ strict = false
87
+ warn_return_any = true
88
+ warn_unused_configs = true
89
+
90
+ [tools.coverage.run]
91
+ omit = [
92
+ "wowdata/wowdata/tests/examples/",
93
+ "wowdata/wowdata/tests/",
94
+ "wowdata/experiments/"
95
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from wowdata.models.pipeline import Pipeline
2
+ from wowdata.models.sinks import Sink
3
+ from wowdata.models.sources import Source
4
+ from wowdata.models.transforms import Transform
5
+ from wowdata.errors import WowDataUserError
6
+
7
+ __all__ = ["Pipeline", "Sink", "Source", "Transform", "WowDataUserError"]
@@ -0,0 +1,211 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import sys
6
+ from pathlib import Path
7
+ from typing import Any, Dict, Optional, Sequence
8
+
9
+ from wowdata import Pipeline, WowDataUserError
10
+
11
+ EXIT_OK = 0
12
+ EXIT_USAGE = 2
13
+ EXIT_PIPELINE_PARSE = 3
14
+ EXIT_PIPELINE_RUNTIME = 4
15
+
16
+
17
+ def _default_locked_path(pipeline_path: str) -> Path:
18
+ p = Path(pipeline_path)
19
+ if p.suffix in {".yaml", ".yml"}:
20
+ return p.with_name(f"{p.stem}.locked{p.suffix}")
21
+ return p.with_name(f"{p.name}.locked.yaml")
22
+
23
+
24
+ def _load_pipeline(path: str, base_dir: Optional[str]) -> Pipeline:
25
+ resolved_base_dir = Path(base_dir) if base_dir else None
26
+ return Pipeline.from_yaml(path, base_dir=resolved_base_dir)
27
+
28
+
29
+ def _print_user_error(err: WowDataUserError) -> None:
30
+ print(str(err), file=sys.stderr)
31
+
32
+
33
+ def _print_json(payload: Dict[str, Any]) -> None:
34
+ print(json.dumps(payload, indent=2, sort_keys=False))
35
+
36
+
37
+ def _cmd_run(args: argparse.Namespace) -> int:
38
+ try:
39
+ pipe = _load_pipeline(args.pipeline, args.base_dir)
40
+ except WowDataUserError as e:
41
+ _print_user_error(e)
42
+ return EXIT_PIPELINE_PARSE
43
+
44
+ try:
45
+ ctx = pipe.run()
46
+ except WowDataUserError as e:
47
+ _print_user_error(e)
48
+ return EXIT_PIPELINE_RUNTIME
49
+
50
+ sinks = [s for s in pipe.steps if getattr(s, "uri", None) is not None and s.__class__.__name__ == "Sink"]
51
+
52
+ if args.json:
53
+ payload: Dict[str, Any] = {
54
+ "ok": True,
55
+ "command": "run",
56
+ "pipeline": args.pipeline,
57
+ "steps": len(pipe.steps),
58
+ "sinks": [s.uri for s in sinks],
59
+ "checkpoints": len(ctx.checkpoints),
60
+ "validations": ctx.validations,
61
+ }
62
+ if args.show_checkpoints:
63
+ payload["checkpoint_data"] = ctx.checkpoints
64
+ _print_json(payload)
65
+ return EXIT_OK
66
+
67
+ if not args.quiet:
68
+ print(f"Run complete: {args.pipeline}")
69
+ print(f"Steps: {len(pipe.steps)}")
70
+ if sinks:
71
+ print("Sinks:")
72
+ for s in sinks:
73
+ print(f"- {s.uri}")
74
+ print(f"Checkpoints: {len(ctx.checkpoints)}")
75
+ if ctx.validations:
76
+ print(f"Validations: {len(ctx.validations)}")
77
+
78
+ if args.show_checkpoints:
79
+ print(json.dumps(ctx.checkpoints, indent=2, default=str))
80
+
81
+ return EXIT_OK
82
+
83
+
84
+ def _cmd_validate(args: argparse.Namespace) -> int:
85
+ try:
86
+ pipe = _load_pipeline(args.pipeline, args.base_dir)
87
+ pipe.preflight()
88
+ except WowDataUserError as e:
89
+ _print_user_error(e)
90
+ return EXIT_PIPELINE_PARSE
91
+
92
+ if args.json:
93
+ _print_json(
94
+ {
95
+ "ok": True,
96
+ "command": "validate",
97
+ "pipeline": args.pipeline,
98
+ "steps": len(pipe.steps),
99
+ }
100
+ )
101
+ else:
102
+ print(f"Pipeline is valid: {args.pipeline}")
103
+ print(f"Steps: {len(pipe.steps)}")
104
+
105
+ return EXIT_OK
106
+
107
+
108
+ def _cmd_schema(args: argparse.Namespace) -> int:
109
+ try:
110
+ pipe = _load_pipeline(args.pipeline, args.base_dir)
111
+ sch = pipe.schema(sample_rows=args.sample_rows, force=args.force)
112
+ except WowDataUserError as e:
113
+ _print_user_error(e)
114
+ return EXIT_PIPELINE_PARSE
115
+
116
+ if args.json:
117
+ _print_json(
118
+ {
119
+ "ok": True,
120
+ "command": "schema",
121
+ "pipeline": args.pipeline,
122
+ "schema": sch,
123
+ }
124
+ )
125
+ else:
126
+ print(f"Schema for: {args.pipeline}")
127
+ print(json.dumps(sch, indent=2, sort_keys=False))
128
+
129
+ return EXIT_OK
130
+
131
+
132
+ def _cmd_lock_schema(args: argparse.Namespace) -> int:
133
+ out_path = Path(args.output) if args.output else _default_locked_path(args.pipeline)
134
+
135
+ try:
136
+ pipe = _load_pipeline(args.pipeline, args.base_dir)
137
+ pipe.to_yaml(
138
+ path=out_path,
139
+ lock_schema=True,
140
+ sample_rows=args.sample_rows,
141
+ force=args.force,
142
+ )
143
+ except WowDataUserError as e:
144
+ _print_user_error(e)
145
+ return EXIT_PIPELINE_PARSE
146
+
147
+ if args.json:
148
+ _print_json(
149
+ {
150
+ "ok": True,
151
+ "command": "lock-schema",
152
+ "pipeline": args.pipeline,
153
+ "output": str(out_path),
154
+ }
155
+ )
156
+ else:
157
+ print(f"Schema-locked pipeline written: {out_path}")
158
+
159
+ return EXIT_OK
160
+
161
+
162
+ def _build_parser() -> argparse.ArgumentParser:
163
+ parser = argparse.ArgumentParser(
164
+ prog="wowdata",
165
+ description="WowData CLI for running YAML pipelines.",
166
+ )
167
+
168
+ subparsers = parser.add_subparsers(dest="command", required=True)
169
+
170
+ run_p = subparsers.add_parser("run", help="Run a YAML pipeline.")
171
+ run_p.add_argument("pipeline", help="Path to pipeline YAML file.")
172
+ run_p.add_argument("--base-dir", help="Base directory for relative paths in YAML.")
173
+ run_p.add_argument("--json", action="store_true", help="Print machine-readable JSON output.")
174
+ run_p.add_argument("--quiet", action="store_true", help="Suppress normal status output.")
175
+ run_p.add_argument("--show-checkpoints", action="store_true", help="Print checkpoint details after run.")
176
+ run_p.set_defaults(func=_cmd_run)
177
+
178
+ validate_p = subparsers.add_parser("validate", help="Validate pipeline YAML and preflight I/O paths.")
179
+ validate_p.add_argument("pipeline", help="Path to pipeline YAML file.")
180
+ validate_p.add_argument("--base-dir", help="Base directory for relative paths in YAML.")
181
+ validate_p.add_argument("--json", action="store_true", help="Print machine-readable JSON output.")
182
+ validate_p.set_defaults(func=_cmd_validate)
183
+
184
+ schema_p = subparsers.add_parser("schema", help="Infer output schema without full execution.")
185
+ schema_p.add_argument("pipeline", help="Path to pipeline YAML file.")
186
+ schema_p.add_argument("--base-dir", help="Base directory for relative paths in YAML.")
187
+ schema_p.add_argument("--sample-rows", type=int, default=200, help="Rows to sample for schema inference.")
188
+ schema_p.add_argument("--force", action="store_true", help="Recompute schema even if cached.")
189
+ schema_p.add_argument("--json", action="store_true", help="Print machine-readable JSON output.")
190
+ schema_p.set_defaults(func=_cmd_schema)
191
+
192
+ lock_p = subparsers.add_parser("lock-schema", help="Write a schema-locked YAML pipeline.")
193
+ lock_p.add_argument("pipeline", help="Path to pipeline YAML file.")
194
+ lock_p.add_argument("-o", "--output", help="Output path for locked YAML.")
195
+ lock_p.add_argument("--base-dir", help="Base directory for relative paths in YAML.")
196
+ lock_p.add_argument("--sample-rows", type=int, default=200, help="Rows to sample for schema inference.")
197
+ lock_p.add_argument("--force", action="store_true", help="Recompute schema even if cached.")
198
+ lock_p.add_argument("--json", action="store_true", help="Print machine-readable JSON output.")
199
+ lock_p.set_defaults(func=_cmd_lock_schema)
200
+
201
+ return parser
202
+
203
+
204
+ def main(argv: Optional[Sequence[str]] = None) -> int:
205
+ parser = _build_parser()
206
+ args = parser.parse_args(argv)
207
+ return int(args.func(args))
208
+
209
+
210
+ if __name__ == "__main__":
211
+ raise SystemExit(main())
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional
4
+
5
+
6
+ class WowDataUserError(Exception):
7
+ """An instructional error intended for end users.
8
+
9
+ Use this for mistakes in the pipeline definition (invalid params, missing columns, etc.).
10
+ It carries a short error code and an optional hint to guide the user.
11
+ """
12
+
13
+ def __init__(self, code: str, message: str, *, hint: Optional[str] = None):
14
+ super().__init__(message)
15
+ self.code = code
16
+ self.message = message
17
+ self.hint = hint
18
+
19
+ def __str__(self) -> str:
20
+ base = f"[{self.code}] {self.message}"
21
+ if self.hint:
22
+ return base + f"\nHint: {self.hint}"
23
+ return base
@@ -0,0 +1,254 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+ from typing import Dict, Any, Optional, List
6
+
7
+ from wowdata.errors import WowDataUserError
8
+ from wowdata.models.sources import Source
9
+ from wowdata.models.sinks import Sink
10
+ from wowdata.models.transforms import Transform
11
+ from wowdata.util import _norm_path, FrictionlessSchema
12
+
13
+
14
+ def _schema_field_names(schema: Optional[FrictionlessSchema]) -> List[str]:
15
+ if not schema or not isinstance(schema, dict):
16
+ return []
17
+ fields = schema.get("fields")
18
+ if not isinstance(fields, list):
19
+ return []
20
+ out: List[str] = []
21
+ for f in fields:
22
+ if isinstance(f, dict) and isinstance(f.get("name"), str):
23
+ out.append(f["name"])
24
+ return out
25
+
26
+
27
+ def _source_to_ir(src: Source) -> Dict[str, Any]:
28
+ uri = os.fspath(src.uri)
29
+ d: Dict[str, Any] = {"uri": uri}
30
+ if src.type is not None:
31
+ d["type"] = src.type
32
+ if src.schema is not None:
33
+ d["schema"] = src.schema
34
+ if src.options:
35
+ d["options"] = dict(src.options)
36
+ return d
37
+
38
+
39
+ def _sink_to_ir(sink: Sink) -> Dict[str, Any]:
40
+ uri = os.fspath(sink.uri)
41
+ d: Dict[str, Any] = {"uri": uri}
42
+ if sink.type is not None:
43
+ d["type"] = sink.type
44
+ if sink.options:
45
+ d["options"] = dict(sink.options)
46
+ return d
47
+
48
+
49
+ def _transform_to_ir(t: Transform) -> Dict[str, Any]:
50
+ d: Dict[str, Any] = {"op": t.op}
51
+ if t.params:
52
+ d["params"] = dict(t.params)
53
+ if t.output_schema_override is not None:
54
+ d["output_schema"] = t.output_schema_override
55
+ return d
56
+
57
+
58
+ def _source_from_ir(d: Dict[str, Any]) -> Source:
59
+ if not isinstance(d, dict):
60
+ raise WowDataUserError(
61
+ "E_IR_SOURCE",
62
+ "IR source must be a mapping.",
63
+ hint="Example: start: {uri: people.csv, type: csv}",
64
+ )
65
+ uri = d.get("uri")
66
+ if not isinstance(uri, str) or not uri:
67
+ raise WowDataUserError(
68
+ "E_IR_SOURCE",
69
+ "IR source requires a non-empty 'uri' string.",
70
+ hint="Example: start: {uri: people.csv}",
71
+ )
72
+ return Source(
73
+ uri,
74
+ type=d.get("type"),
75
+ schema=d.get("schema"),
76
+ options=d.get("options") or {},
77
+ )
78
+
79
+
80
+ def _sink_from_ir(d: Dict[str, Any]) -> Sink:
81
+ if not isinstance(d, dict):
82
+ raise WowDataUserError(
83
+ "E_IR_SINK",
84
+ "IR sink must be a mapping.",
85
+ hint="Example: {sink: {uri: out.csv}}",
86
+ )
87
+ uri = d.get("uri")
88
+ if not isinstance(uri, str) or not uri:
89
+ raise WowDataUserError(
90
+ "E_IR_SINK",
91
+ "IR sink requires a non-empty 'uri' string.",
92
+ hint="Example: {sink: {uri: out.csv}}",
93
+ )
94
+ return Sink(
95
+ uri,
96
+ type=d.get("type"),
97
+ options=d.get("options") or {},
98
+ )
99
+
100
+
101
+ def _normalize_ir(ir: Any, *, base_dir: Optional[Path]) -> Dict[str, Any]:
102
+ """Normalize IR structure and paths.
103
+
104
+ Guarantees:
105
+ - returns a dict with keys: wowdata, pipeline
106
+ - pipeline.start.uri is normalized
107
+ - any sink.uri is normalized
108
+ - any join params.right (string or descriptor.uri) is normalized
109
+ - missing/None options become {}
110
+ - missing transform params become {}
111
+
112
+ This does not change semantics; it makes the IR portable and deterministic.
113
+ """
114
+ if not isinstance(ir, dict):
115
+ raise WowDataUserError(
116
+ "E_IR_ROOT",
117
+ "IR must be a mapping at the root.",
118
+ hint="Expected keys: wowdata, pipeline.",
119
+ )
120
+
121
+ ir2: Dict[str, Any] = dict(ir)
122
+
123
+ # Default version
124
+ if ir2.get("wowdata") is None:
125
+ ir2["wowdata"] = 0
126
+
127
+ version = ir2.get("wowdata")
128
+ if version != 0:
129
+ raise WowDataUserError(
130
+ "E_IR_VERSION",
131
+ f"Unsupported IR version: {version!r}.",
132
+ hint="Supported: wowdata: 0",
133
+ )
134
+
135
+ pipe = ir2.get("pipeline")
136
+ if not isinstance(pipe, dict):
137
+ raise WowDataUserError(
138
+ "E_IR_PIPELINE",
139
+ "IR requires a 'pipeline' mapping.",
140
+ hint="Example: {wowdata: 0, pipeline: {start: {...}, steps: [...]}}",
141
+ )
142
+
143
+ pipe2: Dict[str, Any] = dict(pipe)
144
+
145
+ # Normalize start
146
+ start = pipe2.get("start")
147
+ if not isinstance(start, dict):
148
+ raise WowDataUserError(
149
+ "E_IR_SOURCE",
150
+ "IR pipeline.start must be a mapping.",
151
+ hint="Example: start: {uri: people.csv, type: csv}",
152
+ )
153
+ start2: Dict[str, Any] = dict(start)
154
+ u = start2.get("uri")
155
+ if isinstance(u, str):
156
+ start2["uri"] = _norm_path(u, base_dir=base_dir)
157
+ if "options" in start2 and start2["options"] is None:
158
+ start2["options"] = {}
159
+ pipe2["start"] = start2
160
+
161
+ # Normalize steps
162
+ steps = pipe2.get("steps")
163
+ if steps is None:
164
+ steps = []
165
+ if not isinstance(steps, list):
166
+ raise WowDataUserError(
167
+ "E_IR_STEPS",
168
+ "IR pipeline.steps must be a list.",
169
+ hint="Example: steps: [{transform: {...}}, {sink: {...}}]",
170
+ )
171
+
172
+ norm_steps: List[Dict[str, Any]] = []
173
+ for i, item in enumerate(steps):
174
+ if not isinstance(item, dict) or len(item) != 1:
175
+ raise WowDataUserError(
176
+ "E_IR_STEP",
177
+ f"IR step #{i} must be a mapping with exactly one key: 'transform' or 'sink'.",
178
+ hint=str(item),
179
+ )
180
+
181
+ if "sink" in item:
182
+ s = item["sink"]
183
+ if not isinstance(s, dict):
184
+ raise WowDataUserError(
185
+ "E_IR_SINK",
186
+ "IR sink must be a mapping.",
187
+ hint="Example: - sink: {uri: out.csv}",
188
+ )
189
+ s2: Dict[str, Any] = dict(s)
190
+ su = s2.get("uri")
191
+ if isinstance(su, str):
192
+ s2["uri"] = _norm_path(su, base_dir=base_dir)
193
+ if "options" in s2 and s2["options"] is None:
194
+ s2["options"] = {}
195
+ norm_steps.append({"sink": s2})
196
+ continue
197
+
198
+ if "transform" in item:
199
+ t = item["transform"]
200
+ if not isinstance(t, dict):
201
+ raise WowDataUserError(
202
+ "E_IR_TRANSFORM",
203
+ "IR transform must be a mapping.",
204
+ hint="Example: - transform: {op: select, params: {...}}",
205
+ )
206
+ t2: Dict[str, Any] = dict(t)
207
+ params = t2.get("params")
208
+ if params is None:
209
+ params = {}
210
+ t2["params"] = params
211
+ if not isinstance(params, dict):
212
+ raise WowDataUserError(
213
+ "E_IR_TRANSFORM",
214
+ "IR transform 'params' must be a mapping.",
215
+ hint="Example: params: {where: \"age >= 30\"}",
216
+ )
217
+
218
+ # Join: normalize YAML 1.1 boolean key oddities and right-side path descriptors.
219
+ if t2.get("op") == "join":
220
+ # In YAML 1.1, unquoted key `on` may parse as boolean True.
221
+ # Normalize `{true: [...]}` to `{"on": [...]}` for user-friendly behavior.
222
+ if "on" not in params and True in params:
223
+ params["on"] = params.pop(True)
224
+
225
+ if "right" in params:
226
+ r = params.get("right")
227
+ if isinstance(r, str):
228
+ params["right"] = _norm_path(r, base_dir=base_dir)
229
+ elif isinstance(r, dict):
230
+ r2: Dict[str, Any] = dict(r)
231
+ ru = r2.get("uri")
232
+ if isinstance(ru, str):
233
+ r2["uri"] = _norm_path(ru, base_dir=base_dir)
234
+ if "options" in r2 and r2["options"] is None:
235
+ r2["options"] = {}
236
+ params["right"] = r2
237
+
238
+ # Cast: in YAML, unquoted `null` parses to None. Accept it as the "null" policy.
239
+ if t2.get("op") == "cast" and isinstance(params, dict):
240
+ if "on_error" in params and params.get("on_error") is None:
241
+ params["on_error"] = "null"
242
+
243
+ norm_steps.append({"transform": t2})
244
+ continue
245
+
246
+ raise WowDataUserError(
247
+ "E_IR_STEP",
248
+ f"IR step #{i} must be 'transform' or 'sink'.",
249
+ hint="Example: {transform: {op: select, params: {...}}}",
250
+ )
251
+
252
+ pipe2["steps"] = norm_steps
253
+
254
+ return {"wowdata": 0, "pipeline": pipe2}
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ from typing import Optional, Dict, Any
5
+
6
+ from wowdata.errors import WowDataUserError
7
+
8
+ try:
9
+ from frictionless import Resource, Detector
10
+ except Exception: # pragma: no cover
11
+ Resource = None
12
+ Detector = None
13
+
14
+
15
+ def _is_probably_url(s: str) -> bool:
16
+ return s.startswith("http://") or s.startswith("https://") or s.startswith("s3://")
17
+
18
+
19
+ def _norm_path(p: str, *, base_dir: Optional[Path]) -> str:
20
+ """Normalize a URI/path relative to a base directory (when provided).
21
+
22
+ - Leaves absolute paths and URLs unchanged.
23
+ - If base_dir is provided and p is relative, returns an absolute resolved path.
24
+ """
25
+ if not isinstance(p, str) or not p:
26
+ return p
27
+ if _is_probably_url(p):
28
+ return p
29
+ try:
30
+ pp = Path(p)
31
+ except Exception:
32
+ return p
33
+ if pp.is_absolute():
34
+ return str(pp)
35
+ if base_dir is None:
36
+ return p
37
+ return str((base_dir / pp).resolve())
38
+
39
+
40
+ def _infer_type_from_uri(uri: str) -> Optional[str]:
41
+ ext = Path(uri).suffix.lower()
42
+ if ext == ".csv":
43
+ return "csv"
44
+ # todo: extend later: .xlsx, .parquet, db urls, s3://, http(s)://, etc.
45
+ return None
46
+
47
+
48
+ FrictionlessSchema = Dict[str, Any]
49
+
50
+
51
+ def _normalize_inline_schema(schema: Dict[str, Any]) -> Dict[str, Any]:
52
+ """
53
+ Expect frictionless-ish schema:
54
+ {"fields":[{"name":"age","type":"integer"}, ...]}
55
+ We keep it permissive for now.
56
+ """
57
+ if not isinstance(schema, dict):
58
+ raise WowDataUserError(
59
+ "E_SCHEMA_INLINE_TYPE",
60
+ "Inline schema must be a mapping (dict).",
61
+ hint="Example: {'fields': [{'name': 'age', 'type': 'integer'}]}",
62
+ )
63
+ if "fields" not in schema:
64
+ # allow passing full frictionless resource descriptor later; for now keep simple
65
+ return {"fields": []}
66
+ if not isinstance(schema["fields"], list):
67
+ raise WowDataUserError(
68
+ "E_SCHEMA_INLINE_FIELDS",
69
+ "Inline schema['fields'] must be a list.",
70
+ hint="Example: {'fields': [{'name': 'age', 'type': 'integer'}]}",
71
+ )
72
+ return schema
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: wowdata
3
+ Version: 0.1.0
4
+ Summary: A human-centred, teachable data wrangling and pipeline framework.
5
+ Author: WowData Contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/sci2pro/wowdata
8
+ Project-URL: Repository, https://github.com/sci2pro/wowdata
9
+ Project-URL: Issues, https://github.com/sci2pro/wowdata/issues
10
+ Keywords: data-engineering,etl,data-pipelines,education,data-wrangling
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: petl>=1.7
25
+ Requires-Dist: frictionless>=5.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-cov; extra == "dev"
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: mypy; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: mkdocs; extra == "docs"
34
+ Requires-Dist: mkdocs-material; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # WowData™
38
+
39
+ WowData™ is a human-centred data wrangling and pipeline framework designed to make real-world data cleanup understandable, teachable, and inspectable.
40
+
41
+ ## Install
42
+
43
+ From PyPI:
44
+
45
+ ```bash
46
+ pip install wowdata
47
+ ```
48
+
49
+ From source (editable):
50
+
51
+ ```bash
52
+ git clone https://github.com/sci2pro/wowdata.git
53
+ cd wowdata
54
+ pip install -e .
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ Create a small input CSV:
60
+
61
+ ```csv
62
+ person_id,age,country
63
+ 1,30,KE
64
+ 2,17,UG
65
+ 3,41,KE
66
+ ```
67
+
68
+ Run with Python API:
69
+
70
+ ```python
71
+ from wowdata import Pipeline, Sink, Source, Transform
72
+
73
+ pipe = (
74
+ Pipeline(Source("people.csv"))
75
+ .then(Transform("cast", params={"types": {"age": "integer"}, "on_error": "null"}))
76
+ .then(Transform("filter", params={"where": "age >= 18 and country == 'KE'"}))
77
+ .then(Sink("adults_ke.csv"))
78
+ )
79
+
80
+ pipe.run()
81
+ ```
82
+
83
+ Run from YAML with CLI:
84
+
85
+ ```bash
86
+ wow run pipeline.yaml
87
+ ```
88
+
89
+ Fallback command if `wow` conflicts in your shell:
90
+
91
+ ```bash
92
+ wowdata run pipeline.yaml
93
+ ```
94
+
95
+ ## Documentation
96
+
97
+ - Philosophy: [docs/philosophy.md](docs/philosophy.md)
98
+ - Examples: [EXAMPLES.md](EXAMPLES.md)
99
+ - Reference: [REFERENCE.md](REFERENCE.md)
100
+ - Docs site source: [docs/](docs/) + [mkdocs.yml](mkdocs.yml)
101
+
102
+ To preview docs locally:
103
+
104
+ ```bash
105
+ pip install -e .[docs]
106
+ mkdocs serve
107
+ ```
108
+
109
+ The same docs can be published to GitHub Pages (for `wowdata.github.io`).
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ wowdata/__init__.py
5
+ wowdata/cli.py
6
+ wowdata/errors.py
7
+ wowdata/schema.py
8
+ wowdata/util.py
9
+ wowdata.egg-info/PKG-INFO
10
+ wowdata.egg-info/SOURCES.txt
11
+ wowdata.egg-info/dependency_links.txt
12
+ wowdata.egg-info/entry_points.txt
13
+ wowdata.egg-info/requires.txt
14
+ wowdata.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ wow = wowdata.cli:main
3
+ wowdata = wowdata.cli:main
@@ -0,0 +1,13 @@
1
+ petl>=1.7
2
+ frictionless>=5.0
3
+
4
+ [dev]
5
+ pytest>=7.0
6
+ pytest-cov
7
+ black
8
+ ruff
9
+ mypy
10
+
11
+ [docs]
12
+ mkdocs
13
+ mkdocs-material
@@ -0,0 +1 @@
1
+ wowdata