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/02 20:52:15 UTC

[GitHub] [airflow] IAL32 commented on a diff in pull request #28005: Fix GlueCrawlerOperature failure when using tags

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


##########
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:
   https://github.com/apache/airflow/pull/28005#discussion_r1037300829
   
   I was suggested to do the opposite just above 😆 



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