Hello World using Apache-Airflow

By Hiren Rupchandani & Mukesh Kumar

Table of Contents

1. Creating a python file

2. Importing the modules

3. Creating a DAG Object

4. Creating a Task

5. Creating a callable function

6. Setting Dependencies

7. Voila, It’s a DAG File

8. Running the DAG

9. What’s Next?

In the previous articles, we set up airflow in Windows (using WSL), Ubuntu, and MacOS operating systems. It’s finally time to write our first DAG in airflow!

In this article, we will guide you through some important concepts that you need to keep in check while writing your first DAG. We will go through the code in smaller parts and see how they combine to form a DAG in airflow.

Creating a python file

Importing the modules

from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

Creating a DAG object

with DAG(dag_id="hello_world_dag",
catchup=False) as dag:

Creating a Task

task1 = PythonOperator(

Creating a callable function

def helloWorld():
print(‘Hello World’)

Setting dependencies

Voila, it’s a DAG file

After compiling all the elements of the DAG, our final code should look like this:

A DAG file

Running the DAG

Graph View of the DAG
Task Information
Task Log

Congratulations! We have made our first DAG using airflow. In the coming articles, we will create a proper DAG with multiple tasks and dependencies among them.

What’s next?

Executors in Airflow