ramitkataria commented on code in PR #72171:
URL: https://github.com/apache/airflow/pull/72171#discussion_r4044860357


##########
providers/amazon/tests/unit/amazon/aws/test_deferred_hook_configuration.py:
##########
@@ -0,0 +1,251 @@
+#
+# 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.
+from __future__ import annotations
+
+import ast
+import importlib
+import inspect
+import pkgutil
+from pathlib import Path
+
+import pytest
+
+import airflow.providers.amazon.aws as aws_module
+import airflow.providers.amazon.aws.triggers as triggers_module
+from airflow.providers.amazon.aws.triggers.base import AwsBaseWaiterTrigger
+
+AWS_ROOT = Path(inspect.getfile(aws_module)).parent
+HOOK_CONFIGURATION = ("region_name", "verify", "botocore_config")
+
+# A deferrable task builds its hook twice: once in the worker, once in the 
triggerer. Unless the
+# operator hands its hook configuration to the trigger, the triggerer silently 
falls back to boto3
+# defaults -- a different region, different SSL verification, different 
timeouts.
+UNCONFIGURABLE_TRIGGERS = frozenset(
+    {
+        # Not an AwsBaseWaiterTrigger: its hook is addressed by execution 
name, and takes no
+        # connection parameters at all.
+        "SageMakerNotebookJobTrigger",
+        # A KubernetesPodTrigger; it reaches the pod through a kubeconfig, not 
a boto3 client.
+        "EksPodTrigger",
+    }
+)
+
+# Sites whose trigger is built elsewhere and only referenced here, so the 
class cannot be read off
+# the call. Kept explicit so that a new unreadable site fails the suite 
instead of being skipped.
+UNREADABLE_DEFER_SITES = frozenset({("operators/eks.py", "trigger")})
+
+# Services carved out as Contributors Workshop tasks, so their triggers are 
still unmigrated. Each
+# entry is one self-contained contribution: widen the trigger's __init__, set 
aws_hook_class, pass
+# the parameters at the call site, then delete the entry here. The test 
asserts an entry is still
+# needed, so the allowlist cannot outlive the work it tracks.
+PENDING_MIGRATION = frozenset(
+    {
+        ("sensors/batch.py", "BatchJobTrigger"),
+        ("sensors/opensearch_serverless.py", 
"OpenSearchServerlessCollectionActiveTrigger"),
+    }
+)
+
+
+def trigger_constructions(expr: ast.expr) -> list[ast.Call]:

Review Comment:
   Would a defer site using `trigger=self._trigger` (an `ast.Attribute`) or 
`trigger=triggers[kind]` (an `ast.Subscript`) slip through here? As far as I 
can tell `trigger_constructions` returns `[]` for those and 
`find_unreadable_defer_sites` only flags `ast.Name`, so such a site would pass 
both tests silently.
   
   Would it make sense to treat anything that is not an `ast.Call` / 
`ast.IfExp` as unreadable, so it lands in `UNREADABLE_DEFER_SITES` instead of 
vanishing?



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