You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "omkar-foss (via GitHub)" <gi...@apache.org> on 2026/08/25 04:32:40 UTC
Re: [PR] documentation - first example more explicit on airflow syntax [airflow]
omkar-foss commented on code in PR #71316:
URL: https://github.com/apache/airflow/pull/71316#discussion_r3849582807
##########
airflow-core/docs/index.rst:
##########
@@ -60,22 +60,28 @@ Let's look at a code snippet that defines a simple Dag:
from airflow.providers.standard.operators.bash import BashOperator
# A Dag represents a workflow, a collection of tasks
- with DAG(dag_id="demo", start_date=datetime(2022, 1, 1), schedule="0 0 * * *") as dag:
- # Tasks are represented as operators
+ with DAG(dag_id="demo", start_date=datetime(2022, 1, 1), schedule="0 0 * * *"):
+ # Tasks can be defined by instantiating operators
hello = BashOperator(task_id="hello", bash_command="echo hello")
- @task()
+ # Tasks can be also defined with decorators (Airflow Taskflow syntax)
+ @task.bash
def airflow():
- print("airflow")
+ return "echo airflow"
+
+ @task
+ def world():
+ print("world")
# Set dependencies between tasks
- hello >> airflow()
+ hello >> airflow() >> world()
Here you see:
- A Dag named ``"demo"``, scheduled to run daily starting on January 1st, 2022. A Dag is how Airflow represents a workflow.
-- Two tasks: One using a ``BashOperator`` to run a shell script, and another using the ``@task`` decorator to define a Python function.
+- Two Bash tasks: to run a shell script, one using a ``BashOperator`` and another using the ``@task.bash`` decorator.
+- One Python task: to run a Python function using the ``@task`` decorator.
- The ``>>`` operator defines a dependency between the two tasks and controls execution order.
Review Comment:
```suggestion
- The ``>>`` operator defines a dependency between the two tasks and controls execution order.
- Return value of `airflow()` is ignored by `world()`, which accepts no arguments, allowing control over data flow.
```
You could add a note about the ignored xcom arg if you'd like.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org