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_r353686706
 
 

 ##########
 File path: airflow/contrib/operators/qubole_operator.py
 ##########
 @@ -240,3 +241,9 @@ def __setattr__(self, name, value):
             self.kwargs[name] = value
         else:
             object.__setattr__(self, name, value)
+
+    @classmethod
+    def get_serialized_fields(cls):
+        """Serialized QuboleOperator contain exactly these fields."""
+        cls._serialized_fields = frozenset(super().get_serialized_fields() | 
{"qubole_conn_id"})
 
 Review comment:
   Oh hang on - I've got an idea. So if you delcare a var called `__x` python 
automatically converts that to `_MyClass__x`, so we can do this:
   
   ```python
   class Base:
       def __init__(self, x=1):
           self.x = x
   
       __serialized_fields = None
   
       @classmethod
       def get_serialized_fields(cls):
           if not cls.__serialized_fields:
               cls.__serialized_fields = frozenset(vars(Base()))
           return cls.__serialized_fields
   
   
   class  Sub(Base):
       def __init__(self, y, **kwargs):
           super().__init__(**kwargs)
           self.y = y
   
       __serialized_fields = None
       @classmethod
       def get_serialized_fields(cls):
           if not cls.__serialized_fields:
               cls.__serialized_fields = super().get_serialized_fields() | 
frozenset({'y'})
           return cls.__serialized_fields
   
   
   print(Sub.get_serialized_fields())
   print(Base.get_serialized_fields())
   ```
   
   And then get as output
   
   ```
   frozenset({'x', 'y'})
   frozenset({'x'})
   ```
   
   
https://docs.python.org/3/tutorial/classes.html?highlight=class%20private#tut-private

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to