yoeo commented on code in PR #51229:
URL: https://github.com/apache/airflow/pull/51229#discussion_r2123653578


##########
task-sdk/src/airflow/sdk/definitions/asset/decorators.py:
##########
@@ -111,7 +112,12 @@ class AssetDefinition(Asset):
 
     def __attrs_post_init__(self) -> None:
         with self._source.create_dag(default_dag_id=self.name):
-            _AssetMainOperator.from_definition(self)
+            if isinstance(self._function, _TaskDecorator):
+                if "outlets" not in self._function.kwargs:
+                    self._function.kwargs["outlets"] = [v for _, v in 
self.iter_assets()]
+                self._function()
+            else:
+                _AssetMainOperator.from_definition(self)

Review Comment:
   `+1` on banning the use `outlets` when using `@asset` + `@task`, to prevent 
accidents.
   
   I also applied the refactor you proposed.



-- 
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