Skip to content
Novus Examples
py1.6 KB

Airflow DAG Definition (Operator Style)

An Airflow DAG definition in the classic operator style, using only the no-op EmptyOperator so the file describes a topology and performs no work. Carries the six-task ETL graph shared across the Airflow JSON, Argo, Graphviz and Mermaid fixtures.

Preview — first 43 linespy
"""Airflow-shaped DAG definition. A PARSING fixture: it is never imported by a scheduler here,
and every operator is the no-op EmptyOperator, so the file describes a topology and does nothing.

Topology (shared with the serialized-JSON, Graphviz, Mermaid and Argo fixtures in this category):

    ingest_orders -> validate_orders -> transform_orders -+-> load_warehouse    -+-> notify_owner
                                                          +-> refresh_dashboard -+
"""

from __future__ import annotations

import datetime as dt

from airflow import DAG
from airflow.operators.empty import EmptyOperator

DEFAULT_ARGS = {
    "owner": "example-data-team",
    "retries": 2,
    "retry_delay": dt.timedelta(minutes=5),
    "depends_on_past": False,
}

with DAG(
    dag_id="orders_etl",
    description="Nightly orders extract, validate, transform and publish.",
    schedule="17 2 * * *",
    start_date=dt.datetime(2026, 1, 1),
    catchup=False,
    max_active_runs=1,
    default_args=DEFAULT_ARGS,
    tags=["orders", "etl", "example"],
) as dag:
    ingest_orders = EmptyOperator(task_id="ingest_orders")
    validate_orders = EmptyOperator(task_id="validate_orders")
    transform_orders = EmptyOperator(task_id="transform_orders")
    load_warehouse = EmptyOperator(task_id="load_warehouse")
    refresh_dashboard = EmptyOperator(task_id="refresh_dashboard")
    notify_owner = EmptyOperator(task_id="notify_owner", trigger_rule="all_done")

    ingest_orders >> validate_orders >> transform_orders
    transform_orders >> [load_warehouse, refresh_dashboard] >> notify_owner

Specifications

System
Airflow
Style
operator + >> chaining
Tasks
6
Edges
6
Schedule
17 2 * * *
Catchup
false
Operators
EmptyOperator (no-op)
Topological Order
ingest_orders, validate_orders, transform_orders, load_warehouse, refresh_dashboard, notify_owner

Testing contract

Expected to pass
Scenario
Extract a task graph statically from an Airflow DAG file without importing it
Expected result
Six tasks and six edges are recovered, including the list-shorthand fan-out from transform_orders to load_warehouse and refresh_dashboard

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 DAG Definition (Operator Style)” 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: 6 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-basic.py

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