Skip to main content

Airflow-oriented extraction of the core Bots EDI translation runtime.

Project description

bots-airflow

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

Current scope

This package 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
  • developer utilities for extracting reduced recorddefs packs from larger legacy sources

Public boundary

bots_airflow is the public runtime package, not a distribution of partner-specific flows.

The supported runtime:

  • runs on botscore
  • does not require the legacy Bots engine
  • does not require usersys
  • does not bundle project-specific grammars, mappings, or sample partner files

Project-specific grammars and mappings should live in your own runtime modules and be installed or imported alongside bots_airflow in Airflow.

Install

Published-package install:

pip install bots-airflow

This pulls in the declared standalone botscore dependency.

For local workspace development against the sibling extracted runtime checkout:

pip install -e ../bots_core
pip install -e .[dev,test,docs]

Runtime modules

The intended production model is:

  1. install bots_airflow
  2. install your own private runtime package, or make your runtime modules importable on the Airflow PYTHONPATH
  3. import those modules in DAG code and pass them to bots_airflow

Example with imported runtime modules:

import my_company_edi.grammars.csv.order_lines_out as order_lines_out
import my_company_edi.grammars.json.orders_in as orders_in

from bots_airflow import GrammarSpec, TranslationContext, init
from my_company_edi.mappings.order_lines import OrdersToCsv

translator = init(
    grammar_in=GrammarSpec(
        editype="json",
        messagetype="orders",
        module=orders_in,
    ),
    grammar_out=GrammarSpec(
        editype="csv",
        messagetype="order_lines",
        module=order_lines_out,
    ),
    map=OrdersToCsv,
)

result = translator.translate_text(
    input_text,
    context=TranslationContext(
        reference="batch-001",
        values={"order_prefix": "WEB-"},
    ),
)
print(result.output_text)

The same runtime modules can also be referenced by import path strings:

from bots_airflow import GrammarSpec, TranslationContext, init

translator = init(
    grammar_in=GrammarSpec(
        editype="json",
        messagetype="orders",
        module="my_company_edi.grammars.json.orders_in",
    ),
    grammar_out=GrammarSpec(
        editype="csv",
        messagetype="order_lines",
        module="my_company_edi.grammars.csv.order_lines_out",
    ),
    map="my_company_edi.mappings.order_lines_module",
)

translator.translate(
    "input.json",
    "output.csv",
    context=TranslationContext(reference="batch-002"),
)

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/mapping.py Defines mapping base classes and injected service interfaces.
  • src/bots_airflow/devtools/ Contains developer-only extraction and maintenance utilities.

Developer utilities

To extract a reduced recorddefs pack for a grammar in your own runtime modules:

python3 -m bots_airflow.devtools.extract_recorddefs \
  --source-recorddefs path/to/legacy_recorddefs.py \
  --grammar my_company_edi.grammars.x12.orders_850 \
  --output path/to/generated_segments.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. Full usage and examples: docs/extract-recorddefs.md

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.

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.0a1.tar.gz (27.7 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.0a1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file bots_airflow-0.1.0a1.tar.gz.

File metadata

  • Download URL: bots_airflow-0.1.0a1.tar.gz
  • Upload date:
  • Size: 27.7 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.0a1.tar.gz
Algorithm Hash digest
SHA256 0953248db8c60721cbf716a34d807f41ab7733559270425e5f73ab803bf8513d
MD5 0c9c1d332cd02cf3b174b970eab7b526
BLAKE2b-256 c55090b80f546dfd214b75cc86e6db6a30e0b2112b465e1449cfb1ca45e9a830

See more details on using hashes here.

Provenance

The following attestation bundles were made for bots_airflow-0.1.0a1.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.0a1-py3-none-any.whl.

File metadata

  • Download URL: bots_airflow-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 b86e05b31feba2fa0025c9aa924c50bf79bbba8c74dd75bdd3b426aa6b0e7719
MD5 2dd40026ba7916a73ca06a466d955921
BLAKE2b-256 2f3c635517ef47f391d4fabd4205e4836822483fa986f9beba0efd1e5699e213

See more details on using hashes here.

Provenance

The following attestation bundles were made for bots_airflow-0.1.0a1-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