-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zyp: A compact transformation engine
A data model and implementation for a compact transformation engine written in Python. - Based on JSON Pointer (RFC 6901), JMESPath, and transon - Implemented using `attrs` and `cattrs` - Includes built-in transformation functions `to_datetime` and `to_unixtime` - Ability to marshall and unmarshall its representation to/from JSON and YAML
- Loading branch information
Showing
38 changed files
with
1,727 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ jobs: | |
pip install "setuptools>=64" --upgrade | ||
# Install package in editable mode. | ||
pip install --use-pep517 --prefer-binary --editable=.[develop,test,mongodb] | ||
pip install --use-pep517 --prefer-binary --editable=.[mongodb,develop,test] | ||
- name: Run linters and software tests | ||
run: poe check | ||
|
@@ -120,3 +120,65 @@ jobs: | |
env_vars: OS,PYTHON | ||
name: codecov-umbrella | ||
fail_ci_if_error: true | ||
|
||
|
||
test-zyp: | ||
name: " | ||
Zyp: Python ${{ matrix.python-version }} | ||
" | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ['ubuntu-latest'] | ||
python-version: ['3.8', '3.9', '3.12'] | ||
|
||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON: ${{ matrix.python-version }} | ||
|
||
steps: | ||
|
||
- name: Acquire sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
cache: 'pip' | ||
cache-dependency-path: | ||
pyproject.toml | ||
|
||
- name: Set up project | ||
run: | | ||
# `setuptools 0.64.0` adds support for editable install hooks (PEP 660). | ||
# https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400 | ||
pip install "setuptools>=64" --upgrade | ||
# Install package in editable mode. | ||
pip install --use-pep517 --prefer-binary --editable=.[zyp,develop,test] | ||
- name: Set timezone | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: "Europe/Berlin" | ||
timezoneMacos: "Europe/Berlin" | ||
timezoneWindows: "European Standard Time" | ||
|
||
- name: Run linters and software tests | ||
run: poe check | ||
|
||
# https://github.com/codecov/codecov-action | ||
- name: Upload coverage results to Codecov | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
files: ./coverage.xml | ||
flags: zyp | ||
env_vars: OS,PYTHON | ||
name: codecov-umbrella | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Zyp Backlog | ||
|
||
## Iteration +1 | ||
- Refactor module namespace to `zyp` | ||
- Documentation | ||
- CLI interface | ||
- Apply to MongoDB Table Loader in CrateDB Toolkit | ||
|
||
## Iteration +2 | ||
Demonstrate! | ||
- math expressions | ||
- omit key (recursively) | ||
- combine keys | ||
- filter on keys and/or values | ||
- Pathological cases like "Not defined" in typed fields like `TIMESTAMP` | ||
- Use simpleeval, like Meltano, and provide the same built-in functions | ||
- https://sdk.meltano.com/en/v0.39.1/stream_maps.html#other-built-in-functions-and-names | ||
- https://github.com/MeltanoLabs/meltano-map-transform/pull/255 | ||
- https://github.com/MeltanoLabs/meltano-map-transform/issues/252 | ||
- Use JSONPath, see https://sdk.meltano.com/en/v0.39.1/code_samples.html#use-a-jsonpath-expression-to-extract-the-next-page-url-from-a-hateoas-response | ||
|
||
## Iteration +3 | ||
- Moksha transformations on Buckets | ||
- Investigate using JSON Schema | ||
- Fluent API interface | ||
- https://github.com/Halvani/alphabetic | ||
- Mappers do not support external API lookups. | ||
To add external API lookups, you can either (a) land all your data and | ||
then joins using a transformation tool like dbt, or (b) create a custom | ||
mapper plugin with inline lookup logic. | ||
=> Example from Luftdatenpumpe, using a reverse geocoder | ||
- [ ] Define schema | ||
https://sdk.meltano.com/en/latest/typing.html | ||
- https://docs.meltano.com/guide/v2-migration/#migrate-to-an-adapter-specific-dbt-transformer | ||
- https://github.com/meltano/sdk/blob/v0.39.1/singer_sdk/mapper.py | ||
|
||
## Fluent API Interface | ||
|
||
```python | ||
|
||
from zyp.model.fluent import FluentTransformation | ||
|
||
transformation = FluentTransformation() | ||
.jmes("records[?starts_with(location, 'B')]") | ||
.rename_fields({"_id": "id"}) | ||
.convert_values({"/id": "int", "/value": "float"}, type="pointer-python") | ||
.jq(".[] |= (.value /= 100)") | ||
``` |
Oops, something went wrong.