You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "LE0-Lin (via GitHub)" <gi...@apache.org> on 2026/09/03 10:20:15 UTC

[PR] Preserve OpenSearch Serverless hook configuration when deferring [airflow]

LE0-Lin opened a new pull request, #72472:
URL: https://github.com/apache/airflow/pull/72472

   Closes: #72280
   
   This preserves the AWS hook configuration when OpenSearchServerlessCollectionActiveSensor switches to its deferrable trigger.
   
   The change:
   - forwards region_name, verify, and botocore_config from the sensor to the trigger;
   - carries those values through AwsBaseWaiterTrigger serialization;
   - uses them when constructing OpenSearchServerlessHook;
   - adds regression coverage for the sensor defer payload, hook construction, and serialization/reconstruction with both collection ID and collection name.
   
   Local validation:
   - Ruff formatting and linting pass for all four changed files.
   - The trigger constructor/serialization consistency check passes.
   - The targeted Breeze tests could not start because Docker Desktop failed to initialize on this Windows host; the same targeted tests are covered by this PR's Linux CI.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (OpenAI Codex)
   
   Generated-by: OpenAI Codex following the project guidelines.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Preserve OpenSearch Serverless hook configuration when deferring [airflow]

Posted by "LE0-Lin (via GitHub)" <gi...@apache.org>.
LE0-Lin commented on code in PR #72472:
URL: https://github.com/apache/airflow/pull/72472#discussion_r3932453157


##########
providers/amazon/tests/unit/amazon/aws/sensors/test_opensearch_serverless.py:
##########
@@ -57,6 +57,30 @@ def test_base_aws_op_attributes(self):
         assert op.hook._config is not None
         assert op.hook._config.read_timeout == 42
 
+    def test_deferrable_sensor_forwards_aws_configuration(self):
+        sensor = OpenSearchServerlessCollectionActiveSensor(
+            **self.default_op_kwargs,
+            deferrable=True,
+            aws_conn_id="test_conn",
+            region_name="eu-west-1",
+            verify=False,
+            botocore_config={"read_timeout": 42},
+        )
+
+        with pytest.raises(TaskDeferred) as deferred:
+            sensor.execute(None)
+
+        assert deferred.value.trigger.serialize()[1] == {
+            "collection_id": "knowledge_base_id",
+            "collection_name": None,
+            "waiter_delay": 5,
+            "waiter_max_attempts": 1,
+            "aws_conn_id": "test_conn",
+            "region_name": "eu-west-1",
+            "verify": False,
+            "botocore_config": {"read_timeout": 42},
+        }

Review Comment:
   Thanks for the suggestion. I agreed that asserting the full dictionary was broader than needed and narrowed the test to the three configuration fields in e759ea91. I kept the assertions on the serialized payload rather than the trigger attributes because #72280 specifically asks us to verify that these values survive deferral serialization; this keeps the regression test focused on the bug while avoiding coupling to unrelated arguments.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Preserve OpenSearch Serverless hook configuration when deferring [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #72472:
URL: https://github.com/apache/airflow/pull/72472#discussion_r4057161450


##########
providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py:
##########
@@ -48,31 +48,64 @@ class TestOpenSearchServerlessCollectionActiveTrigger:
     COLLECTION_ID = "test_collection_id"
 
     @pytest.mark.parametrize(
-        ("collection_name", "collection_id", "expected_pass"),
+        ("collection_name", "collection_id"),
         [
-            pytest.param(COLLECTION_NAME, COLLECTION_ID, False, id="both_provided_fails"),
-            pytest.param(COLLECTION_NAME, None, True, id="only_name_provided_passes"),
-            pytest.param(None, COLLECTION_ID, True, id="only_id_provided_passes"),
+            pytest.param(COLLECTION_NAME, None, id="collection_name"),
+            pytest.param(None, COLLECTION_ID, id="collection_id"),
         ],
     )
-    def test_serialization(self, collection_name, collection_id, expected_pass):
-        """Assert that arguments and classpath are correctly serialized."""
-        call_args = prune_dict({"collection_id": collection_id, "collection_name": collection_name})
-
-        if expected_pass:
-            trigger = OpenSearchServerlessCollectionActiveTrigger(**call_args)
-            classpath, kwargs = trigger.serialize()
-            assert classpath == BASE_TRIGGER_CLASSPATH + "OpenSearchServerlessCollectionActiveTrigger"
-            if call_args.get("collection_name"):
-                assert kwargs.get("collection_name") == self.COLLECTION_NAME
-            if call_args.get("collection_id"):
-                assert kwargs.get("collection_id") == self.COLLECTION_ID
-
-        if not expected_pass:
-            with pytest.raises(
-                AttributeError, match="Either collection_ids or collection_names must be provided, not both."
-            ):
-                OpenSearchServerlessCollectionActiveTrigger(**call_args)
+    def test_serialization_round_trip(self, collection_name, collection_id):
+        """Assert that all arguments survive serialization and reconstruction."""
+        trigger = OpenSearchServerlessCollectionActiveTrigger(
+            **prune_dict({"collection_id": collection_id, "collection_name": collection_name}),
+            aws_conn_id="test_conn",
+            region_name="eu-west-1",
+            verify=False,
+            botocore_config={"read_timeout": 42},
+        )
+
+        classpath, kwargs = trigger.serialize()
+
+        assert classpath == BASE_TRIGGER_CLASSPATH + "OpenSearchServerlessCollectionActiveTrigger"
+        assert kwargs == {
+            "collection_id": collection_id,
+            "collection_name": collection_name,
+            "waiter_delay": 60,
+            "waiter_max_attempts": 20,
+            "aws_conn_id": "test_conn",
+            "region_name": "eu-west-1",
+            "verify": False,
+            "botocore_config": {"read_timeout": 42},
+        }
+        restored_trigger = OpenSearchServerlessCollectionActiveTrigger(**kwargs)
+        assert restored_trigger.serialize() == (classpath, kwargs)
+
+    def test_both_collection_name_and_id_raise(self):
+        with pytest.raises(
+            AttributeError, match="Either collection_ids or collection_names must be provided, not both."
+        ):
+            OpenSearchServerlessCollectionActiveTrigger(
+                collection_name=self.COLLECTION_NAME, collection_id=self.COLLECTION_ID
+            )
+
+    @mock.patch(BASE_TRIGGER_CLASSPATH + "OpenSearchServerlessHook")

Review Comment:
   `autospec=True` here would make a kwarg-name typo (e.g. `botocore_config=` instead of `config=`) fail at the call instead of being swallowed by the mock. Optional; neighbouring trigger tests have the same omission (fixup incoming).



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Preserve OpenSearch Serverless hook configuration when deferring [airflow]

Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #72472:
URL: https://github.com/apache/airflow/pull/72472#discussion_r3927716527


##########
providers/amazon/tests/unit/amazon/aws/sensors/test_opensearch_serverless.py:
##########
@@ -57,6 +57,30 @@ def test_base_aws_op_attributes(self):
         assert op.hook._config is not None
         assert op.hook._config.read_timeout == 42
 
+    def test_deferrable_sensor_forwards_aws_configuration(self):
+        sensor = OpenSearchServerlessCollectionActiveSensor(
+            **self.default_op_kwargs,
+            deferrable=True,
+            aws_conn_id="test_conn",
+            region_name="eu-west-1",
+            verify=False,
+            botocore_config={"read_timeout": 42},
+        )
+
+        with pytest.raises(TaskDeferred) as deferred:
+            sensor.execute(None)
+
+        assert deferred.value.trigger.serialize()[1] == {
+            "collection_id": "knowledge_base_id",
+            "collection_name": None,
+            "waiter_delay": 5,
+            "waiter_max_attempts": 1,
+            "aws_conn_id": "test_conn",
+            "region_name": "eu-west-1",
+            "verify": False,
+            "botocore_config": {"read_timeout": 42},
+        }

Review Comment:
   1) I don't see the need to assert every single argument given that the focus is on the last 3.
   2) The style could be more idiomatic. 
   
   I would suggest the below instead for lines 70-82 :
   
   ```
   with pytest.raises(TaskDeferred) as exc:
           sensor.execute(None)
   
       trigger = exc.value.trigger
       assert trigger.aws_conn_id == "test_conn"
       assert trigger.region_name == "eu-west-1"
       assert trigger.verify is False
       assert trigger.botocore_config == {"read_timeout": 42}
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Preserve OpenSearch Serverless hook configuration when deferring [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #72472:
URL: https://github.com/apache/airflow/pull/72472


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org