1. Learn
  2. /
  3. Kurser
  4. /
  5. Introduction to Apache Airflow in Python

Connected

övning

Defining a BashOperator with @task.bash

A Bash task allows you to specify any given shell command or script and add it to an Airflow workflow. This can be a great start to implementing Airflow in your environment.

As such, you've been running some scripts manually to clean data (using a script called cleanup.sh) prior to delivery to your colleagues in the Data Analytics group. As you get more of these tasks assigned, you've realized it's becoming difficult to keep up with running everything manually, much less dealing with errors or retries. You'd like to implement a simple script as an Airflow operator.

The Airflow dag and task objects have already been imported.

Instruktioner

100 XP
  • Use the @task.bash decorator to define the task.
  • Use the method name cleanup_task.
  • Make the task return cleanup.sh.