jc-etlforge 0.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.
- jc_etlforge-0.7.0/LICENSE +21 -0
- jc_etlforge-0.7.0/PKG-INFO +603 -0
- jc_etlforge-0.7.0/README.md +567 -0
- jc_etlforge-0.7.0/pyproject.toml +87 -0
- jc_etlforge-0.7.0/setup.cfg +4 -0
- jc_etlforge-0.7.0/src/jc_etlforge/__init__.py +84 -0
- jc_etlforge-0.7.0/src/jc_etlforge/__main__.py +8 -0
- jc_etlforge-0.7.0/src/jc_etlforge/cli.py +183 -0
- jc_etlforge-0.7.0/src/jc_etlforge/components/__init__.py +43 -0
- jc_etlforge-0.7.0/src/jc_etlforge/components/sinks.py +217 -0
- jc_etlforge-0.7.0/src/jc_etlforge/components/sources.py +163 -0
- jc_etlforge-0.7.0/src/jc_etlforge/components/transformers.py +131 -0
- jc_etlforge-0.7.0/src/jc_etlforge/config.py +63 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/__init__.py +42 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/base.py +93 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/context.py +63 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/engine/__init__.py +28 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/engine/base.py +61 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/engine/process.py +53 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/engine/retry.py +76 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/engine/thread.py +46 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/exceptions.py +38 -0
- jc_etlforge-0.7.0/src/jc_etlforge/core/pipeline.py +343 -0
- jc_etlforge-0.7.0/src/jc_etlforge/plugins/__init__.py +33 -0
- jc_etlforge-0.7.0/src/jc_etlforge/plugins/loader.py +125 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/PKG-INFO +603 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/SOURCES.txt +41 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/dependency_links.txt +1 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/entry_points.txt +2 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/requires.txt +10 -0
- jc_etlforge-0.7.0/src/jc_etlforge.egg-info/top_level.txt +1 -0
- jc_etlforge-0.7.0/tests/test_cli.py +226 -0
- jc_etlforge-0.7.0/tests/test_context.py +33 -0
- jc_etlforge-0.7.0/tests/test_end_to_end.py +88 -0
- jc_etlforge-0.7.0/tests/test_engine_process.py +31 -0
- jc_etlforge-0.7.0/tests/test_engine_thread.py +33 -0
- jc_etlforge-0.7.0/tests/test_pipeline.py +197 -0
- jc_etlforge-0.7.0/tests/test_plugins.py +98 -0
- jc_etlforge-0.7.0/tests/test_retry.py +53 -0
- jc_etlforge-0.7.0/tests/test_sinks.py +96 -0
- jc_etlforge-0.7.0/tests/test_smoke.py +27 -0
- jc_etlforge-0.7.0/tests/test_sources.py +70 -0
- jc_etlforge-0.7.0/tests/test_transformers.py +74 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jacivaldo Carvalho
|
|
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,603 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jc-etlforge
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: A minimalist, plugin-driven ETL framework with declarative pipelines, concurrency, and CLI support.
|
|
5
|
+
Author-email: Jacivaldo Carvalho <jacivaldocarvalho@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jacivaldocarvalho/jc-etlforge
|
|
8
|
+
Project-URL: Repository, https://github.com/jacivaldocarvalho/jc-etlforge
|
|
9
|
+
Project-URL: Issues, https://github.com/jacivaldocarvalho/jc-etlforge/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/jacivaldocarvalho/jc-etlforge/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Documentation, https://github.com/jacivaldocarvalho/jc-etlforge/tree/main/docs
|
|
12
|
+
Keywords: etl,pipeline,data-engineering,framework,plugins,cli
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
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
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: click>=8.1
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.1; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
32
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
33
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# JC Etlforge
|
|
38
|
+
|
|
39
|
+
[](https://github.com/jacivaldocarvalho/jc-etlforge/actions/workflows/ci.yml)
|
|
40
|
+
[](https://pypi.org/project/jc-etlforge/)
|
|
41
|
+
[](https://www.python.org/)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
A **minimalist, plugin-driven ETL framework** for Python with declarative
|
|
46
|
+
pipelines, concurrency, and a first-class CLI.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install jc-etlforge
|
|
50
|
+
jc-etlforge run pipeline.yaml
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`jc-etlforge` is the **pytest of ETL**: small, composable, extensible, and
|
|
54
|
+
installable from PyPI. It does not try to be Airflow — it tries to replace
|
|
55
|
+
the ad-hoc Python script that copies data from one place to another.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Table of contents
|
|
60
|
+
|
|
61
|
+
- [JC Etlforge](#jc-etlforge)
|
|
62
|
+
- [Table of contents](#table-of-contents)
|
|
63
|
+
- [Why jc-etlforge](#why-jc-etlforge)
|
|
64
|
+
- [Install](#install)
|
|
65
|
+
- [Quickstart](#quickstart)
|
|
66
|
+
- [How it works](#how-it-works)
|
|
67
|
+
- [Layers](#layers)
|
|
68
|
+
- [Data flow](#data-flow)
|
|
69
|
+
- [Execution model](#execution-model)
|
|
70
|
+
- [Built-in components](#built-in-components)
|
|
71
|
+
- [Sources](#sources)
|
|
72
|
+
- [Transformers](#transformers)
|
|
73
|
+
- [Sinks](#sinks)
|
|
74
|
+
- [Pipeline config](#pipeline-config)
|
|
75
|
+
- [Format conversion is just a config choice](#format-conversion-is-just-a-config-choice)
|
|
76
|
+
- [CLI reference](#cli-reference)
|
|
77
|
+
- [Exit codes](#exit-codes)
|
|
78
|
+
- [Plugins](#plugins)
|
|
79
|
+
- [Where to use it](#where-to-use-it)
|
|
80
|
+
- [Legacy data migration](#legacy-data-migration)
|
|
81
|
+
- [SaaS integration](#saas-integration)
|
|
82
|
+
- [CI/CD data pipelines](#cicd-data-pipelines)
|
|
83
|
+
- [Spreadsheet cleanup](#spreadsheet-cleanup)
|
|
84
|
+
- [Plugin ecosystem](#plugin-ecosystem)
|
|
85
|
+
- [Design decisions](#design-decisions)
|
|
86
|
+
- [Development](#development)
|
|
87
|
+
- [Roadmap](#roadmap)
|
|
88
|
+
- [License](#license)
|
|
89
|
+
- [Author](#author)
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Why jc-etlforge
|
|
94
|
+
|
|
95
|
+
Most ETL tools are either **too heavy** (full platforms with scheduler,
|
|
96
|
+
UI, and database) or **too ad-hoc** (one-off scripts that each reimplement
|
|
97
|
+
parsing, retry, logging, and tests).
|
|
98
|
+
|
|
99
|
+
`jc-etlforge` sits in the sweet spot: a **small, declarative framework**
|
|
100
|
+
built around four primitives:
|
|
101
|
+
|
|
102
|
+
- **Source** — where data comes from (JSON, CSV, positional files, …).
|
|
103
|
+
- **Transformer** — how data is reshaped (regex, rename, filter, …).
|
|
104
|
+
- **Sink** — where data goes (JSON, CSV, positional files, …).
|
|
105
|
+
- **Pipeline** — a chain that wires sources, transformers, and sinks.
|
|
106
|
+
|
|
107
|
+
Pipelines are declared in **YAML or JSON**, executed by pluggable engines
|
|
108
|
+
(**threaded** or **multiprocessing**), and extended through **entry-point
|
|
109
|
+
plugins** — no forks required.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Install
|
|
114
|
+
|
|
115
|
+
Requires **Python 3.10+**.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pip install jc-etlforge
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Verify:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
jc-etlforge --version
|
|
125
|
+
jc-etlforge info
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For development, see [Development](#development).
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Quickstart
|
|
133
|
+
|
|
134
|
+
Create `data/in.json`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
[
|
|
138
|
+
{"id": 1, "name": "Alice", "email": "alice@example.com"},
|
|
139
|
+
{"id": 2, "name": "Bob", "email": "bob@example.com"},
|
|
140
|
+
{"id": 3, "name": "Carol", "email": "carol@example.com"}
|
|
141
|
+
]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Create `pipeline.yaml`:
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
name: quickstart
|
|
148
|
+
source:
|
|
149
|
+
type: JsonSource
|
|
150
|
+
path: data/in.json
|
|
151
|
+
transformers:
|
|
152
|
+
- type: RegexTransformer
|
|
153
|
+
field: email
|
|
154
|
+
pattern: "@example\\.com$"
|
|
155
|
+
replacement: "@example.org"
|
|
156
|
+
sink:
|
|
157
|
+
type: CsvSink
|
|
158
|
+
path: output/out.csv
|
|
159
|
+
fields: [id, name, email]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Validate and run:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
jc-etlforge validate pipeline.yaml
|
|
166
|
+
jc-etlforge run pipeline.yaml
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Output:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
INFO jc_etlforge: pipeline quickstart starting (executor=thread, workers=1, retries=1)
|
|
173
|
+
INFO jc_etlforge: pipeline quickstart finished in 0.001s: {'rows.read': 3, 'rows.written': 3, 'rows.transformed': 3}
|
|
174
|
+
pipeline 'quickstart' finished in 0.001s
|
|
175
|
+
rows.read: 3
|
|
176
|
+
rows.transformed: 3
|
|
177
|
+
rows.written: 3
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`output/out.csv`:
|
|
181
|
+
|
|
182
|
+
```csv
|
|
183
|
+
id,name,email
|
|
184
|
+
1,Alice,alice@example.org
|
|
185
|
+
2,Bob,bob@example.org
|
|
186
|
+
3,Carol,carol@example.org
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
That's it. No Python code, no `if __name__ == "__main__"`, no retry
|
|
190
|
+
boilerplate.
|
|
191
|
+
|
|
192
|
+

|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## How it works
|
|
197
|
+
|
|
198
|
+
### Layers
|
|
199
|
+
|
|
200
|
+
```mermaid
|
|
201
|
+
flowchart TB
|
|
202
|
+
subgraph CLI["CLI"]
|
|
203
|
+
info["info"]
|
|
204
|
+
validate["validate"]
|
|
205
|
+
run["run"]
|
|
206
|
+
plugins["plugins list"]
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
subgraph Config["Config"]
|
|
210
|
+
load["load_config\n(YAML/JSON → dict)"]
|
|
211
|
+
from_config["Pipeline.from_config\n(dict → Pipeline)"]
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
subgraph Core["Core"]
|
|
215
|
+
pipeline["Pipeline\n(Source → Transformer… → Sink)"]
|
|
216
|
+
context["PipelineContext\n(logger, metrics, config)"]
|
|
217
|
+
executor["Executor\n(thread | process | sequential)"]
|
|
218
|
+
retry["with_retry\n(exponential backoff)"]
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
subgraph Components["Built-in components"]
|
|
222
|
+
sources["Sources: JsonSource,\nCsvSource, PositionalFileSource"]
|
|
223
|
+
transformers["Transformers: RegexTransformer,\nRenameTransformer, FilterTransformer"]
|
|
224
|
+
sinks["Sinks: JsonSink,\nCsvSink, PositionalFileSink"]
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
subgraph Plugins["Plugins (entry points)"]
|
|
228
|
+
third_party["jc_etlforge.transformers\n(third-party packages)"]
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
info --> Core
|
|
232
|
+
validate --> Config
|
|
233
|
+
run --> Config
|
|
234
|
+
plugins --> Plugins
|
|
235
|
+
load --> from_config
|
|
236
|
+
from_config --> pipeline
|
|
237
|
+
pipeline --> context
|
|
238
|
+
pipeline --> executor
|
|
239
|
+
executor --> retry
|
|
240
|
+
pipeline --> sources
|
|
241
|
+
pipeline --> transformers
|
|
242
|
+
pipeline --> sinks
|
|
243
|
+
from_config -.->|resolve type| Components
|
|
244
|
+
from_config -.->|resolve type| Plugins
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The **CLI** is a thin shell: it parses arguments, loads config, and
|
|
248
|
+
delegates to the core. The **core** is engine-agnostic: it wires a
|
|
249
|
+
`Source`, zero or more `Transformer`s, and a `Sink`, and lets an
|
|
250
|
+
`Executor` decide how to fan out `process` calls.
|
|
251
|
+
|
|
252
|
+
### Data flow
|
|
253
|
+
|
|
254
|
+
A pipeline is a **lazy stream** of `dict[str, Any]` records. Nothing is
|
|
255
|
+
read until the sink pulls; each transformer yields records one at a time.
|
|
256
|
+
Memory usage is bounded by the largest single record, not by the input
|
|
257
|
+
size.
|
|
258
|
+
|
|
259
|
+
```mermaid
|
|
260
|
+
sequenceDiagram
|
|
261
|
+
participant CLI
|
|
262
|
+
participant Pipeline
|
|
263
|
+
participant Source
|
|
264
|
+
participant Transformer
|
|
265
|
+
participant Sink
|
|
266
|
+
participant Context
|
|
267
|
+
|
|
268
|
+
CLI->>Pipeline: from_config(dict)
|
|
269
|
+
CLI->>Context: __enter__()
|
|
270
|
+
CLI->>Pipeline: run(ctx, executor, workers, retries)
|
|
271
|
+
Pipeline->>Source: read(ctx)
|
|
272
|
+
loop for each record
|
|
273
|
+
Source-->>Pipeline: record
|
|
274
|
+
Pipeline->>Transformer: process(record, ctx)
|
|
275
|
+
Transformer-->>Pipeline: transformed | None | list
|
|
276
|
+
Pipeline->>Context: record("rows.transformed")
|
|
277
|
+
end
|
|
278
|
+
Pipeline->>Sink: write(record, ctx)
|
|
279
|
+
Sink-->>Pipeline: None
|
|
280
|
+
Pipeline->>Context: record("rows.written")
|
|
281
|
+
CLI->>Context: __exit__()
|
|
282
|
+
CLI-->>CLI: print metrics
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Execution model
|
|
286
|
+
|
|
287
|
+
`Pipeline.run` accepts three knobs:
|
|
288
|
+
|
|
289
|
+
| Knob | Default | Effect |
|
|
290
|
+
|------|---------|--------|
|
|
291
|
+
| `executor` | `"thread"` | `"thread"` uses `ThreadPoolExecutor`; `"process"` uses `ProcessPoolExecutor`. |
|
|
292
|
+
| `max_workers` | `1` | `1` runs sequentially (no pool overhead); `>1` fans out `transformer.process` across workers. |
|
|
293
|
+
| `retries` | `1` | Total attempts per record when `process` raises. `1` means "no retry". |
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Sequential (default)
|
|
297
|
+
jc-etlforge run pipeline.yaml
|
|
298
|
+
|
|
299
|
+
# 4 threads (I/O-bound transformers)
|
|
300
|
+
jc-etlforge run pipeline.yaml --workers 4
|
|
301
|
+
|
|
302
|
+
# 4 processes (CPU-bound transformers)
|
|
303
|
+
jc-etlforge run pipeline.yaml --executor process --workers 4
|
|
304
|
+
|
|
305
|
+
# Retry up to 3 times with 0.5s base backoff
|
|
306
|
+
jc-etlforge run pipeline.yaml --retries 3 --retry-backoff 0.5
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Metrics (`rows.read`, `rows.transformed`, `rows.written`, `rows.filtered`,
|
|
310
|
+
`rows.failed`) are counted in the **parent** process, so they are accurate
|
|
311
|
+
even with `--executor process`.
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Built-in components
|
|
316
|
+
|
|
317
|
+
### Sources
|
|
318
|
+
|
|
319
|
+
| Class | Reads | Args |
|
|
320
|
+
|-------|-------|------|
|
|
321
|
+
| `JsonSource` | JSON array or wrapped object | `path`, `records_key`, `encoding` |
|
|
322
|
+
| `CsvSource` | CSV with header | `path`, `delimiter`, `encoding` |
|
|
323
|
+
| `PositionalFileSource` | Fixed-width text | `path`, `layout`, `encoding`, `skip_blank_lines` |
|
|
324
|
+
|
|
325
|
+
### Transformers
|
|
326
|
+
|
|
327
|
+
| Class | Does | Args |
|
|
328
|
+
|-------|------|------|
|
|
329
|
+
| `RegexTransformer` | Regex substitution on one or more fields | `field`, `pattern`, `replacement`, `flags`, `missing` |
|
|
330
|
+
| `RenameTransformer` | Rename fields via mapping | `mapping` |
|
|
331
|
+
| `FilterTransformer` | Keep records matching a predicate | `field`, `op` (`eq`/`ne`/`in`/`not_in`/`regex`/`not_regex`), `value` |
|
|
332
|
+
|
|
333
|
+
### Sinks
|
|
334
|
+
|
|
335
|
+
| Class | Writes | Args |
|
|
336
|
+
|-------|--------|------|
|
|
337
|
+
| `JsonSink` | JSON array (pretty-printed) | `path`, `encoding` |
|
|
338
|
+
| `CsvSink` | CSV with header | `path`, `fields`, `delimiter`, `encoding` |
|
|
339
|
+
| `PositionalFileSink` | Fixed-width text | `path`, `layout`, `encoding` |
|
|
340
|
+
|
|
341
|
+
`PositionalFileSink` accepts a `layout` of either plain `(start, end)`
|
|
342
|
+
tuples (space-padded, left-aligned) or `FieldSpec(start, end, align, fill)`
|
|
343
|
+
for zero-padding and right-alignment:
|
|
344
|
+
|
|
345
|
+
```yaml
|
|
346
|
+
layout:
|
|
347
|
+
id: {start: 0, end: 5, align: right, fill: "0"} # → "00001"
|
|
348
|
+
name: {start: 5, end: 15, align: left, fill: " "} # → "Alice "
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Pipeline config
|
|
354
|
+
|
|
355
|
+
A pipeline is a YAML or JSON file with **`source`**, optional
|
|
356
|
+
**`transformers`**, and **`sink`**. Each is a mapping with a `type` key
|
|
357
|
+
(resolved against built-in components, then plugins) and constructor
|
|
358
|
+
kwargs.
|
|
359
|
+
|
|
360
|
+
```yaml
|
|
361
|
+
name: my-pipeline # optional, defaults to "pipeline"
|
|
362
|
+
source:
|
|
363
|
+
type: JsonSource
|
|
364
|
+
path: data/in.json
|
|
365
|
+
transformers:
|
|
366
|
+
- type: FilterTransformer
|
|
367
|
+
field: status
|
|
368
|
+
op: eq
|
|
369
|
+
value: active
|
|
370
|
+
- type: RenameTransformer
|
|
371
|
+
mapping:
|
|
372
|
+
full_name: name
|
|
373
|
+
sink:
|
|
374
|
+
type: CsvSink
|
|
375
|
+
path: output/out.csv
|
|
376
|
+
fields: [id, name, email]
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
`jc-etlforge validate pipeline.yaml` parses and validates the config
|
|
380
|
+
**without executing** — useful in CI to catch bad configs before they run.
|
|
381
|
+
|
|
382
|
+
### Format conversion is just a config choice
|
|
383
|
+
|
|
384
|
+
Because every component speaks `dict[str, Any]`, any combination works:
|
|
385
|
+
|
|
386
|
+
| From → To | Source | Transformers | Sink |
|
|
387
|
+
|-----------|--------|--------------|------|
|
|
388
|
+
| JSON → CSV | `JsonSource` | (optional) | `CsvSink` |
|
|
389
|
+
| CSV → JSON | `CsvSource` | (optional) | `JsonSink` |
|
|
390
|
+
| CSV → CSV (clean) | `CsvSource` | `Filter`/`Rename`/`Regex` | `CsvSink` |
|
|
391
|
+
| JSON → JSON (clean) | `JsonSource` | `Filter`/`Rename`/`Regex` | `JsonSink` |
|
|
392
|
+
| Positional → CSV | `PositionalFileSource` | (optional) | `CsvSink` |
|
|
393
|
+
| CSV → Positional | `CsvSource` | (optional) | `PositionalFileSink` |
|
|
394
|
+
|
|
395
|
+
> **Note on types:** `CsvSource` reads every value as a string (that is
|
|
396
|
+
> what `csv.DictReader` does). If you need `id` as an integer in the
|
|
397
|
+
> output JSON, add a `CastTransformer` (see
|
|
398
|
+
> [`examples/plugins/`](examples/plugins/)).
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## CLI reference
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
jc-etlforge [OPTIONS] COMMAND [ARGS]...
|
|
406
|
+
|
|
407
|
+
Commands:
|
|
408
|
+
info Print version and environment info.
|
|
409
|
+
run Execute a pipeline from a YAML/JSON config.
|
|
410
|
+
validate Validate a config without executing it.
|
|
411
|
+
plugins list List transformers discovered via entry points.
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Exit codes
|
|
415
|
+
|
|
416
|
+
| Code | Meaning |
|
|
417
|
+
|------|---------|
|
|
418
|
+
| 0 | Success |
|
|
419
|
+
| 1 | Unmapped exception (bug — please report) |
|
|
420
|
+
| 2 | CLI usage error (reserved by `click`) |
|
|
421
|
+
| 3 | `ConfigurationError` — bad config file or unknown component |
|
|
422
|
+
| 4 | `PipelineError` / `ExecutionError` — pipeline failed |
|
|
423
|
+
| 5 | `PluginError` — plugin failed to load or validate |
|
|
424
|
+
|
|
425
|
+
Scripts can branch on these:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
jc-etlforge run pipeline.yaml
|
|
429
|
+
case $? in
|
|
430
|
+
0) echo "ok" ;;
|
|
431
|
+
3) echo "fix your config" >&2; exit 1 ;;
|
|
432
|
+
4) echo "pipeline failed" >&2; exit 2 ;;
|
|
433
|
+
*) echo "unexpected: $?" >&2; exit 3 ;;
|
|
434
|
+
esac
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Plugins
|
|
440
|
+
|
|
441
|
+
Third parties extend `jc-etlforge` by publishing a package that declares
|
|
442
|
+
an entry point under `jc_etlforge.transformers`:
|
|
443
|
+
|
|
444
|
+
```toml
|
|
445
|
+
[project.entry-points."jc_etlforge.transformers"]
|
|
446
|
+
titlecase = "my_pkg:TitleCaseTransformer"
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
After `pip install my-pkg`, the transformer is available by name in any
|
|
450
|
+
pipeline config:
|
|
451
|
+
|
|
452
|
+
```yaml
|
|
453
|
+
transformers:
|
|
454
|
+
- type: titlecase
|
|
455
|
+
field: name
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
List discovered plugins:
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
jc-etlforge plugins list
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
See [`examples/plugins/`](examples/plugins/) for a full working example
|
|
465
|
+
(`TitleCaseTransformer` and `CastTransformer`).
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Where to use it
|
|
470
|
+
|
|
471
|
+
### Legacy data migration
|
|
472
|
+
|
|
473
|
+
```mermaid
|
|
474
|
+
flowchart LR
|
|
475
|
+
mainframe["Mainframe\n(EBCDIC, fixed-width)"] --> src["PositionalFileSource"]
|
|
476
|
+
src --> regex["RegexTransformer\n(trim padding)"]
|
|
477
|
+
regex --> sink["JsonSink / CsvSink"]
|
|
478
|
+
sink --> cloud["Cloud warehouse"]
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
A 30-year-old Cobol export becomes a versioned `pipeline.yaml` per layout,
|
|
482
|
+
testable with `jc-etlforge validate` in CI.
|
|
483
|
+
|
|
484
|
+
### SaaS integration
|
|
485
|
+
|
|
486
|
+
```mermaid
|
|
487
|
+
flowchart LR
|
|
488
|
+
stripe["Stripe API"] --> p1["Plugin: StripeSource"]
|
|
489
|
+
zendesk["Zendesk API"] --> p2["Plugin: ZendeskSource"]
|
|
490
|
+
p1 --> merge["Merge / filter"]
|
|
491
|
+
p2 --> merge
|
|
492
|
+
merge --> sink["CsvSink / JsonSink"]
|
|
493
|
+
sink --> bi["BI dashboard"]
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Two 30-line plugins + one YAML file. Runs on a $5/month VPS on a cron.
|
|
497
|
+
|
|
498
|
+
### CI/CD data pipelines
|
|
499
|
+
|
|
500
|
+
```mermaid
|
|
501
|
+
flowchart LR
|
|
502
|
+
cron["GitHub Actions\n(scheduled)"] --> validate["jc-etlforge validate"]
|
|
503
|
+
validate -->|valid| run["jc-etlforge run"]
|
|
504
|
+
validate -->|invalid| fail["fail the build"]
|
|
505
|
+
run --> s3["S3 (CSV)"] --> filter["FilterTransformer"] --> pg["Postgres"]
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
`validate` in CI catches broken configs **before** the cron runs;
|
|
509
|
+
`--executor process` uses all cores of the runner.
|
|
510
|
+
|
|
511
|
+
### Spreadsheet cleanup
|
|
512
|
+
|
|
513
|
+
```mermaid
|
|
514
|
+
flowchart LR
|
|
515
|
+
xlsx["clientes.xlsx\n(exported CSV)"] --> src["CsvSource"]
|
|
516
|
+
src --> filter["FilterTransformer\n(valid CPF)"]
|
|
517
|
+
filter --> rename["RenameTransformer\n(standard columns)"]
|
|
518
|
+
rename --> regex["RegexTransformer\n(strip phone)"]
|
|
519
|
+
regex --> sink["CsvSink"]
|
|
520
|
+
sink --> clean["clientes_limpos.csv"]
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
The monthly spreadsheet cleanup becomes a reusable YAML file, run in
|
|
524
|
+
seconds instead of hours.
|
|
525
|
+
|
|
526
|
+
### Plugin ecosystem
|
|
527
|
+
|
|
528
|
+
```mermaid
|
|
529
|
+
flowchart TB
|
|
530
|
+
core["jc-etlforge (core)"]
|
|
531
|
+
core --> salesforce["jc-etlforge-salesforce"]
|
|
532
|
+
core --> snowflake["jc-etlforge-snowflake"]
|
|
533
|
+
core --> kafka["jc-etlforge-kafka"]
|
|
534
|
+
core --> excel["jc-etlforge-excel"]
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
The same model that made `pytest` and `mkdocs` ecosystems: a small core
|
|
538
|
+
plus many focused extensions.
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## Design decisions
|
|
543
|
+
|
|
544
|
+
Architectural decisions are recorded as
|
|
545
|
+
[ADRs](docs/adr/README.md):
|
|
546
|
+
|
|
547
|
+
| ID | Decision |
|
|
548
|
+
|----|----------|
|
|
549
|
+
| [0001](docs/adr/0001-use-modern-typing-and-python-310.md) | Use modern typing and Python 3.10+ |
|
|
550
|
+
| [0002](docs/adr/0002-pipeline-context-and-metrics.md) | PipelineContext and metrics |
|
|
551
|
+
| [0003](docs/adr/0003-executor-abstraction-and-pickling.md) | Executor abstraction and pickling |
|
|
552
|
+
| [0004](docs/adr/0004-plugin-system-via-entry-points.md) | Plugin system via entry points |
|
|
553
|
+
| [0005](docs/adr/0005-config-format-and-exit-codes.md) | Config format and exit codes |
|
|
554
|
+
|
|
555
|
+
See [`docs/architecture.md`](docs/architecture.md) for the full layered
|
|
556
|
+
architecture and data flow.
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## Development
|
|
561
|
+
|
|
562
|
+
```bash
|
|
563
|
+
git clone https://github.com/jacivaldocarvalho/jc-etlforge.git
|
|
564
|
+
cd jc-etlforge
|
|
565
|
+
python -m venv .venv
|
|
566
|
+
source .venv/bin/activate
|
|
567
|
+
make install # editable install with dev extras
|
|
568
|
+
make check # ruff + pytest (what CI runs)
|
|
569
|
+
make build # sdist + wheel + twine check
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
See the [`Makefile`](Makefile) for the full task list (`make help`).
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## Roadmap
|
|
577
|
+
|
|
578
|
+
| Version | Status | Highlights |
|
|
579
|
+
|---------|--------|------------|
|
|
580
|
+
| 0.1–0.6 | ✅ | Core, components, executors, plugins, CLI |
|
|
581
|
+
| 0.7 | 🚧 | Docs, ADRs, `examples/plugins/`, PyPI release |
|
|
582
|
+
| 1.0 | 📋 | API freeze, `CastTransformer` built-in, async executor |
|
|
583
|
+
| 1.x | 📋 | DAG pipelines, aggregate transformers, DB/API sources |
|
|
584
|
+
|
|
585
|
+
Roadmap items are not commitments — they are directions. See
|
|
586
|
+
[issues](https://github.com/jacivaldocarvalho/jc-etlforge/issues) for
|
|
587
|
+
the live list.
|
|
588
|
+
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## License
|
|
592
|
+
|
|
593
|
+
MIT — see [LICENSE](LICENSE).
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
## Author
|
|
598
|
+
|
|
599
|
+
**Jacivaldo Carvalho**
|
|
600
|
+
|
|
601
|
+
Telecommunications Engineer | DevOps Engineer | SRE | Networking
|
|
602
|
+
|
|
603
|
+
[GitHub](https://github.com/jacivaldocarvalho) | [LinkedIn](https://www.linkedin.com/in/jacivaldocarvalho) | [Website](https://www.jacivaldocarvalho.com/)
|