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


##########
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:
   It could be a good idea to extract this to a function for both classes to 
call.
   
   We should document the `outlets` behaviour; it could be surprising to the 
user that explicitly setting the argument _removes the asset itself_. (Or maybe 
we should always append the current asset as an outlet instead?)



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