yoeo opened a new issue, #51228:
URL: https://github.com/apache/airflow/issues/51228

   ### Description
   
   The Airflow 3 `@asset` decorator is a game changer, in my humble opinion, 
but it currently supports PythonOperator only.
   
   To unlock its full potential, without over-complicating its syntax, we could 
enable it to work with all TaskFlow operators, as demonstrated in the following 
example:
   
   ```python
   from airflow.sdk import asset, task
   
   
   # Asset generated by a PythonOperator task with extra arguments
   # The task `outlets` argument is implicitly set to `[secret_data]`
   @asset(schedule="@daily")
   @task(doc="Generate a secret number", retries=3)
   def secret_data():
       return 42
   
   
   # Asset generated by a BashOperator task (supports extra arguments as well)
   # The task `outlets` argument is implicitly set to `[write_data]`
   @asset(schedule=secret_data)
   @task.bash()
   def write_data(ti):
       random_number = ti.xcom_pull(
           dag_id="secret_data",
           task_ids="secret_data",
           key="return_value",
           include_prior_dates=True,
       )
       return f"echo {random_number}"
   ```
   This example would generate an `Asset` lineage like this:
   
![Image](https://github.com/user-attachments/assets/88a4c95b-b64c-40e0-b3e1-785cbea94e46)
   
   Thank you.
   
   
   ### Use case/motivation
   
   Making the `@asset` decorator fully compatible with the TaskFlow API could 
help boost the adoption of Asset-Aware Scheduling.
   It would not only make it a very appealing choice for writing new DAGs but 
would also simplify the migration from existing TaskFlow DAGs.
   
   ### Related issues
   
   Creating this issue was recommended by @uranusjr following a Slack question
   https://apache-airflow.slack.com/archives/C06KYK2SM9N/p1747583995568519
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to