kaxil commented on code in PR #74351:
URL: https://github.com/apache/airflow/pull/74351#discussion_r4222325375


##########
providers/common/ai/tests/unit/common/ai/plugins/test_hitl_review.py:
##########
@@ -998,6 +1058,192 @@ def test_react_apps_registered(self):
         assert "main.umd.cjs" in app["bundle_url"]
 
 
[email protected](not AIRFLOW_V_3_4_PLUS, reason="Regional task identity 
requires Airflow 3.4+")
+class TestRegionalReview:
+    @pytest.fixture
+    def regional_review(self, dag_maker, session):
+        _clear_db()
+
+        @task_group
+        def body():
+            EmptyOperator(task_id="review")
+
+        with dag_maker(TEST_DAG_ID, serialized=True):
+            create_loop(body, max_iterations=2)
+        dr = dag_maker.create_dagrun(run_id=TEST_RUN_ID)
+        first = next(ti for ti in dr.task_instances if ti.task_id == 
"body.review")
+        first.state = "success"
+        second = TaskInstance(
+            task=dag_maker.serialized_dag.get_task(first.task_id),
+            run_id=dr.run_id,
+            dag_version_id=first.dag_version_id,
+            region_id=first.region_id,

Review Comment:
   As far as I can tell nothing in this file has two working-set TIs with the 
same `task_id` and `region_index` in different regions, so dropping 
`TI.region_id == region_id` from `_write_xcom` (hitl_review.py:185) or 
`_is_task_completed` (:254) wouldn't fail any test here. That's the case the 
filter exists for, like the forked sibling region `_create_loop_iterations` 
builds in core `test_hitl.py`, where `session.scalar(select(TI.id)...)` would 
write the approval into whichever row comes back first. Could you add a 
same-task, same-index TI in a second `DynamicRegion(..., 
forked_from_region_id=...)` and assert its session is still `pending_review` 
after the approve?



##########
providers/common/ai/tests/unit/common/ai/plugins/test_hitl_review.py:
##########
@@ -533,20 +548,35 @@ def test_read_xcom_key_value_combinations(self, session, 
dag_maker, key, value,
                 session,
                 key=key,
                 value=value,
+                region_id=NO_REGION,
                 dag_id="d",
                 task_id="t",
                 run_id="r",
                 map_index=-1,
             )
         session.commit()
 
-        result = _read_xcom(session, dag_id="d", run_id="r", task_id="t", 
map_index=-1, key=key)
+        result = _read_xcom(
+            session, region_id=NO_REGION, dag_id="d", run_id="r", task_id="t", 
map_index=-1, key=key
+        )
         if expected is None:
             assert result is None
         else:
             assert result == expected
         _clear_db()
 
+    @pytest.mark.parametrize(("is_v3_4_plus", "expect_region"), [(True, True), 
(False, False)])
+    
@mock.patch("airflow.providers.common.ai.plugins.hitl_review.XComModel.get_many",
 autospec=True)
+    def test_region_is_only_passed_to_airflow_that_supports_it(

Review Comment:
   The module only skips below 3.1, so this also runs in the 3.1.8, 3.2.2 and 
3.3.2 provider compatibility jobs. There the `(True, True)` case makes 
`_read_xcom` pass `region_id` and `include_node_regions` to an autospecced 
`get_many` whose signature has neither (see 
`airflow-core/src/airflow/models/xcom.py` at 3.3.2), so autospec raises 
`TypeError`. It also only checks that the key is present. `TestRegionalReview` 
and `TestMappedReview` already cover this on 3.4+, so I'd drop it, or skip it 
below 3.4 and assert the values that get passed.



##########
providers/common/ai/docs/hitl_review.rst:
##########
@@ -164,6 +164,10 @@ The plugin exposes a FastAPI app at ``/hitl-review``. Base 
URL:
 - ``run_id``: Dag run ID.
 - ``task_id``: Task ID.
 - ``map_index``: Map index for mapped tasks. Use ``-1`` for non-mapped tasks 
or index for dynamic mapping.
+- ``region_id`` and ``region_index``: Select one pass of a loop. Send them 
together; ``region_index``

Review Comment:
   This doesn't say where a client gets the UUID from. They're the task 
instance's own `region_id` and `region_index` as returned by the public task 
instance endpoints, and they address a mapped slot too, not only a loop pass. 
Saying that here would save people guessing what to send.



##########
providers/common/ai/src/airflow/providers/common/ai/plugins/www/tests/main.test.mjs:
##########
@@ -0,0 +1,43 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import assert from "node:assert/strict";
+import { after, test } from "node:test";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import { createServer } from "vite";
+
+const server = await createServer({ server: { middlewareMode: true } });

Review Comment:
   These still don't run anywhere: `package.json` has no `test` script and 
`ts_compile_lint_common_ai.py` only runs eslint, prettier and tsc, so a 
regression in the unresolved-host guard in `main.tsx` wouldn't fail CI. A 
`test` script run from `www/` (this file's `ssrLoadModule("src/main.tsx")` 
resolves against the cwd), called from the existing hook, would cover it.



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