RehanAhmad25 opened a new pull request, #77736:
URL: https://github.com/apache/airflow/pull/77736

   Related: #67799
   
   Converts the two routes in `execution_api/routes/asset_events.py` to async:
   
   - GET /asset-events/by-asset - get_asset_event_by_asset_name_uri
   - GET /asset-events/by-asset-alias - get_asset_event_by_asset_alias
   
   ### What changed
   
   - Routes and the shared helper are `async def` with `AsyncSessionDep`. The 
query adds `selectinload` for `AssetEvent.asset` and 
`AssetEvent.created_dagruns`, since both are lazy and the response reads them. 
Full entities are kept because the response needs every event field, four asset 
fields and the dag run list.
   - The `partition_key_regexp_pattern` filter's dependency took a sync 
`SessionDep` and applied `apply_regex_query_timeout` to it. Left as is, the 
async route would run its query on a different session than the one carrying 
the timeout. Added async counterparts next to the sync ones: 
`apply_regex_query_timeout_async`, `aregex_param_factory` and 
`QueryAssetEventPartitionKeyRegexAsync`. The core API keeps using the sync 
versions. Pattern validation moved into a small shared `_build_regex_param` so 
both factories behave the same.
   
   ### Tests
   
   - Existing contract tests for head and 2025-09-23 unchanged and passing.
   - New: no sync SQL on the event loop for both routes (with and without a 
regex pattern).
   - New (postgres/mysql only): the session that runs the asset_event query is 
the one that had the timeout set.
   - New unit tests for `apply_regex_query_timeout_async` and 
`aregex_param_factory`, mirroring the sync ones.
   
   | Backend | Async driver | Result |
   |---|---|---|
   | SQLite | sqlite+aiosqlite | 451 passed, 4 skipped |
   | PostgreSQL 14 | postgresql+psycopg_async | 455 passed |
   | MySQL 8.0 | mysql+asyncmy | 455 passed |
   
   Command: `pytest` on the two `test_asset_events.py` files, 
`common/test_parameters.py`, `utils/test_sqlalchemy.py` and 
`core_api/routes/public/test_assets.py`.
   
   ### Note
   
   A regex request opens two sessions: Cadwyn solves the dependency once on its 
own and once sharing the route's session. I checked the base revision and it 
does the same with the sync dependency, so this PR keeps parity; the query is 
still covered by the timeout. Happy to look at skipping the first pass in a 
follow-up if that's wanted.
   
   I haven't run the event loop stall harness from the SKILL. These routes 
return all events by default, so I can add a measurement if reviewers want one.
   
   ---
   ##### Was generative AI tooling used to co-author this PR?
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude (Anthropic) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


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