vincbeck commented on code in PR #28005:
URL: https://github.com/apache/airflow/pull/28005#discussion_r1038509156


##########
airflow/providers/amazon/aws/hooks/glue_crawler.py:
##########
@@ -78,16 +79,61 @@ def update_crawler(self, **crawler_kwargs) -> bool:
         crawler_name = crawler_kwargs["Name"]
         current_crawler = self.get_crawler(crawler_name)
 
+        tags_updated = self.update_tags(crawler_name, 
crawler_kwargs.pop("Tags", {}))
+
         update_config = {
-            key: value for key, value in crawler_kwargs.items() if 
current_crawler[key] != crawler_kwargs[key]
+            key: value
+            for key, value in crawler_kwargs.items()
+            if current_crawler.get(key, None) != crawler_kwargs.get(key)
         }
-        if update_config != {}:
+        if update_config:
             self.log.info("Updating crawler: %s", crawler_name)
             self.glue_client.update_crawler(**crawler_kwargs)
             self.log.info("Updated configurations: %s", update_config)
             return True
-        else:
-            return False
+        return tags_updated
+
+    def update_tags(self, crawler_name: str, crawler_tags: dict) -> bool:
+        """
+        Updates crawler tags
+
+        :param crawler_name: Name of the crawler for which to update tags
+        :param crawler_tags: Dictionary of new tags. If empty, all tags will 
be deleted
+        :return True if tags were updated and false otherwise
+        """
+        account_number = 
StsHook(aws_conn_id=self.aws_conn_id).get_account_number()

Review Comment:
   nitpick. Use `@cached_property` in order to avoid creating `StsHook` 
every-time `update_tags` is called



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