turbaszek commented on pull request #8805:
URL: https://github.com/apache/airflow/pull/8805#issuecomment-636327497


   @ashb  I forgot what was the problem with metaclass:
   ```python
           with DAG(dag_id='xcomargs_test', default_args={"start_date": 
datetime.today()}):
               op1 = DummyOperator(task_id="op1")
               op2 = CustomOp(task_id="op2")
               op2.field = op1.output  # value is set after init
   
           assert op1 in op2.upstream_list
   ```
   this needs to be solved also: 
https://github.com/apache/airflow/pull/8805#discussion_r423205936
   
   But this hints another possible solution without metaclass:
   ```python
   class BaseOperator():
       def __setattr__(self, key, value):
           super().__setattr__(key, value)
           # Resolve upstreams set by assigning an XComArg after initializing
           # an operator, example:
           #   op = BashOperator()
           #   op.bash_command = "sleep 1"
           from airflow.models.xcom_arg import XComArg
           if key in self.template_fields:
               self.set_xcomargs_dependencies()
   ```
   This one is nice and simple, however I am not sure if this will degradate 
performance in any way .
   
   @evgenyshulman @casassg @ashb @mik-laj thoughts? 


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


Reply via email to