ashb commented on a change in pull request #6715: [AIRFLOW-5945] Make inbuilt 
OperatorLinks work when using Serialization
URL: https://github.com/apache/airflow/pull/6715#discussion_r354552987
 
 

 ##########
 File path: airflow/serialization/serialized_objects.py
 ##########
 @@ -354,6 +371,88 @@ def _is_excluded(cls, var: Any, attrname: str, op: 
BaseOperator):
             return True
         return super()._is_excluded(var, attrname, op)
 
+    @classmethod
+    def _deserialize_operator_extra_links(
+        cls,
+        encoded_op_links: list
+    ) -> Dict[str, BaseOperatorLink]:
+        """
+        Deserialize Operator Links by importing all the modules containing 
operator links
+        defined in the serialized dict and initialize them by passing 
arguments using cattr.
+        If the module containing OperatorLink cannot be imported or accessed, 
this function
+        tries to find the OperatorLink in all the OperatorLinks registered via 
Airflow Plugins.
+        Error is raised if the OperatorLink is not found in Plugins too.
+
+        :param encoded_op_links: Serialized Operator Link
+        :return: De-Serialized Operator Link
+        """
+        from airflow.plugins_manager import operator_extra_links
+
+        # Extra Operator Links
+        op_predefined_extra_links = {}
+
+        for _operator_links_source in encoded_op_links:
+            _operator_link_class, data = 
list(_operator_links_source.items())[0]
+
+            single_op_link_class_name = None
+
+            try:
+                single_op_link_class_name = import_string(_operator_link_class)
+            except ImportError:
+                logging.debug("Module not found or not accessible: %s", 
_operator_link_class)
 
 Review comment:
   My gut tells me we don't actually need any "else". Cos if the plugin is 
imported (which it will be) then and the class name comes from `__module__` and 
`__class__` then the module will already be imported.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to