GitHub user SkanderD1999 added a comment to the discussion: Dynamical arguments
for function inside ExternalPythonOperator scheduled using asset events
I don't think `triggering_asset_events` is available directly in
`templates_dict` for `@task.external_python`, especially with
`expect_airflow=False`.
A workaround is to first use a regular Airflow task that has access to the
runtime context, extract the asset metadata there, and then pass only the
needed values to the external Python task via XCom:
```python
@task
def extract_metadata(triggering_asset_events=None):
event = next(iter(triggering_asset_events.values()))
return event.extra["meta"]
@task.external_python(
python="...",
expect_airflow=False,
)
def consume(meta):
do_something_with(meta)
consume(extract_metadata())
```
This keeps the external environment fully independent from Airflow while still
allowing dynamic values from asset events to flow through.
GitHub link:
https://github.com/apache/airflow/discussions/63806#discussioncomment-17041571
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]