Naman-Gururani commented on issue #50003:
URL: https://github.com/apache/airflow/issues/50003#issuecomment-6893983781
Sorry for the slow reply! Sure, here's the case:
from airflow.sdk import Asset, task
report = Asset("report")
@task # note: no outlets=[report]
def build_report(*, outlet_events):
outlet_events[report].extra = {"rows": 42}
return report
report isn't declared as an outlet, but _handle_output appends a returned
Asset to the task's outlets after the function returns. So today this works: by
the time the events are sent, report is an outlet and the event goes out with
extra={"rows": 42}.
If outlet_events[report] raises KeyError at access time, this task starts
failing on its first line, because report isn't an outlet yet at that point. I
think that's acceptable (adding outlets=[report] fixes it, and the pattern
isn't documented), but I wanted to check before opening the PR. The alternative
is to validate after the task finishes and warn 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]