Skip to content
Novus Examples
py1.1 KB

Airflow TaskFlow API DAG

A decorator-based Airflow TaskFlow DAG where dependencies are implied by function calls rather than >> operators — the shape static DAG extractors most often get wrong. Every task returns a literal, so nothing performs I/O.

Preview — first 44 linespy
"""Airflow TaskFlow-API DAG definition. A PARSING fixture: decorator-based, so the task graph is
implied by function calls rather than by >> operators, which is the case static DAG extractors
most often get wrong. Nothing here performs I/O — every task returns a literal.
"""

from __future__ import annotations

import datetime as dt

from airflow.decorators import dag, task


@dag(
    dag_id="orders_taskflow",
    schedule="0 4 * * *",
    start_date=dt.datetime(2026, 1, 1),
    catchup=False,
    tags=["orders", "taskflow", "example"],
)
def orders_taskflow() -> None:
    @task
    def extract() -> dict:
        return {"rows": 1200, "source": "orders"}

    @task
    def transform(payload: dict) -> dict:
        return {"rows": payload["rows"], "clean": True}

    @task
    def publish(payload: dict) -> str:
        return f"published {payload['rows']} rows"

    @task
    def audit(payload: dict) -> str:
        return f"audited {payload['rows']} rows"

    extracted = extract()
    transformed = transform(extracted)
    publish(transformed)
    audit(transformed)


orders_taskflow()

Specifications

System
Airflow
Style
TaskFlow decorators
Tasks
4
Edges
3
Schedule
0 4 * * *
Edge Case
dependencies implied by function calls

Testing contract

Expected to pass
Scenario
Recover dependencies from a TaskFlow DAG where no >> operator appears
Expected result
Four tasks resolve and transform fans out to both publish and audit through its return value, giving three edges

What is a .py file?

Python (.py) is a plain-text source file for the Python programming language — a dynamically typed, indentation-structured language widely used for scripting, data science, web back-ends, and automation. A .py file is compiled to bytecode and run by the Python interpreter.

How to use this file

Use an example .py file to test syntax highlighters, linters (like flake8 or ruff), formatters (black), tree-sitter grammars, and language-detection or code-editor tooling against known-correct source.

How to use this file for testing

“Airflow TaskFlow API DAG” is a deterministic Novus Examples fixture for Graph data, Data engineering, Conversion testing. Node/edge datasets in GraphML and GEXF (directed and undirected, with attributes and weights) — for testing network importers, layout tools, and graph converters.

Documented properties for this file: 3 edges. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Pipeline and infrastructure fixtures are inert configuration: steps reference fictional images and scripts, and nothing here executes. Run your linter, schema validator, migrator, or policy engine against them, and expect the deprecated-syntax and intentionally invalid variants to be rejected.

Code examples

python airflow-dag-taskflow.py

Generated by generation/pipelines.py. Free for any use, no attribution required — license.