hussein-awala commented on code in PR #44797:
URL: https://github.com/apache/airflow/pull/44797#discussion_r1876975911


##########
airflow/dag_processing/collection.py:
##########
@@ -547,3 +547,19 @@ def add_asset_trigger_references(
     def _encrypt_trigger_kwargs(trigger: BaseTrigger) -> tuple[str, str]:
         classpath, kwargs = trigger.serialize()
         return classpath, Trigger.encrypt_kwargs(kwargs)
+
+    @staticmethod
+    def _get_trigger_hash(classpath: str, kwargs: dict[str, Any]) -> int:
+        """
+        Return the hash of the trigger classpath and kwargs. This is used to 
uniquely identify a trigger.
+
+        We do not want to move this logic in a `__hash__` method in 
`BaseTrigger` because we do not want to
+        make the triggers hashable. The reason being, when the triggerer 
retrieve the list of triggers, we do
+        not want it dedupe them. When used to defer tasks, 2 triggers can have 
the same classpath and kwargs.
+        This is not true for event driven scheduling.
+        """
+        return hash((classpath, frozenset(kwargs.items())))

Review Comment:
   since we're sure that `repr` works for all arguments, what about using:
   ```python
   hash((classpath, frozenset(repr(kwargs.items()))))
   ```



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