yuqian90 commented on pull request #10153:
URL: https://github.com/apache/airflow/pull/10153#issuecomment-689468941


   > The lack of indentation was on purpose to check if `TaskGroup` works well 
with `>>` between `XComArg` which is returned by invoking `my_task()`:
   > 
https://github.com/apache/airflow/blob/aaf56f9816ed72e18a3215183c185d379b4e4247/airflow/operators/python.py#L291
   > 
   > At least typing here is missing `TaskGroup`:
   > 
https://github.com/apache/airflow/blob/aaf56f9816ed72e18a3215183c185d379b4e4247/airflow/models/xcom_arg.py#L118-L130
   
   
   Hi @turbaszek, thanks for pointing out. In order to demonstrate `TaskGroup` 
working with `@task` and making sure it continues to work, I added 
`test_build_task_group_with_task_decorator` in `test_task_group.py`. Please see 
if that's in line with what you have in mind.
   
   That said, I noticed two small issues that's not related to `TaskGroup`, but 
rather to `XComArg`:
   
   1. This function inside `xcom_args.py` returns `self` instead of `other` 
(which is what `BaseOperator` does).
   
   ```
       def __rshift__(self, other):
           """
           Implements XComArg >> op
           """
           self.set_downstream(other)
           return self
   ```
   
   2. `BaseOperator` `__lshift__` and `__rshift__` do not handle `XComArg`.
   
   As a result, it effectively prevents us from chaining operators like this:
   ```
   tsk_1 >> group234 >> tsk_5
   ```
   
   I.e. we would intuitively expect the above line to put `tsk_5` downstream of 
`group234`. But because `tsk_1` is a `XComArg`, what this line actually does is 
very surprising. It puts both `group234` and `tsk_5` downstream of `tsk_1`. 
I.e. it's equivalent to doing this, which is what I added in the test.
   ```
   tsk_1 >> group234
   tsk_5 << group234
   ```
   
   I'm not sure if this is a bug or a `XComArg` feature. Since it's not a 
`TaskGroup` issue, the change (if any) should probably be done separately in a 
different PR.


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


Reply via email to