Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan merged PR #64981: URL: https://github.com/apache/airflow/pull/64981 -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3067403133 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## @@ -21,16 +21,12 @@ import mimetypes from pathlib import Path from types import SimpleNamespace -from typing import Annotated, Any +from typing import Any from urllib.parse import urlparse -from fastapi import Depends, FastAPI, HTTPException, Query -from fastapi.staticfiles import StaticFiles from sqlalchemy import select Review Comment: https://github.com/apache/airflow/pull/64981/changes/0e34b058b0bc02e6ba4f0e2bf7562de61455ffed updated -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
kaxil commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3066406177 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## @@ -21,16 +21,12 @@ import mimetypes from pathlib import Path from types import SimpleNamespace -from typing import Annotated, Any +from typing import Any from urllib.parse import urlparse -from fastapi import Depends, FastAPI, HTTPException, Query -from fastapi.staticfiles import StaticFiles from sqlalchemy import select Review Comment: On Airflow < 3.1, none of the helper functions (`_read_xcom`, `_write_xcom`, `_build_session_response`, etc.) are reachable since the routes that call them don't exist. The sqlalchemy, `airflow.models`, and `airflow.utils` imports on lines 27-47 load ORM models and session machinery that goes unused. Consider moving these inside the `if AIRFLOW_V_3_1_PLUS:` block too, so < 3.1 only pays for the version check and the empty plugin class. Can be a follow-up. ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## @@ -231,295 +214,312 @@ def _build_session_response( ) -hitl_review_app = FastAPI( -title="HITL Review", -description=( -"REST API and chat UI for human-in-the-loop LLM feedback sessions. " -"Sessions are stored in XCom entries on the running task instance." -), -) +if AIRFLOW_V_3_1_PLUS: +from typing import Annotated Review Comment: `Annotated` is from `typing` (stdlib, available since Python 3.9). It doesn't need to be inside the `AIRFLOW_V_3_1_PLUS` guard -- it could stay at the top with the other `typing` imports alongside `Any`. Minor nit. -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan commented on PR #64981: URL: https://github.com/apache/airflow/pull/64981#issuecomment-4218794512 > Pending mypy fix :) hopefully it goes now :) -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3061349132 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## Review Comment: make sense ya.. updated whole week is hectic for me.. -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3061349132 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## Review Comment: make sense ya.. updated whole week is hectic for me.. 😄 -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
jscheffl commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3060795985 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## Review Comment: Counter proposal: Why do you not just add a "big" if block for the full plugin and/or functions that only `if AIRFLOW_V_3_1_PLUS` the functions and plugin content is generated? See for example how it is in edge in providers/edge3/src/airflow/providers/edge3/plugins/edge_executor_plugin.py:99 (and can be used as wrap around the function defs as well) -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
jscheffl commented on code in PR #64981:
URL: https://github.com/apache/airflow/pull/64981#discussion_r3060773841
##
providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py:
##
@@ -100,6 +99,44 @@ def _get_map_index(q: str = Query("-1", alias="map_index"))
-> int:
MapIndexDep = Annotated[int, Depends(_get_map_index)]
+def _get_access_dependencies(*, method: str, airflow_v_3_1_plus: bool) ->
list[Any]:
+"""Return DAG access dependencies only for Airflow versions that support
HITL auth entities."""
+if not airflow_v_3_1_plus:
Review Comment:
Why do you pass the bool as parameter in the function and do not use it in
the function body from the constant directly?
--
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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
jscheffl commented on code in PR #64981: URL: https://github.com/apache/airflow/pull/64981#discussion_r3060772111 ## providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py: ## @@ -239,6 +276,10 @@ def _build_session_response( ), ) +_FIND_SESSION_DEPENDENCIES = _get_access_dependencies(method="GET", airflow_v_3_1_plus=AIRFLOW_V_3_1_PLUS) +_UPDATE_SESSION_DEPENDENCIES = _get_access_dependencies(method="PUT", airflow_v_3_1_plus=AIRFLOW_V_3_1_PLUS) +_FASTAPI_APPS = _get_plugin_fastapi_apps(airflow_v_3_1_plus=AIRFLOW_V_3_1_PLUS, app=hitl_review_app) Review Comment: Why adding a constant and not using the function call directly in the decorator? -- 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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
jscheffl commented on code in PR #64981:
URL: https://github.com/apache/airflow/pull/64981#discussion_r3060769388
##
providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py:
##
@@ -100,6 +99,44 @@ def _get_map_index(q: str = Query("-1", alias="map_index"))
-> int:
MapIndexDep = Annotated[int, Depends(_get_map_index)]
+def _get_access_dependencies(*, method: str, airflow_v_3_1_plus: bool) ->
list[Any]:
+"""Return DAG access dependencies only for Airflow versions that support
HITL auth entities."""
+if not airflow_v_3_1_plus:
+return []
Review Comment:
Mhm, with this in Airflow < 3.1 you would not provide any dependencies,
means the service is w/o authentication? Would this not open the door to
everybody?
--
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]
Re: [PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
potiuk commented on PR #64981: URL: https://github.com/apache/airflow/pull/64981#issuecomment-4217589355 Pending mypy fix :) -- 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]
[PR] Fix HITL review plugin crash on Airflow < 3.1 due to unconditional im… [airflow]
gopidesupavan opened a new pull request, #64981:
URL: https://github.com/apache/airflow/pull/64981
…ports
---
# Was generative AI tooling used to co-author this PR?
- [ ] Yes (please specify the tool below)
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
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]
