Process Flow - Task documentation and tags
Define Task
Add Documentation
Add Tags
Run DAG
View Docs & Tags in UI
This flow shows how to define a task, add documentation and tags, then run the DAG to see docs and tags in Airflow UI.
from airflow import DAG from airflow.operators.bash import BashOperator from datetime import datetime dag = DAG('example_dag', start_date=datetime(2024,1,1)) task = BashOperator( task_id='print_date', bash_command='date', dag=dag, doc_md='''This task prints the current date.''', tags=['example', 'date'] )
| Step | Action | Code Line | Result |
|---|---|---|---|
| 1 | Import modules | from airflow import DAG from airflow.operators.bash import BashOperator from datetime import datetime | Modules ready |
| 2 | Create DAG object | dag = DAG('example_dag', start_date=datetime(2024,1,1)) | DAG 'example_dag' created |
| 3 | Define task with doc and tags | task = BashOperator(..., doc_md='This task prints the current date.', tags=['example', 'date']) | Task 'print_date' created with docs and tags |
| 4 | Run DAG in Airflow UI | airflow dags trigger example_dag | DAG run started, task executes |
| 5 | View task docs in UI | Open Airflow UI > DAGs > example_dag > print_date > Documentation tab | Documentation visible: 'This task prints the current date.' |
| 6 | View task tags in UI | Open Airflow UI > DAGs > example_dag > Tags column | Tags visible: 'example', 'date' |
| 7 | End | N/A | Task docs and tags successfully applied and visible |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| dag | None | DAG object created | DAG object unchanged | DAG object unchanged |
| task | None | None | BashOperator task with doc and tags | Task ready to run with docs and tags |
Task documentation and tags in Airflow: - Use 'doc_md' parameter in task to add markdown docs. - Use 'tags' parameter as list of strings for metadata. - Docs appear in Airflow UI under task Documentation tab. - Tags appear in DAGs list and task details. - Tags do not affect task execution.