https://flyte.org logo
#ask-the-community
Title
# ask-the-community
r

Rupsha Chaudhuri

06/13/2022, 6:03 PM
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

Ketan (kumare3)

06/13/2022, 7:32 PM
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

Rupsha Chaudhuri

06/13/2022, 7:54 PM
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

Ketan (kumare3)

06/13/2022, 11:11 PM
@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

Rupsha Chaudhuri

06/13/2022, 11:22 PM
I had foo_node = create_node(foo) c >> foo_node gave me the error
k

Ketan (kumare3)

06/14/2022, 4:36 AM
hmm
i did not try that
cc @Kevin Su
👀 1
k

Kevin Su

06/14/2022, 5:19 AM
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

Rupsha Chaudhuri

06/14/2022, 4:23 PM
Thanks for clarifying
👍 1
79 Views