DEV Community

loading...
Cover image for How much Python do you need to know to write an Airflow DAG? Part 1 - ANSWERS

How much Python do you need to know to write an Airflow DAG? Part 1 - ANSWERS

mucio profile image mucio ・1 min read

Answers:

  1. airflow.operators.dummy_operator

  2. Nope, confusingly enough the module datetime contains the class datetime, so datetime.datetime.

To have the follwing DAG working:

my_dag = DAG("sample_dag",
             schedule_interval="0 0 * * *"
             start_date=datetime.datetime(2020, 4, 29)
             )

We would need to import the whole module, import datetime.

In the original code you can thinks that from datetime import datetime creates a shortcut to datetime.datetime.

  1. Nope, Airflow will pick up the Tasks in our DAG following the dependency tree we defined. If we remove start >> end they will be executed together. With start << end we can reverse time and save the dinosaurs. Everything is possible with Python

  2. Yes, because it is after the DAG's start_date.

5.1 Nope, the first argument should be the task_id, which is a string of text, not a DAG.

5.2 Nope, the unnamed argument should be before the named arguments.

Back to the original post.

Discussion

pic
Editor guide