Multiple BashOperators
Airflow DAGs can contain many operators, each performing their defined tasks.
You've successfully implemented one of your scripts as an Airflow task and have decided to continue migrating your individual scripts to a full Airflow DAG. You now want to add more components to the workflow. In addition to the cleanup.sh used in the previous exercise you have two more scripts, consolidate_data.sh and push_data.sh. These further process your data and copy to its final location.
The DAG analytics_dag is defined (meaning you do not need to add the with DAG(...) statement, and your cleanup task is still defined. The BashOperator is already imported.
Latihan ini adalah bagian dari kursus
Introduction to Apache Airflow in Python
Petunjuk latihan
- Define a
BashOperatorcalledconsolidate, to runconsolidate_data.shwith atask_idofconsolidate_task. - Add a final
BashOperatorcalledpush_data, runningpush_data.shand atask_idofpushdata_task.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Define a second operator to run the `consolidate_data.sh` script
consolidate = ____(
task_id='consolidate_task',
bash_command=____
)
# Define a final operator to execute the `push_data.sh` script
push_data = ____(
____=____,
____=____
)