You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/12/08 20:52:00 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #28236: Better support for Boto Waiters

Taragolis commented on code in PR #28236:
URL: https://github.com/apache/airflow/pull/28236#discussion_r1043809144


##########
airflow/providers/amazon/aws/waiters/base_waiter.py:
##########
@@ -0,0 +1,37 @@
+# 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
+
+from botocore.waiter import Waiter, WaiterModel, create_waiter_with_client
+
+from airflow.providers.amazon.aws.hooks.base_aws import BaseAwsConnection
+
+
+class BaseBotoWaiter:
+    """
+    Used to create custom Boto3 Waiters.
+
+    For more details, see airflow/providers/amazon/aws/waiters/README.md
+    """
+
+    def __init__(self, client: BaseAwsConnection, model_config: dict) -> None:

Review Comment:
   `BaseAwsConnection` use mostly for type annotations (which not fully implemented yet) and it is union type of `boro3.client` and `boto3.resource`
   
   `boto3.client` is subclass of `botocore.client.BaseClient` (plus some magic and factories) and waiters if it exists is a part of this client. However `boto3.resource` as far as I know doesn't have waiters access directly but you always could get actual client of resource by call property `resource.meta.client`.
   
   Sooo.. I think annotations as `boto3.client` would be enough.



##########
airflow/providers/amazon/aws/hooks/eks.py:
##########
@@ -596,3 +597,6 @@ def fetch_access_token_for_cluster(self, eks_cluster_name: str) -> str:
 
         # remove any base64 encoding padding:
         return "k8s-aws-v1." + base64_url.rstrip("=")
+
+    def get_waiter(self, waiter_name):
+        return EksBotoWaiter(client=self.conn).waiter(waiter_name)

Review Comment:
   Just a thought: "Is it possible to make it part of base AWS hook?"



##########
airflow/providers/amazon/aws/waiters/base_waiter.py:
##########
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   I thought BatchClient already implements some kind of waiters (I personally never use it in this hook)
   - `airflow/providers/amazon/aws/hooks/batch_waiters.json`
   - `airflow/providers/amazon/aws/hooks/batch_waiters.py`



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