An Hoang
07/28/2021, 3:47 PMSKIP
signal inside the task or 2) use conditional task case
. I have provided the two scenarios on this gist https://gist.github.com/hoangthienan95/e0d8c3d73cb25f90f0d427c689ea80d8/revisions?diff=unified, along with the flow visualizations
In the Gist, initial version is SKIP
signal, and the second version are the modifications to make it use case
. I have tested both of the flows, they work and both satisfy my requirements so far, so is there any caveats I haven't thought of or best practices that I should consider to choose one over the other?An Hoang
07/28/2021, 3:49 PMKevin Kho
target
will not run the task if the file already exists and will load it from the file. If you want to manually check and decide to skip, raise SKIP
is better inside a task. case
would do it on the Flow level. Both will work. I think it’s just a matter of where you want that logic to take place (task or flow-level)
I opened the links. It’s a bit hard to follow.An Hoang
07/28/2021, 4:05 PMcase=False
(no result outputted), and task B -> task C if case=True
, is the following code an anti-pattern of some sort?
with case(cond, False):
task_A_result = task_A()
task_B_result_false = task_B() #task_B loads a partial result from the file task_A outputted, but is not passed `task_A_result`
task_C_result_false= task_C(task_B_result_false)
with case(cond, True): #file exist, skip A
task_B_result_true = task_B()
task_C_result_true= task_C(task_B_result_true)
task_C_result = merge(task_C_result_false, task_C_result_true)
Kevin Kho
task_A()
needs to be inside the case right? task_B()
and task_C()
will run regardless so they don’t need to be part of the case statement?An Hoang
07/28/2021, 4:28 PMtask A
upstream of task B
and task C
but I forgot I could do like below:
with case(cond, False):
task_A_result = task_A()
task_B_result = task_B()
task_B_result.set_upstream(task_A_result)
task_C_result = task_C(task_B_result)
even when the case
might evaluates to True
. In if/else
equivalent it would complain about the task_A_result
variable not declared, but we are building a DAG that will be evaluated later 😄
This is one of the "gotchas" that would be a helpful addition to the beginner's tutorial or the case
documentation 🙂An Hoang
07/28/2021, 4:28 PMKevin Kho