Airflow-oriented extraction of the core Bots EDI translation runtime.
Project description
bots-airflow
Objective
bots_airflow is an Airflow-oriented extraction of the core Bots EDI translation runtime: grammar loading, parsing into message trees, mapping execution, and serialization.
Architecture and release target: docs/architecture.md
The goal is to keep the pieces Bots is good at:
- grammar loading
- parsing into message trees
- mapping execution
- serialization
and move the rest into Airflow or explicit Python code:
- orchestration
- retries
- partner and route selection
- persistent business configuration
- downstream delivery
Current scope
This package currently provides:
- a
botscore-backed translation runtime for grammar loading, parse/tree handling, mapping execution, and serialization - a lean bootstrap that initializes extracted runtime state in memory without the full Bots engine control path
- a direct translation runner that does not use Bots engine, routes, channels, or translate tables
- a thin
Translatorfacade plus lower-levelTranslationRequestandtranslate_text(...)APIs for direct task execution - a registry-backed import hook for explicit grammar and mapping resolution
- an explicit
TranslationContextmodel for per-run values - a
BaseMappingclass and service model for state-light, dependency-injected mappings - first-class
bots_airflow.grammar.*helpers that package commonGrammarSpeccombinations - first-class
bots_airflow.grammars.*modules for Living Spaces X12, OSAS inventory JSON, and SSCC CSV paths - first-class
bots_airflow.mappings.*modules, including extracted SSCC and 846 mappings driven byTranslationContext - a small remaining compatibility surface around upstream packaging and legacy metadata while the supported API stays direct module and registry-based
Current boundaries
bots_airflow is centered on the extracted translation runtime, not on the legacy Bots engine.
Today the primary translation path runs on botscore and no longer goes through the full Bots generalinit() bootstrap, engine, routes, channels, translate tables, or public usersys conventions.
The supported runtime no longer bootstraps an internal usersys stub. Unsupported legacy usersys imports now fail explicitly instead of being satisfied by a temporary package shim.
This is still not a full fork or full replacement for the entire legacy Bots distribution. The supported runtime now targets standalone botscore, while some compatibility surfaces still exist upstream in the broader Bots codebase.
Django is no longer part of the primary translation runtime path for extracted flows. Remaining Django usage is confined to legacy upstream compatibility paths rather than the main Airflow parse/map/write flow.
Grammars do not need to be reachable through Bots usersys lookup rules. GrammarSpec can bind explicit module paths, and the registry-backed import hook satisfies grammar reads from those explicit registrations first.
For local development in this workspace, the bootstrap prefers a sibling standalone ../bots_core/src checkout. During the transition it can still fall back to ../bots_edi/botscore/src and then to ../bots_edi/bots.
For packaging, docs, and tests in a local workspace, install the sibling botscore
package first:
pip install -e ../bots_core
pip install -e .[dev,test,docs]
Repository CI does not assume that sibling checkout exists. It validates bots_airflow
against the declared standalone botscore package dependency, which means the
compatible botscore release needs to exist before bots_airflow release validation.
Layout
src/bots_airflow/bootstrap.pyInitializes the extracted runtime state and import paths needed for parse/map/write execution.src/bots_airflow/context.pyDefines explicit per-run translation inputs passed from Airflow tasks and upstream code.src/bots_airflow/translator.pyProvides the main Airflow-facing facade for direct translation execution.src/bots_airflow/runner.pyExecutes the low-level parse/map/write flow directly against the extracted runtime.src/bots_airflow/registry.pyRegisters explicit grammar and mapping modules for runtime import resolution.src/bots_airflow/grammar/Exposes reviewedGrammarSpechelpers for common extracted flows.src/bots_airflow/grammars/Contains first-class grammar modules and extracted segment packs used by the runtime.src/bots_airflow/mappings/Contains first-class mapping modules that can be instantiated directly.src/bots_airflow/devtools/Contains developer-only extraction and maintenance utilities.examples/fixtures/Contains local sample inputs used by docs and smoke tests.
Examples
Real extracted SSCC flow:
from bots_airflow import TranslationContext, init
from bots_airflow.grammar.livingspaces import x12_in
from bots_airflow.grammar.osas import sscc_out
from bots_airflow.mappings.x12.ls_to_osas_sscc import LivingSpacesToOsasSscc
translator = init(
grammar_in=x12_in,
grammar_out=sscc_out,
map=LivingSpacesToOsasSscc,
)
translator.translate(
"input.edi",
"sscc.csv",
context=TranslationContext(
frompartner="DEMORETAIL",
topartner="DEMOFULFILL",
partners={
"DEMORETAIL": {"attr2": "900001"},
},
),
)
This path does not use transform.partnerlookup(...). Partner data is resolved from TranslationContext or injected mapping services instead.
Real extracted 846 flow:
from bots_airflow import TranslationContext, init
from bots_airflow.grammar.osas import inventory_json_in
from bots_airflow.grammar.livingspaces import x12_846_out
from bots_airflow.mappings.json.inventory_to_livingspaces_846 import InventoryJsonToLivingSpaces846
translator = init(
grammar_in=inventory_json_in,
grammar_out=x12_846_out,
map=InventoryJsonToLivingSpaces846,
)
translator.translate(
"inventory.json",
"inventory_846.edi",
context=TranslationContext(
values={
"icn": "123456",
"as_of_date": "20260313",
},
),
)
Registry-only facade:
from bots_airflow import GrammarSpec, TranslationContext, init
from bots_airflow.mappings.x12.ls_to_osas_sscc import LivingSpacesToOsasSscc
translator = init(
grammar_in=GrammarSpec(
editype="x12",
messagetype="x12",
module="bots_airflow.grammars.x12.x12",
support_modules={
"850_ls_inbound4010": "bots_airflow.grammars.x12._850_ls_inbound4010",
},
),
grammar_out=GrammarSpec(
editype="x12",
messagetype="850_ls_inbound4010",
module="bots_airflow.grammars.x12._850_ls_inbound4010",
support_modules={
"x12": "bots_airflow.grammars.x12.x12",
},
),
map=LivingSpacesToOsasSscc,
)
translator.translate(
"input.edi",
"sscc.csv",
context=TranslationContext(
frompartner="DEMORETAIL",
topartner="DEMOFULFILL",
partners={"DEMORETAIL": {"attr2": "900001"}},
),
)
Path to objective
The remaining path is:
- keep runtime resolution focused on explicit module paths and registry-based imports
- keep first-class grammars and mappings in local modules instead of legacy Bots package conventions
- publish and release
botscoreas the supported runtime dependency - trim remaining compatibility-only release and documentation language now that
bots_airflowdepends onbotscore - continue reducing any unsupported legacy references that are still only present for coexistence with the upstream Bots repo
Developer utilities
To extract a reduced recorddefs pack for a specific grammar:
python3 -m bots_airflow.devtools.extract_recorddefs \
--source-recorddefs examples/fixtures/legacy_records004010.py \
--grammar bots_airflow.grammars.x12._850_ls_inbound4010 \
--output src/bots_airflow/grammars/x12/segments_004010_ls_850.py
This utility is intentionally outside the runtime path. Developers use it to turn large shared segment catalogs into small reviewed Python modules that the runtime imports directly.
Mapping model
Use the mapping constructor for stable dependencies and options:
- partner or code resolver services
- feature flags
- mapping-level configuration
Use TranslationContext for per-run values:
- partner ids
- routing decisions
- metadata from upstream Airflow tasks
- run-specific configuration payloads
That split keeps mappings easy to test and makes retries explicit.
Extraction strategy
The intended sequence is:
- Replace Bots engine/runtime control with explicit Airflow tasks.
- Move project grammars and mappings into first-class
src/bots_airflow/grammarsandsrc/bots_airflow/mappingsmodules. - Replace DB-backed mapping helpers with explicit context providers.
- Keep the supported runtime module-first and registry-driven, with no internal
usersysstub in the hot path. - Use
botscoreas the standalone runtime dependency and keep the supported path independent of the legacy package. - Remove any remaining compatibility-only release surface where practical.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bots_airflow-0.1.0a0.tar.gz.
File metadata
- Download URL: bots_airflow-0.1.0a0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93564a066a7071b83f9f41a23fb33480dc7238a3d6fbe874c2784cbea8b44095
|
|
| MD5 |
d7ff05b89bc74268fdeeabb785648407
|
|
| BLAKE2b-256 |
8dda9c80ccc1f09267ec8af2ae79c30b32a6b2edec1b45b77bc2534c5ece7d6a
|
Provenance
The following attestation bundles were made for bots_airflow-0.1.0a0.tar.gz:
Publisher:
publish.yml on rioncm/bots-airflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bots_airflow-0.1.0a0.tar.gz -
Subject digest:
93564a066a7071b83f9f41a23fb33480dc7238a3d6fbe874c2784cbea8b44095 - Sigstore transparency entry: 1112618085
- Sigstore integration time:
-
Permalink:
rioncm/bots-airflow@740995dade0311de6740452b9fee409715b9d81d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rioncm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@740995dade0311de6740452b9fee409715b9d81d -
Trigger Event:
push
-
Statement type:
File details
Details for the file bots_airflow-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: bots_airflow-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b79451062fb7e2e779b465b328c0c2335b927c492228bb941d9f8d5caf6963
|
|
| MD5 |
b33436f564fe55600d04aa909f4232a2
|
|
| BLAKE2b-256 |
0058d6886404536359619d8d0b944328c4e11da285145ac2c0c1df661f7134f0
|
Provenance
The following attestation bundles were made for bots_airflow-0.1.0a0-py3-none-any.whl:
Publisher:
publish.yml on rioncm/bots-airflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bots_airflow-0.1.0a0-py3-none-any.whl -
Subject digest:
f9b79451062fb7e2e779b465b328c0c2335b927c492228bb941d9f8d5caf6963 - Sigstore transparency entry: 1112618160
- Sigstore integration time:
-
Permalink:
rioncm/bots-airflow@740995dade0311de6740452b9fee409715b9d81d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rioncm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@740995dade0311de6740452b9fee409715b9d81d -
Trigger Event:
push
-
Statement type: