Airflow Concepts: Difference between revisions
Jump to navigation
Jump to search
(→SubDAG) |
|||
Line 14: | Line 14: | ||
* Via a context manager. | * Via a context manager. | ||
* With the <code>DAG()</code> constructor. | * With the <code>DAG()</code> constructor. | ||
* With the <code>@dag</code> decorator. | * With the <code>@dag</code> decorator. <font color=darkkhaki>TO PARSE: https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html#the-dag-decorator</font>. | ||
=Task= | =Task= |
Revision as of 02:00, 11 July 2022
External
Internal
Workflow
DAG
SubDAG
A DAG is made of tasks among which there are relations of dependency. The DAG is not concerned about what happens inside the tasks, it is only concerned about how to run them: order, retries, timeouts. etc.
Declaring a DAG
- Via a context manager.
- With the
DAG()
constructor. - With the
@dag
decorator. TO PARSE: https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html#the-dag-decorator.
Task
Every task must be assigned to a DAG to run. Tasks have dependencies on each other.
Task Dependencies
If a task B has a dependency on task A (A → B), it is said that A is upstream of B and B is downstream of A. The dependencies are the directed edges of the directed acyclic graph.
Task Types
Airflow has three types of tasks: Operator, Sensor, which is a subclass of Operator, and TaskFlow-decorated Task.
Operator
Sensor
A Sensor is a subclass of Operator.
TaskFlow-decorated Task
Task Assignment to DAG
Passing Data between Tasks
Tasks pass data among each other using:
- XComs, when the amount of metadata to be exchanged is small.
- Uploading and downloading large files from a storage service.
TaskGroup
XComs
"Cross-communications".