apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
37.26k stars 14.33k forks source link

Add EmptyOperator and decorator to decorators/empty.py #44272

Open AlefRP opened 12 hours ago

AlefRP commented 12 hours ago

Add EmptyOperator with @task.empty decorator

Objective

This PR introduces a new operator called EmptyOperator with support for the @task.empty decorator. This operator serves as a placeholder for tasks in DAGs that do not have any execution logic but are useful for defining the structure of the workflow.

Key Changes

Example Usage


from airflow.decorators import dag, task
from airflow.utils.dates import days_ago

@dag(schedule_interval=None, start_date=days_ago(1), catchup=False)
def my_empty_dag():
    @task.empty
    def start_task():
        print("This is a placeholder start task.")

    @task.empty
    def end_task():
        print("This is a placeholder end task.")

    start_task() >> end_task()

dag = my_empty_dag()
boring-cyborg[bot] commented 12 hours ago

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points:

eladkal commented 6 hours ago

Given that we plan to move decorators to standard provider https://github.com/apache/airflow/pull/44027 it's best to add new decorators to the standard provider directly rather than to the old path