I have a workflow that has a conditional task A th...
# ask-the-community
r
I have a workflow that has a conditional task A that executes if some parameter is true. Then there is a task B that needs to execute after A. Is there a way to represent this dependency without defining a sub-workflow for A? Looks like I can't represent this as condition >> node (syntax error)
k
what do you mean
is it like this
Copy code
if true:
   A()
   B()
else:
   # do nothin
is it like this
Copy code
if true:
   A()
B()
r
The 2nd option But I need to make sure A() runs before B()
Another behavior that I just noticed
Copy code
variable c_out = C()
if true:
    A(c_out=c_cout)
A started running before C was done. Is that expected?
k
@Rupsha Chaudhuri both of those should just work
Example# 3 - shows using outputs from condition to chain
if for example 3 you do not want to pass outputs and use some chaining then
👍 1
let me see
@Rupsha Chaudhuri I just tried this, it worked
Copy code
from flytekit import task, workflow, conditional

@task
def foo():
    print("Called")


@task
def foo2():
    print("Called")

@workflow
def wf(b: bool):
    c = conditional("blah").if_(b.is_true()).then(foo()).else_().fail("haha")
    c >> foo()
r
I had foo_node = create_node(foo) c >> foo_node gave me the error
k
hmm
i did not try that
cc @Kevin Su
👀 1
k
Here the type of c is a promise, but the type of foo_node is a node. Therefore, it doesn’t work. It’s okay to use
c >> foo()
without creating node
Copy code
foo_node = create_node(foo)
c >> foo_node
r
Thanks for clarifying
👍 1
165 Views