chronitis commented on issue #5231: [AIRFLOW-4456] Add BranchOperator URL: https://github.com/apache/airflow/pull/5231#issuecomment-489062169 I take the comment that this logic shouldn't be duplicated between this operator and `BranchPythonOperator` - I'll look at a better way of avoiding duplication. The reason for not subclassing `BranchPythonOperator` was that creating a bound reference to the method in `__init__` seems to cause issues with templating: ```python class MyBranch(BranchPythonOperator): template_fields = ('myvar', ) def __init__(self, myvar, **kwargs): self.myvar = myvar super().__init__(python_callable=self.choose_branch) def choose_branch(self): # for reasons I'm not totally clear on, but I'm guessing the reference to `self` before `super()` # has returned creates a closure, any {{ templates }} in `self.myvar` here don't get evaluated return self.myvar ``` Less importantly, it seems a bit inelegant to need to pass a reference to the method like this.
---------------------------------------------------------------- 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
