tha-map-runner 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,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ python-version: ["3.10", "3.11", "3.12"]
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v4
20
+ with:
21
+ version: "latest"
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ run: uv python install ${{ matrix.python-version }}
25
+
26
+ - name: Install dependencies
27
+ run: uv sync --extra dev --python ${{ matrix.python-version }}
28
+
29
+ - name: Lint
30
+ run: uv run ruff check src/ tests/
31
+
32
+ - name: Test
33
+ run: uv run pytest
34
+
35
+ - name: Type check
36
+ run: uv run mypy src/
@@ -0,0 +1,58 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v4
16
+
17
+ - name: Build
18
+ run: uv build
19
+
20
+ - name: Upload dist
21
+ uses: actions/upload-artifact@v4
22
+ with:
23
+ name: dist
24
+ path: dist/
25
+
26
+ publish-testpypi:
27
+ needs: build
28
+ runs-on: ubuntu-latest
29
+ environment: testpypi
30
+ permissions:
31
+ id-token: write
32
+ steps:
33
+ - name: Download dist
34
+ uses: actions/download-artifact@v4
35
+ with:
36
+ name: dist
37
+ path: dist/
38
+
39
+ - name: Publish to TestPyPI
40
+ uses: pypa/gh-action-pypi-publish@release/v1
41
+ with:
42
+ repository-url: https://test.pypi.org/legacy/
43
+
44
+ publish-pypi:
45
+ needs: publish-testpypi
46
+ runs-on: ubuntu-latest
47
+ environment: pypi
48
+ permissions:
49
+ id-token: write
50
+ steps:
51
+ - name: Download dist
52
+ uses: actions/download-artifact@v4
53
+ with:
54
+ name: dist
55
+ path: dist/
56
+
57
+ - name: Publish to PyPI
58
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nathan Wright
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,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: tha-map-runner
3
+ Version: 0.1.0
4
+ Summary: Join JSON responses into CSV-style rows with dotted-path projection — a Tabular Helper API.
5
+ Project-URL: Homepage, https://github.com/tha-guy-nate/tha-map-runner
6
+ Project-URL: Issues, https://github.com/tha-guy-nate/tha-map-runner/issues
7
+ Author: Nate Wright
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.10
19
+ Provides-Extra: dev
20
+ Requires-Dist: mypy>=1.10; extra == 'dev'
21
+ Requires-Dist: pytest>=8; extra == 'dev'
22
+ Requires-Dist: ruff>=0.5; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # tha-map-runner
26
+
27
+ [![CI](https://github.com/tha-guy-nate/tha-map-runner/actions/workflows/ci.yml/badge.svg)](https://github.com/tha-guy-nate/tha-map-runner/actions/workflows/ci.yml)
28
+
29
+ A small Python library that joins a list of row dicts with a lookup source on a key, projecting values into flat row columns via a mapping config.
30
+
31
+ Think "left join between rows and a lookup source, with dotted-path projection on the source side."
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ pip install tha-map-runner
37
+ ```
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ from tha_map_runner import enrich_rows
43
+
44
+ rows = [
45
+ {"Org BK": "school-001", "Start Date": "08/15"},
46
+ {"Org BK": "school-002", "Start Date": "08/16"},
47
+ ]
48
+
49
+ api_response = [
50
+ {"sourcedId": "school-001", "name": "Lincoln Elementary", "parent": {"sourcedId": "dist-A"}},
51
+ {"sourcedId": "school-002", "name": "Roosevelt Middle", "parent": {"sourcedId": "dist-A"}},
52
+ ]
53
+
54
+ enriched = enrich_rows(
55
+ rows=rows,
56
+ source=api_response,
57
+ mapping={
58
+ "Org Name": "name",
59
+ "Parent BK": "parent.sourcedId",
60
+ },
61
+ row_key="Org BK",
62
+ source_key="sourcedId",
63
+ )
64
+ ```
65
+
66
+ ## How it works
67
+
68
+ 1. Builds an index of `source` on `source_key` — O(n+m), no nested loops
69
+ 2. For each row, looks up a match by `row[row_key]`
70
+ 3. Walks dotted paths (`"parent.sourcedId"`) into the matched source entry
71
+ 4. Projects resolved values into new columns on a copy of the row
72
+ 5. Returns a new list — input is never mutated
73
+
74
+ Rows whose `row status` is in `skip_statuses` are passed through unchanged.
75
+
76
+ ## API
77
+
78
+ ```python
79
+ enrich_rows(
80
+ rows, # list of row dicts
81
+ source, # list of dicts to join against
82
+ mapping, # {"output_column": "dotted.path"} — callable values planned
83
+ row_key, # column name in rows to match on
84
+ source_key, # field in source to match on
85
+ *,
86
+ on_no_match="skip", # "skip" | "error" | "blank"
87
+ allow_empty_source=False, # if True, empty source is not an error
88
+ skip_statuses=["error", "warning"],# rows with these statuses are passed through
89
+ ) -> list[dict]
90
+ ```
91
+
92
+ ### `on_no_match`
93
+
94
+ | Value | Behaviour |
95
+ |---|---|
96
+ | `"skip"` | Row is returned unchanged — no new columns added |
97
+ | `"error"` | `row status="error"`, `message=...`, mapping columns set to `""` |
98
+ | `"blank"` | Mapping columns set to `""`, row status untouched |
99
+
100
+ ### `skip_statuses`
101
+
102
+ By default, rows already marked `row status="error"` or `row status="warning"` are passed through without processing. Override with any list:
103
+
104
+ ```python
105
+ enrich_rows(..., skip_statuses=["error"]) # only skip errors
106
+ enrich_rows(..., skip_statuses=["error", "pending"]) # custom statuses
107
+ enrich_rows(..., skip_statuses=[]) # process every row regardless
108
+ ```
109
+
110
+ ### Composing with `tha-csv-runner`
111
+
112
+ ```python
113
+ from tha_csv_runner import ThaCSV
114
+ from tha_map_runner import enrich_rows
115
+ import requests
116
+
117
+ runner = ThaCSV()
118
+ runner.read("Step 1 of 2", "input.csv", ["Org BK"])
119
+
120
+ api_response = requests.get(api_url).json()
121
+
122
+ runner.rows = enrich_rows(
123
+ rows=runner.rows,
124
+ source=api_response,
125
+ mapping={"Org Name": "name", "District": "parent.sourcedId"},
126
+ row_key="Org BK",
127
+ source_key="sourcedId",
128
+ )
129
+
130
+ runner.write("Step 2 of 2", "output.csv")
131
+ ```
132
+
133
+ ## License
134
+
135
+ MIT
@@ -0,0 +1,111 @@
1
+ # tha-map-runner
2
+
3
+ [![CI](https://github.com/tha-guy-nate/tha-map-runner/actions/workflows/ci.yml/badge.svg)](https://github.com/tha-guy-nate/tha-map-runner/actions/workflows/ci.yml)
4
+
5
+ A small Python library that joins a list of row dicts with a lookup source on a key, projecting values into flat row columns via a mapping config.
6
+
7
+ Think "left join between rows and a lookup source, with dotted-path projection on the source side."
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install tha-map-runner
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ ```python
18
+ from tha_map_runner import enrich_rows
19
+
20
+ rows = [
21
+ {"Org BK": "school-001", "Start Date": "08/15"},
22
+ {"Org BK": "school-002", "Start Date": "08/16"},
23
+ ]
24
+
25
+ api_response = [
26
+ {"sourcedId": "school-001", "name": "Lincoln Elementary", "parent": {"sourcedId": "dist-A"}},
27
+ {"sourcedId": "school-002", "name": "Roosevelt Middle", "parent": {"sourcedId": "dist-A"}},
28
+ ]
29
+
30
+ enriched = enrich_rows(
31
+ rows=rows,
32
+ source=api_response,
33
+ mapping={
34
+ "Org Name": "name",
35
+ "Parent BK": "parent.sourcedId",
36
+ },
37
+ row_key="Org BK",
38
+ source_key="sourcedId",
39
+ )
40
+ ```
41
+
42
+ ## How it works
43
+
44
+ 1. Builds an index of `source` on `source_key` — O(n+m), no nested loops
45
+ 2. For each row, looks up a match by `row[row_key]`
46
+ 3. Walks dotted paths (`"parent.sourcedId"`) into the matched source entry
47
+ 4. Projects resolved values into new columns on a copy of the row
48
+ 5. Returns a new list — input is never mutated
49
+
50
+ Rows whose `row status` is in `skip_statuses` are passed through unchanged.
51
+
52
+ ## API
53
+
54
+ ```python
55
+ enrich_rows(
56
+ rows, # list of row dicts
57
+ source, # list of dicts to join against
58
+ mapping, # {"output_column": "dotted.path"} — callable values planned
59
+ row_key, # column name in rows to match on
60
+ source_key, # field in source to match on
61
+ *,
62
+ on_no_match="skip", # "skip" | "error" | "blank"
63
+ allow_empty_source=False, # if True, empty source is not an error
64
+ skip_statuses=["error", "warning"],# rows with these statuses are passed through
65
+ ) -> list[dict]
66
+ ```
67
+
68
+ ### `on_no_match`
69
+
70
+ | Value | Behaviour |
71
+ |---|---|
72
+ | `"skip"` | Row is returned unchanged — no new columns added |
73
+ | `"error"` | `row status="error"`, `message=...`, mapping columns set to `""` |
74
+ | `"blank"` | Mapping columns set to `""`, row status untouched |
75
+
76
+ ### `skip_statuses`
77
+
78
+ By default, rows already marked `row status="error"` or `row status="warning"` are passed through without processing. Override with any list:
79
+
80
+ ```python
81
+ enrich_rows(..., skip_statuses=["error"]) # only skip errors
82
+ enrich_rows(..., skip_statuses=["error", "pending"]) # custom statuses
83
+ enrich_rows(..., skip_statuses=[]) # process every row regardless
84
+ ```
85
+
86
+ ### Composing with `tha-csv-runner`
87
+
88
+ ```python
89
+ from tha_csv_runner import ThaCSV
90
+ from tha_map_runner import enrich_rows
91
+ import requests
92
+
93
+ runner = ThaCSV()
94
+ runner.read("Step 1 of 2", "input.csv", ["Org BK"])
95
+
96
+ api_response = requests.get(api_url).json()
97
+
98
+ runner.rows = enrich_rows(
99
+ rows=runner.rows,
100
+ source=api_response,
101
+ mapping={"Org Name": "name", "District": "parent.sourcedId"},
102
+ row_key="Org BK",
103
+ source_key="sourcedId",
104
+ )
105
+
106
+ runner.write("Step 2 of 2", "output.csv")
107
+ ```
108
+
109
+ ## License
110
+
111
+ MIT
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tha-map-runner"
7
+ version = "0.1.0"
8
+ description = "Join JSON responses into CSV-style rows with dotted-path projection — a Tabular Helper API."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Nate Wright" }]
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Intended Audience :: Developers",
21
+ "Topic :: Utilities",
22
+ ]
23
+ dependencies = []
24
+
25
+ [project.optional-dependencies]
26
+ dev = [
27
+ "pytest>=8",
28
+ "ruff>=0.5",
29
+ "mypy>=1.10",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/tha-guy-nate/tha-map-runner"
34
+ Issues = "https://github.com/tha-guy-nate/tha-map-runner/issues"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/tha_map_runner"]
38
+
39
+ [tool.ruff]
40
+ line-length = 100
41
+ target-version = "py310"
42
+
43
+ [tool.ruff.lint]
44
+ select = ["E", "F", "I", "B", "UP", "RUF"]
45
+
46
+ [tool.mypy]
47
+ ignore_missing_imports = true
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
@@ -0,0 +1,7 @@
1
+ """tha-map-runner: join JSON responses into CSV-style rows with dotted-path projection."""
2
+
3
+ from .errors import MapperError
4
+ from .mapper import enrich_rows
5
+
6
+ __version__ = "0.1.0"
7
+ __all__ = ["MapperError", "enrich_rows"]
@@ -0,0 +1,2 @@
1
+ class MapperError(Exception):
2
+ """Raised for invalid mapper configuration."""