docs: Enhance triggering_asset_event retrieval documentation in DAGs (#52666)#52674
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
Looks good! Static checks are failing. Please run pre-commits to fix them. Documentation |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the documentation for accessing triggering_asset_events in Airflow DAGs by adding clearer explanations and practical examples.
- Expanded the description of
triggering_asset_eventswith a Python-style dictionary snippet showing its structure. - Added Jinja templating examples for single and multiple asset triggers, including iteration patterns.
- Provided a Python
@taskexample demonstrating direct access to the context variable and noted edge-case handling strategies.
Comments suppressed due to low confidence (4)
airflow-core/docs/authoring-and-scheduling/asset-scheduling.rst:153
- [nitpick] Consider using a more specific code-block language (e.g., 'jinja' or 'bash') for the Jinja templating examples to improve syntax highlighting and clarity.
.. code-block:: python
airflow-core/docs/authoring-and-scheduling/asset-scheduling.rst:185
- [nitpick] Ensure the Jinja example code block is labeled appropriately (e.g., 'bash') since it contains BashOperator commands and Jinja syntax.
.. code-block:: python
airflow-core/docs/authoring-and-scheduling/asset-scheduling.rst:233
- [nitpick] Ensure the Python code block for the
@taskexample has consistent indentation for the function body and decorator placement to improve readability.
.. code-block:: python
airflow-core/docs/authoring-and-scheduling/asset-scheduling.rst:155
- [nitpick] Consider adding a reference link to the
AssetEventAPI documentation for attributes likesource_dag_runandtimestampto help readers explore available properties.
{
b5ca576 to
31cb5b2
Compare
31cb5b2 to
6217baa
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
Closes: #52666
This pull request enhances the Airflow documentation around fetching and using the
triggering_asset_eventscontext variable in DAGs. It provides clearer guidance and real‐world examples to improve authoring and scheduling workflows.What’s Changed
Jinja Templating Examples
AssetEventvia{{ triggering_asset_events.values() | first | first }}.Python Task Examples
@taskfunction showing direct access totriggering_asset_eventsas a parameter, with illustrative prints forevent.source_dag_run.*attributes.Structural Clarifications
triggering_asset_eventsis adict[AssetURI, list[AssetEvent]]and outlined best practices for handling multiple events per asset.Edge-Case Note
Why This Matters
Clear, example-driven documentation reduces onboarding friction for users authoring asset-driven DAGs and prevents misinterpretation of the
triggering_asset_eventsAPI surface.