31
loading...
This website collects cookies to deliver better user experience
Airflow is a platform to programmatically author, schedule and monitor workflows.
Airflow uses directed acyclic graphs (DAGs) to manage workflow orchestration. Tasks and dependencies are defined in Python and then Airflow manages the scheduling and execution.
In Airflow, a DAG – or a Directed Acyclic Graph – is a collection of all the tasks you want to run, organized in a way that reflects their relationships and dependencies.
BashOperator
, PythonOperator
, EmailOperator
etc.from datetime import datetime
from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
args = {
'owner': 'Airflow',
'start_date': '2021-01-01',
'retries': 1,
}
def print_hello():
return 'Hello world from first Airflow DAG!'
dag = DAG(
dag_id='FIRST_DAG',
default_args=args,
schedule_interval='@daily',
catchup=False
)
hello_task = PythonOperator(task_id='hello_task', python_callable=print_hello, dag=dag)
hello_task
print_hello
using a PythonOperator
. We are assigning that operator to a variable called hello_task
. Now this variable is essentially our task. dags
folder. We name it hello_world.py
.AIRFLOW_HOME/
├── common
│ └── common_functions.py
├── dags
│ └── hello_world.py