kazanzhy commented on a change in pull request #20071:
URL: https://github.com/apache/airflow/pull/20071#discussion_r765034631



##########
File path: airflow/operators/python.py
##########
@@ -248,7 +248,7 @@ def execute(self, context: Dict):
 
         if condition:
             self.log.info('Proceeding with downstream tasks...')
-            return
+            return condition

Review comment:
       I can't see where defined that ShortCircuitOperator's callable should 
return only boolean.
   Maybe I'm missing something.
   Here is an example of what I mean. In the first case, callable returns a 
non-empty string, and ShortCircuitOperator passes.
   In the second case return value is the empty list, which is casts as False.
   
   ```
   from datetime import datetime
   from airflow.models import DAG
   from airflow.operators.python import ShortCircuitOperator
   from airflow.operators.dummy import DummyOperator
   
   with DAG('test_short_circuit_dag', start_date=datetime(2021, 12, 7)) as dag:
       circuit_true = ShortCircuitOperator(task_id='circuit_true', 
python_callable=lambda: 'signature')
       check_true = DummyOperator(task_id='check_true')
       circuit_true >> check_true
   
       circuit_false = ShortCircuitOperator(task_id='circuit_false', 
python_callable=lambda: [])
       check_false = DummyOperator(task_id='check_false')
       circuit_false >> check_false
   ```
   
   <img width="303" alt="Screenshot 2021-12-08 at 18 33 19" 
src="https://user-images.githubusercontent.com/10523218/145247230-f0692172-e847-4ea2-a102-6f0ce550fba4.png";>




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to