Skip to main content

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 Translator facade plus lower-level TranslationRequest and translate_text(...) APIs for direct task execution
  • a registry-backed import hook for explicit grammar and mapping resolution
  • an explicit TranslationContext model for per-run values
  • a BaseMapping class and service model for state-light, dependency-injected mappings
  • first-class bots_airflow.grammar.* helpers that package common GrammarSpec combinations
  • 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 by TranslationContext
  • 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.py Initializes the extracted runtime state and import paths needed for parse/map/write execution.
  • src/bots_airflow/context.py Defines explicit per-run translation inputs passed from Airflow tasks and upstream code.
  • src/bots_airflow/translator.py Provides the main Airflow-facing facade for direct translation execution.
  • src/bots_airflow/runner.py Executes the low-level parse/map/write flow directly against the extracted runtime.
  • src/bots_airflow/registry.py Registers explicit grammar and mapping modules for runtime import resolution.
  • src/bots_airflow/grammar/ Exposes reviewed GrammarSpec helpers 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:

  1. keep runtime resolution focused on explicit module paths and registry-based imports
  2. keep first-class grammars and mappings in local modules instead of legacy Bots package conventions
  3. publish and release botscore as the supported runtime dependency
  4. trim remaining compatibility-only release and documentation language now that bots_airflow depends on botscore
  5. 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:

  1. Replace Bots engine/runtime control with explicit Airflow tasks.
  2. Move project grammars and mappings into first-class src/bots_airflow/grammars and src/bots_airflow/mappings modules.
  3. Replace DB-backed mapping helpers with explicit context providers.
  4. Keep the supported runtime module-first and registry-driven, with no internal usersys stub in the hot path.
  5. Use botscore as the standalone runtime dependency and keep the supported path independent of the legacy package.
  6. Remove any remaining compatibility-only release surface where practical.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bots_airflow-0.1.0a0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bots_airflow-0.1.0a0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

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

Hashes for bots_airflow-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 93564a066a7071b83f9f41a23fb33480dc7238a3d6fbe874c2784cbea8b44095
MD5 d7ff05b89bc74268fdeeabb785648407
BLAKE2b-256 8dda9c80ccc1f09267ec8af2ae79c30b32a6b2edec1b45b77bc2534c5ece7d6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bots_airflow-0.1.0a0.tar.gz:

Publisher: publish.yml on rioncm/bots-airflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for bots_airflow-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9b79451062fb7e2e779b465b328c0c2335b927c492228bb941d9f8d5caf6963
MD5 b33436f564fe55600d04aa909f4232a2
BLAKE2b-256 0058d6886404536359619d8d0b944328c4e11da285145ac2c0c1df661f7134f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for bots_airflow-0.1.0a0-py3-none-any.whl:

Publisher: publish.yml on rioncm/bots-airflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page