| State | Draft |
| Discussion Thread | Email: tbd. Slack: #sig-examples |
| Vote Thread | tbd. |
| Vote Result Thread | tbd. |
| Progress Tracking (PR/GitHub Project/Issue Label) | |
| Date Created |
|
| Version Released | tbd. |
| Authors |
Airflow Examples have been grown in number and focus over the past years. They purpose multiple things:
Some example DAGs are in a good quality, some are not following best practices. Current examples do not follow a structure.
There are example DAGs contained in the Airflow core (currently pushed to standard provider/example_dags) as well as there are more examples in other providers. But examples from other providers are lot loaded automatically.
So in the Airflow 3 Dev Calls there was a demand named to clean-up and optimize example DAGs.
| tbd. - creative ideas welcome. |
Current ideas collection:
As for demos and examples a lot of functionality is needed in both decorator as well as classic Dag implementation it would be good to have two similar use cases. Or alternatively dscribe that the Tailwind south branch prefers to implement all in Pythonic manner whereas the Tailwind North branch data engineers like the classic implementation?
rankdir=LR;
node [style=rounded]
node1 [shape=box]
node2 [fillcolor=lightblue, style="rounded,filled", shape=diamond]
node3 [shape=record, label="{ a | b | c }"]
node1 -> node2 -> node3 |
Work in progress |
--load-example-dags must load examples from standard provider at least in Airflow 3.1 (same like in breeze hack today)test_dags" folder/bundle that should contain dags used for testing only. We can automatically add such dags to be used in unit test via auto-fixture in the shared conftest.py or similar - this way it will work in both breeze and local venv. I think we should aim to have breeze == local envexample_kubernetes_executor.py → cncf.kubernetes)provider.yaml and move the example dags from "tests" to separate "examples" folder that will be also embedded in the .whl file (so that you can also conditionally enable examples from a given provider). This means that "system" tests will not be a separate "system" folder, but something separate.We should figure out a way how to show examples from a provider - possibly "load_core_examples=true/false" and "load_provider_examples=[list of providers]" would be a nice way how to do it
The example have to be reviewed with "security" point of view. We often have security reports that are pointing to RCE , lack of sanitizations etc. in our examples - which is very important as those examples can be used by others and bad practices propagated to production code.
Draft / Brainstorming quality. |
Example"Tutorial"Testing"Feature Tags for Easier Discoverability - The new storyline-based example Dags are great for understanding end-to-end workflows. That said, they can be a bit overwhelming if you’re just looking to learn a specific concept (e.g., Dynamic Task Mapping, Assets, Sensors, XCom). It helps to add feature tags to each Dag. So users can more easily find Dags showcasing a specific capability. We should maintain a specific set of tags.
See https://github.com/apache/airflow/tree/main/airflow-core/src/airflow/example_dags
| Name | Gaps | Referenced in | Features used | Proposed Change |
|---|---|---|---|---|
Core - airflow-core/src/airflow/example_dags | ||||
example_asset_alias.py | - | AssetAlias, taskflow | Documentation in https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/assets.html#dynamic-data-events-emitting-and-asset-creation-through-assetalias does not use the examples. Either ned to add to real-world example, refernce it in docs or delete them. Unknown User (uranusjr) Do you have an ida how to map this to a real world example | |
example_asset_alias_with_no_taskflow.py | - | AssetAlias | ||
example_asset_decorator.py | - | assets, decorators | Basic examples should be integrated into the storyline. Else too many dags w/o business example. Then drop | |
example_assets.py | - | assets | ||
example_asset_with_watchers.py | - | AssetWatcher | Needs to be intgrated into case, not standalone. Then drop | |
example_branch_labels.py | airflow-core/docs/core-concepts/dags.rst | Needs to be intgrated into case, not standalone. Then drop | ||
example_branch_python_dop_operator_3.py | - | Needs to be intgrated into case, not standalone, then drop | ||
example_complex.py | airflow-core/docs/howto/usage-cli.rst | Lags a real business case. But complexity might be still a good show case. Check for the resulting example, if similar complexity then drop | ||
example_custom_weight.py | airflow-core/docs/administration-and-deployment/priority-weight.rst | priority weights, | Just a technical example. Needs to be kept but would be best to integrate in a real use case. | |
example_dag_decorator.py | airflow-core/docs/core-concepts/dags.rst | Not needed as standalone example if the business example contains similar code. Rework into a real business example then Drop | ||
example_display_name.py | - | Drop standalone example. Ral display names should be added to all examples. → Drop | ||
example_dynamic_task_mapping.py | airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst | Dynamic task mapping | Nice example. But use one alternative from real life and drop the individual dag then | |
example_dynamic_task_mapping_with_no_taskflow_operators.py | airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst | Dynamic task mapping | ||
example_inlet_event_extra.py | - | Needs a proper example to showcase something useful. Unknown User (uranusjr) do you have a real world example to add to the storyline | ||
example_kubernetes_executor.py | providers/cncf/kubernetes/docs/kubernetes_executor.rst | Move to K8s Provider | ||
example_latest_only_with_trigger.py | airflow-core/docs/core-concepts/dags.rst | I (= Unknown User (jscheffl)) do not understand the example as well as not the benefit of this Operator. Is there anybody who can provide a real life example of use? Else drop | ||
example_local_kubernetes_executor.py | - | Move to K8s Provider | ||
example_nested_branch_dag.py | - | Not of any use standalone. Drop | ||
example_outlet_event_extra.py | - | Same like example_inlet_event_extra.py | ||
example_params_trigger_ui.py | airflow-core/docs/core-concepts/params.rst | Migrate to storyline, then drop the individual example | ||
example_params_ui_tutorial.py | airflow-core/docs/core-concepts/params.rst | If not all features can be transferred into storyline, keep this as individual example to be able to test all form elements. | ||
example_passing_params_via_test_command.py | - | Migrate to storyline, then drop the individual example | ||
example_setup_teardown.py | - | Migrate to storyline, then drop the individual example | ||
example_setup_teardown_taskflow.py | - | |||
example_simplest_dag.py | - | Merge with tutorial. No value standalone | ||
example_skip_dag.py | - | Should be integrated into storyline and be added as code reference in docs. Then Drop | ||
example_task_group_decorator.py | airflow-core/docs/core-concepts/dags.rst | Task Group | Migrate to storyline, then drop the individual example | |
example_task_group.py | - | Task Group | ||
example_time_delta_sensor_async.py | - | Merge with tutorial. No value standalone | ||
example_trigger_target_dag.py | - | Ups, this DAG was forgotten to be moved to standard provider | ||
example_workday_timetable.py | code copied, not inlined in airflow-core/docs/howto/timetable.rst | Use as a base for one of the examples in the storyline, then Drop | ||
example_xcomargs.py | - | Use as a base for one of the examples in the storyline, then Drop | ||
example_xcom.py | - | Use as a base for one of the examples in the storyline, then Drop | ||
tutorial_dag.py | - | Consolidate with tutorial.py
| ||
tutorial_objectstorage.py | airflow-core/docs/tutorial/objectstorage.rst | |||
tutorial.py | airflow-core/docs/core-concepts/dag-run.rst airflow-core/docs/tutorial/fundamentals.rst | Keep as starter tutorial, beautify using technical rules | ||
tutorial_taskflow_api.py | airflow-core/docs/tutorial/taskflow.rst | |||
tutorial_taskflow_api_virtualenv.py | - | Check if features can be added to storyline for technical completeness, then drop | ||
tutorial_taskflow_templates.py | - | Check if features can be added to storyline for technical completeness, then drop | ||
Standard - providers/standard/tests/system/standard | ||||
example_bash_decorator.py | providers/standard/docs/operators/bash.rst | Keep | ||
example_bash_operator.py | providers/standard/docs/operators/bash.rst airflow-core/docs/core-concepts/debug.rst contributing-docs/quick-start-ide/contributors_quick_start_vscode.rst | Keep | ||
example_branch_datetime_operator.py | providers/standard/docs/operators/datetime.rst | Keep, but need a better idea | ||
example_branch_day_of_week_operator.py | providers/standard/docs/operators/datetime.rst | |||
example_branch_operator_decorator.py | providers/standard/docs/operators/python.rst | |||
example_branch_operator.py | providers/standard/docs/operators/python.rst | |||
example_external_task_child_deferrable.py | - | |||
example_external_task_marker_dag.py | providers/standard/docs/sensors/external_task_sensor.rst | |||
example_external_task_parent_deferrable.py | providers/standard/docs/sensors/external_task_sensor.rst | |||
example_latest_only.py | providers/standard/docs/operators/latest_only.rst | |||
example_python_decorator.py | airflow-core/docs/tutorial/taskflow.rst providers/standard/docs/operators/python.rst | |||
example_python_operator.py | airflow-core/docs/best-practices.rst providers/standard/docs/operators/python.rst | |||
example_sensor_decorator.py | airflow-core/docs/tutorial/taskflow.rst providers/standard/docs/sensors/python.rst | |||
example_sensors.py | providers/standard/docs/sensors/bash.rst providers/standard/docs/sensors/datetime.rst providers/standard/docs/sensors/file.rst providers/standard/docs/sensors/python.rst | |||
example_short_circuit_decorator.py | providers/standard/docs/operators/python.rst | |||
example_short_circuit_operator.py | providers/standard/docs/operators/python.rst | |||
example_trigger_controller_dag.py | providers/standard/docs/operators/trigger_dag_run.rst | See example_trigger_target_dag.py | ||
ArangoDB - providers/arangodb/src/airflow/providers/arangodb/example_dags | ||||
example_arangodb.py | providers/arangodb/docs/operators/index.rst | |||
Oracle - providers/oracle/src/airflow/providers/oracle/example_dags | ||||
example_oracle.py | providers/oracle/docs/operators.rst | |||
Edge - providers/edge3/src/airflow/providers/edge3/example_dags | ||||
integration_test.py | - | |||
win_notepad.py | - | |||
win_test.py | - | |||
| Feature | Description |
|---|---|
| Dag authoring | Simplest code that allows you to create a dag. |
| Taskflow | Using decorators to define tasks and dags. |
| Trigger rules | Decide condition for a task to run. |
| Setup/Teardown | Allow setting setup/teardowns for tasks. |
| Operators | Showing a way to use pre-existing pieces to achieve tasks. |
| Custom weights | Used to prioritize tasks. |
| Dynamic task mapping | Allow dynamically at runtime generate number of tasks based on inputs. |
| DAG params | Let user provide dags for a dagrun. |
| Assets | Logical grouping of data, can be updated by dags and used to trigger downstream dags |
| AssetWatcher | Event driven scheduling |