Conditional task #36479
Replies: 1 comment 4 replies
-
I personally like it (and yes. I share the sentiment of not liking the separate branch operator/task). Generally I think the concept is pretty sound and having a way that would conditionally skip execution of ANY operator (but otherwise not impacting the structure of the DAG) sounds rather appealing to me. I think we could make it a little more sophisticated however, and nicer integrated into taskflow and with a little bit better syntactic sugar to make it look nicer. Simply, the example you show is just super-ugly and difficult to read. Possibly we could even add it as a callable in the BaseOperator and any of our taskflow decorator that you could add so that it might look like: Classic: t1 = AnyOprator(task_id='task', run_if=lambda context: randint(0, 1) == 0) TaskFlow: @task.run_if(lambda context: randint(0, 1) == 0)
@task.python Maybe naming could be a bit better and probably we could even pass I see no particular problem with that approach, I think it would be quite powerful to implement some "cross-cutting" skipping behaviour independent from the operator implementation. There are probably some caveats:
I wonder what others think (@dstandish @Taragolis @uranusjr @ephraimbuddy @josh-fell - calling the usual culprits who were usually implementing the decorators/syntactic sugar around the operator's use). |
Beta Was this translation helpful? Give feedback.
-
I never liked the need of a separate branch task to conditionally execute another task and was thinking of a way to somehow decorate/enhance an arbitrary operator to skip it on condition.
Finally I came up with something that worked:
Visually it looks okay to me and having run a simple test it looks to be working correctly...
But not being super advanced in Python I'm wondering if this is maybe too hacky, or prone to some errors or issues? Or not reasonable at all?
Beta Was this translation helpful? Give feedback.
All reactions