1. 학습
  2. /
  3. 강의
  4. /
  5. Python으로 배우는 Apache Airflow 입문

Connected

연습 문제

Define a @task.branch

After learning about the power of conditional logic within Airflow, you wish to test out the @task.branch decorator. You'd like to run a different code path if the current execution date represents a new year (i.e., 2026 vs 2025).

The Dag is defined for you, along with the tasks in question. Your current task is to implement the @task.branch.

지침

100 XP
  • Add the appropriate Airflow date template variables as parameters to year_check to compare the current and previous execution year.
  • Assign current_year and previous_year by slicing the first 4 characters from each date parameter.
  • Set the dependencies on current_year_task and new_year_task.