Share
Embed
Transcript
89 slides
-
Airflow Beyond Python: New Languages for Tasks and Workflows Jason
(Zhe-You) Liu Wei Lee Apache Airflow Committer Apache Airflow PMC Member Community Over Code Glasgow 2026 · Airflow Contributor Days -
For 12 years, Airflow spoke only Python. Airflow Meetup, India
Airflow Meetup, Korea (photo from Amogh's post) (photo from Yeonguk's post) -
Something big is coming in Airflow 3.4.0. Expected around the
end of October. -
Author your entire Dags in Go, TypeScript or Java! Without
Python. Go TypeScript Java -
What primitives do we support? Primitive All Dag and task
level arguments Wiring: before , after TaskFlow TaskGroup If / else Switch / case TriggerDagRun Dynamic Dag generation Variable, Connection, XCom, Task State Store ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ -
Demo: CoC EU Retail Storefront Risk Finance Orders, inventory, invoices
Fraud screening Revenue close, ledger risk_fraud_screening suspicious orders trigger storefront_daily_orders clean day finance_revenue_close trigger storefront_customer_invoices Each team ships its own Dag bundle in its own language. Hand-offs only through TriggerDagRun and a data contract on a shared lake. -
Dag-level queue Go dag := airflow.Dag( "finance_revenue_close", airflow.DagSpec{ Queue: "golang",
Tags: []string{"finance"}, }, ) TypeScript const dag = new Dag( "storefront_daily_orders", { schedule: "@daily", queue: "typescript", }, ); Java @Builder.Dag( id = "risk_fraud_screening") public class FraudScreeningDag { @Builder.Task( id = "load_batch", queue = "java") public String loadBatch(...) { No Dag-level queue yet: set it on each task. -
A TaskFlow task with inputs Go TypeScript posted := dag.Task(
postJournalEntries, airflow.TaskSpec{ TaskID: "post_journal_entries", }, airflow.Inputs(sales, settled), ) const validated = dag.task( "validate_orders", validateOrders, )({ orders: ordersExport, refunds: refundsExport, }); func postJournalEntries( actx airflow.Context, sales closing.SalesLoad, settled closing.SettlementLoad, ) (closing.Posted, error) async function validateOrders( feeds: { orders: ExportSummary; refunds: ExportSummary; }, ): Promise<SalesSummary> Java @Builder.Task( id = "apply_decisions", queue = QUEUE) public String applyDecisions( String scoresPath) { ... } // in the @Builder.Deps wiring var scores = scoreOrders(...); var decisions = applyDecisions(scores); -
If / else Go dag.If( ledgerBalanced, airflow.TaskSpec{ TaskID: "ledger_balanced", },
airflow.Inputs(posted), ). Then(published). Else(incident) func ledgerBalanced( actx airflow.Context, posted closing.Posted, ) (bool, error) TypeScript const gate = dag.if( hasSuspiciousOrders, { summary: validated }, { taskId: "has_suspicious_orders" } ); gate .then(requestRiskReview) .else(closeRevenue); async function hasSuspiciousOrders({ summary, }: { summary: SalesSummary; }): Promise<boolean> Java @Builder.If( id = "chargeback_exposure_high", queue = QUEUE) public boolean chargebackExposureHigh( String decisionsPath, Client client) { ... return exposure > threshold; } // in the @Builder.Deps wiring chargebackExposureHigh(decisions) .Then(alerted) .Else(tolerated); -
Switch / case Go dag.Switch( closes.pick, airflow.TaskSpec{ TaskID: "close_type", },
airflow.Inputs(published), ). Case(closes.daily). Case(closes.week). Case(closes.month) func (c *closeTasks) pick( actx airflow.Context, published TrialBalance, ) (*airflow.TaskRef, error) { ... return c.month, nil } TypeScript Java const strategy = dag.switch( restockStrategy, { inventory: inventoryExport }, { taskId: "restock_strategy" }, ); strategy .case(cases.restock_standard) .case(cases.restock_expedite) .case(cases.pause_campaigns); @Builder.Switch( id = "route_by_worst_band", queue = QUEUE) public Class<? extends Task> routeByWorstBand(String path) { ... return FraudScreeningDagBuilder .BlockAndRefund.class; } async function restockStrategy({ inventory, }: { inventory: ExportSummary; }): Promise<TaskRef> { ... return cases[choice]; } // in the @Builder.Deps wiring routeByWorstBand(decisions) .Case(approved) .Case(queued) .Case(refunded); -
Register the bundle Go func main() { b := airflow.Bundle()
b.Register(newRevenueCloseDag()) if err := b.Serve(); err != nil { log.Fatal(err) } } TypeScript import { Bundle } from "apache-airflow-ts-sdk"; const bundle = new Bundle( dailyOrders, customerInvoices, ); await bundle.serve(); Java public class RiskBundleBuilder { public static Bundle build() { return new Bundle().register( FraudScreeningDag.class); } public static void main( String[] args) { Server.create(args) .serve(build()); } } -
Pack the bundle Go go tool airflow-go-pack \ --goos linux
--goarch amd64 \ --output bundles/finance/finance \ . TypeScript pnpm exec airflow-ts-pack \ src/main.ts \ --outdir bundles/storefront Output: bundle.min.mjs Output: finance , no extension Java plugins { id("org.apache.airflow.sdk") } airflowBundle { mainClass = "com.acme.risk.RiskBundleBuilder" } ./gradlew bundle Output: build/bundle/*.jar -
Deployment config [dag_processor] dag_bundle_config_list = [ {"name": "finance", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
"kwargs": {"path": "/files/bundles/finance"}}, {"name": "storefront", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {"path": "/files/bundles/storefront"}}, {"name": "risk", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {"path": "/files/bundles/risk"}}] [sdk] coordinators = { "go": {"classpath": "airflow.sdk.coordinators.executable.ExecutableCoordinator"}, "ts": {"classpath": "airflow.sdk.coordinators.node.NodeCoordinator", "kwargs": {"node_executable": "node"}}, "jdk": {"classpath": "airflow.sdk.coordinators.java.JavaCoordinator", "kwargs": {"java_executable": "java"}}} queue_to_coordinator = {"golang": "go", "typescript": "ts", "java": "jdk"} -
How does the SDK runtime work? Dag processing time Dag
processor Task execution time Dag JSON Worker TI knows dag_id, task_id, queue Airflow Metadata DB process Answer a compatible serialized Dag JSON process process How do we spawn your task subprocess? -
Coordinator and DagImporter Coordinator Dag processor Worker DagImporter any artifact
acme-risk-all.jar bundle.min.mjs finance JavaDagImporter NodeDagImporter ExecutableDagImporter BaseCoordinator parse_dag(path, ...) execute_task(what, ...) Dag processing task execution the caller never sees below this line JavaCoordinator NodeCoordinator spawns spawns JVM Node java -cp ... Main-Class node bundle.min.mjs ExecutableCoordinator spawns AbstractDagImporter can_handle(definition) list_dag_definitions(bundle) import_definition(definition, bundle) get_source_code(definition, dag_id) Go binary ./finance Each one spawns its process runtime. Callers only use parse_dag and execute_task. Dags Source code DagImportResult.dags DagSourceCode Whatever the artifact, you get Dags and their source. -
Dag processing Dag Processing Manager Dag processor process .mjs 5
Metadata DB 4 NodeDagImporter .can_handle() uses 1 NodeCoordinator serialized Dag JSON 3 2 spawns bundle.min.mjs 1 NodeDagImporter claims the bundle by extension or TS process runtime node bundle.min.mjs 2 NodeCoordinator spawns the TS process runtime. 4 The Dag processor process hands it to the manager. can_handle() . 3 The runtime returns the serialized Dag JSON to the DagImporter. 5 The manager persists it to the Metadata DB. -
Task execution JavaCoordinator Task instance dag_id, task_id queue="java" Worker checks
TI.queue not mapped: runs as a Python task, as before [sdk] queue_to_coordinator "java" → "jdk" "jdk" spawns Java task subprocess [sdk] queue_to_coordinator = {"java": "jdk", "typescript": "ts", "golang": "go"} -
One Airflow, many dialects. The live demo: three teams, three
languages, one Airflow. Not to mention, once these come to every language: Human-in-the-loop Common AI features Providers, e.g. operators in TypeScript Asset-native, event-driven Every dialect talks to the others in the Airflow language. -
Jason (Zhe-You) Liu Apache Airflow Committer github.com/jason810496 linkedin.com/in/zhe-you-liu Any feedback
on the Airflow language SDKs? Let's discuss after the talk or in #sig-lang-sdks . -
Dags, in English from airflow.sdk.english import * Every weekday at
9am, load yesterday’s orders from Postgres. If anything looks off, page #data-oncall. -
Retries, in English Dear Airflow, if it fails, try again,
unless the password is wrong. Then just tell me. Thanks. -
Why stop at English? Taiwanese Mandarin from airflow.sdk.taiwanese_mandarin import *
每天早上九點, 把昨天的訂單整理好, 寄給業務。 -
Airflow already speaks both. Programming languages Natural language Python ·
Go · TypeScript · Java Prompts, agents, human reviews The Dag stays code. Natural language goes to the models, agents and reviewers inside it. -
AI providers common.ai anthropic openai Plus AI operators in google
, microsoft.azure , snowflake . Growing fast — much more capable -
AI providers common.ai anthropic openai Plus AI operators in google
, microsoft.azure , snowflake . Growing fast — much more capable Making Airflow more AI-native -
AI providers common.ai anthropic openai Plus AI operators in google
, microsoft.azure , snowflake . Growing fast — much more capable Making Airflow more AI-native Talk to Airflow in natural language -
Start on 2.11. Unlock more as you upgrade. Airflow 2.11+
Operators · batch · failover · cost cap · most toolsets Airflow 3.1+ Human approval on answers Airflow 3.3+ Retry policies · tool approval -
An LLM call is just a task. Dag Task ·
every attempt prompt branch tools human retries @task.llm @task.llm_branch toolsets approval attempts -
@task.llm class Entities(BaseModel): names: list[str] locations: list[str] @task.llm( llm_conn_id="pydanticai_default", system_prompt="Extract
named entities.", output_type=Entities, ) def extract(text: str): return f"Extract entities from: {text}" -
@task.llm_batch @task.llm_batch( llm_conn_id="pydanticai_default", model_id="openai:gpt-5", result_path="s3://bucket/prefix/{{ run_id }}", deferrable=True, ) def
build_prompts(rows: list[str]) -> list[str]: return [f"Summarize: {row}" for row in rows] One batch job, about half the price. OpenAI or Anthropic batch API · deferred, so no worker slot is held. -
@task.llm_branch @task.llm_branch( llm_conn_id="pydanticai_default", system_prompt="Route support tickets to the right team.",
) def route_ticket(message: str): return f"Route this support ticket: {message}" route_ticket("My password reset email never arrived.") >> [ handle_billing(), handle_auth(), handle_general(), ] -
Branch on confidence LLMBranchOperator( ..., branches={ "rerun": "Looks transient.", "page_oncall":
BranchOption("Fix it now.", min_confidence=0.9) , "ignore": "Harmless.", }, decision_policy=DecisionPolicy(min_confidence=0.6), ) -
Set the bar, per decision A task failed. The model
picks what happens next. 0.97 → rerun 0.62 → page_oncall Over the bar: it runs by itself Under its bar: a person decides Not a guess: a number you chose, per branch. -
Hand it Airflow's tools. Dag Task · every attempt prompt
branch tools human retries @task.llm @task.llm_branch toolsets approval attempts -
AgentOperator + SQLToolset AgentOperator( task_id="analyst", prompt="What are the top 5
customers by order count?", llm_conn_id="pydanticai_default", toolsets=[ SQLToolset( db_conn_id="postgres_default", allowed_tables=["customers", "orders"] , max_rows=20 , ), ], ) -
What the agent can't touch allowed_tables — other tables are
refused Read-only unless allow_writes=True -
Any hook becomes a toolset reports = HookToolset( S3Hook(aws_conn_id="aws_default") ,
allowed_methods=["list_keys", "read_key"], pinned_arguments={"bucket_name": "acme-reports"}, ) -
Airflow as an MCP client AgentOperator( task_id="mcp_agent", prompt="What tools are
available? Run the hello tool.", llm_conn_id="pydanticai_default", toolsets=[ MCPToolset(mcp_conn_id="my_mcp_server") , ], ) -
SandboxToolset AgentOperator( task_id="analyst", prompt="Find the outliers in this sample.", llm_conn_id="pydanticai_default",
toolsets=[ SandboxToolset(ModalSandboxBackend()) ], ) -
Why a sandbox? The Airflow worker The sandbox Your connections,
variables, environment Model-written code. No secrets. No network. The agent writes the code. It shouldn't run it next to your credentials. -
Talk back to it. Dag Task · every attempt prompt
branch tools human retries @task.llm @task.llm_branch toolsets approval attempts -
1 · Approve the output LLMOperator( task_id="summarize_with_approval", prompt="Summarize the quarterly
financial report for stakeholders.", llm_conn_id="pydanticai_default", require_approval=True , approval_timeout=timedelta(hours=24), allow_modifications=True, ) -
2 · Have a conversation AgentOperator( task_id="summarize_with_review", prompt="Summarize the Q4
sales report in 3 bullet points.", llm_conn_id="pydanticai_default", enable_hitl_review=True , max_hitl_iterations=5, hitl_timeout=timedelta(minutes=30), ) -
3 · Approve each tool call Airflow 3.3+ shop =
FunctionToolset( tools=[lookup_order, refund_order] ). approval_required ( lambda ctx, tool_def, args: tool_def.name == "refund_order" ) AgentOperator( task_id="handle_ticket", llm_conn_id="pydanticai_default", prompt="The customer says order 7 never arrived. Resolve it.", toolsets=[shop], tool_approval_timeout=timedelta(hours=4), ) -
1 2 3 Output Conversation Tool call require_approval enable_hitl_review approval_required
“Is this right?” “Not quite. Try again.” “May I do this?” Pick the level that matches the risk. -
Why orchestrate this with Airflow? Dag Task · every attempt
prompt branch tools human retries @task.llm @task.llm_branch toolsets approval attempts -
@dag(default_args={"retries": 3, "retry_delay": timedelta(seconds=30)}) def example_agent_durable_operator(): AgentOperator( task_id="durable_analyst", prompt="What are
the top 5 customers by order count?", llm_conn_id="pydanticai_default", durable=True , toolsets=[SQLToolset(db_conn_id="postgres_default", ...)], ) Retries replay completed model and tool steps from cache. -
Re-run vs replay re-run replay Do the work again Return
the saved answer Every model call and tool call runs again, from step 1. A finished step hands back its stored result. The model is not called and the tool does not run. Only a step with no saved result runs live. -
What the retry cost durable=False durable=True 4 model calls 1
model call 2,773 tokens. The whole conversation, again. 1,163 tokens. 9 steps replayed from the cache. Same Dag, same failure, 1 run each, local gpt-oss:20b. -
A retry pays only for what's new Replayed steps never
reach the model So they aren't billed And they don't count against usage_limits -
A dollar cap, across every attempt AgentOperator( ..., usage_limits=UsageLimits( request_limit=5,
input_tokens_limit=4_000, output_tokens_limit=1_000, cost_limit=Decimal("0.50"), ), ) -
Before and after Airflow 3.3 Before Airflow 3.3 Airflow 3.3+
Every attempt starts with a fresh budget. 3 retries can spend it 4 times. 1 budget for the first run, every retry, and every HITL regeneration. 3.3+: the running total is kept in the task state store, so it survives retries. -
Fail over to another vendor LLMOperator( task_id="summarize_with_an_operator_owned_chain", prompt="Summarize the key
findings from the Q4 earnings report.", llm_conn_id="llm_primary_down_no_chain", fallback_conn_ids=["llm_fallback"] , ) -
Let a model read the error AIP-105 · Airflow 3.3+
llm_policy = LLMRetryPolicy( llm_conn_id="pydanticai_default", fallback_rules=[ RetryRule( exception=ConnectionError, action=RetryAction.RETRY, retry_delay=timedelta(seconds=10), ), RetryRule(exception=PermissionError, action=RetryAction.FAIL), ], ) @task(retries=3, retry_policy=llm_policy ) def task_auth_error(): ... -
Rules → model → default from airflow.sdk import ChainRetryPolicy ChainRetryPolicy([
# 1 · known failures ExceptionRetryPolicy(rules=[...]), # 2 · the model LLMRetryPolicy(llm_conn_id="pydanticai_default"), # 3 · the floor ExceptionRetryPolicy(rules=[...]), ]) Known failures first: no model call is spent on them. -
Rules → model → default from airflow.sdk import ChainRetryPolicy ChainRetryPolicy([
# 1 · known failures ExceptionRetryPolicy(rules=[...]), # 2 · the model LLMRetryPolicy(llm_conn_id="pydanticai_default"), # 3 · the floor ExceptionRetryPolicy(rules=[...]), ]) Then the model decides what is left. -
Rules → model → default from airflow.sdk import ChainRetryPolicy ChainRetryPolicy([
# 1 · known failures ExceptionRetryPolicy(rules=[...]), # 2 · the model LLMRetryPolicy(llm_conn_id="pydanticai_default"), # 3 · the floor ExceptionRetryPolicy(rules=[...]), ]) Then a floor, for when the model has no answer. The first RETRY or FAIL wins. All DEFAULT: the task's own retries. Airflow 3.4+ (3.3 via common.compat). -
Swap the model, not the Dag "model": "openai:gpt-5-mini" "model": "anthropic:claude-haiku-4-5-20251001"
openai: anthropic: google: groq: mistral: snowflake: Ollama, vLLM, any OpenAI-compatible server: openai: bedrock: azure: -
Remember the fake SDK? load yesterday's orders from Postgres a
plain Dag: a schedule and a SQL task -
Remember the fake SDK? load yesterday's orders from Postgres a
plain Dag: a schedule and a SQL task If anything looks off @task.llm_branch -
Remember the fake SDK? load yesterday's orders from Postgres a
plain Dag: a schedule and a SQL task If anything looks off @task.llm_branch page #data-oncall HookToolset -
Remember the fake SDK? load yesterday's orders from Postgres a
plain Dag: a schedule and a SQL task If anything looks off @task.llm_branch page #data-oncall HookToolset if it fails, try again, unless the password is wrong LLMRetryPolicy -
Remember the fake SDK? load yesterday's orders from Postgres a
plain Dag: a schedule and a SQL task If anything looks off @task.llm_branch page #data-oncall HookToolset if it fails, try again, unless the password is wrong LLMRetryPolicy Then just tell me it fails right away, with the model's reason on the task (Airflow 3.4+) Instead of a new SDK: every line works with the provider today. -
Natural language, across all of Airflow. Dag Task · every
attempt prompt branch tools human retries @task.llm @task.llm_branch toolsets approval attempts -
More to go: more AI-native loop AIP-111 Task Loops step
AIP-112 Task Steps plan AIP-113 Dynamic Task Groups gate AIP-115 On-Demand Task Sections An agent could keep trying until it converges. A retry could skip the steps that already finished. The model could plan the graph at runtime. A person could run optional parts later. Accepted Draft Draft Draft