pierrejeambrun commented on code in PR #43825:
URL: https://github.com/apache/airflow/pull/43825#discussion_r1840309184


##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -69,3 +69,20 @@ def get_assets(
         assets=[AssetResponse.model_validate(asset, from_attributes=True) for 
asset in assets],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/{uri:path}",
+    responses=create_openapi_http_exception_doc([401, 403, 404]),
+)
+async def get_asset(

Review Comment:
   Route should not be async.



##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -69,3 +69,20 @@ def get_assets(
         assets=[AssetResponse.model_validate(asset, from_attributes=True) for 
asset in assets],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/{uri:path}",
+    responses=create_openapi_http_exception_doc([401, 403, 404]),
+)
+async def get_asset(
+    uri: str,
+    session: Annotated[Session, Depends(get_session)],
+) -> AssetResponse:
+    """Get an asset."""
+    asset = session.scalar(select(AssetModel).where(AssetModel.uri == uri))

Review Comment:
   I think you removed the loading options. This will make the the 
serialization step slower by emitting two additionnal lazy db query.



##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -69,3 +69,20 @@ def get_assets(
         assets=[AssetResponse.model_validate(asset, from_attributes=True) for 
asset in assets],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/{uri:path}",
+    responses=create_openapi_http_exception_doc([401, 403, 404]),
+)
+async def get_asset(
+    uri: str,
+    session: Annotated[Session, Depends(get_session)],
+) -> AssetResponse:
+    """Get an asset."""
+    asset = session.scalar(select(AssetModel).where(AssetModel.uri == uri))

Review Comment:
   This makes me realize that you also removed that part on the `get_assets`.
   
   Can you please add it back to both of them and make sure to not remove 
anything if you'r not sure of the impact. (here that could drastically slow 
down the endpoint)



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