https://flyte.org logo
r

Rupsha Chaudhuri

06/09/2022, 8:20 PM
Hi folks... I have a
@dynamic
task that calls a
@task
task that's expected to return a dict. Instead I'm getting a
flytekit.core.promise.Promise
object back. I also don't see any of the logs from that task.. nor do I see the called task executing on the console. What's weird is that the same called task works as expected when invoked from other tasks in the same workflow. Can someone help me understand why a task would not execute and return a Promise instead?
k

Ketan (kumare3)

06/09/2022, 9:11 PM
Can you share the snippet
In dynamic every task execution is deferred till the main dynamic workflow/ task returns
So everything will be a promise
You can return multiple promises
r

Rupsha Chaudhuri

06/09/2022, 9:15 PM
this is what I have... more or less
Copy code
@dynamic
def task_a(flag: bool):
    res = ""
    if flag:
        result = task_b(some params)
        res = result["field"]
    return res
k

Ketan (kumare3)

06/09/2022, 9:15 PM
You cannot access result
As it is not materialized yet
r

Rupsha Chaudhuri

06/09/2022, 9:16 PM
so how do I structure this?
k

Ketan (kumare3)

06/09/2022, 9:16 PM
Want to jump on a call
r

Rupsha Chaudhuri

06/09/2022, 9:16 PM
Is dynamic the wrong construct?
sure
k

Ketan (kumare3)

06/09/2022, 9:16 PM
Depends
To join the video meeting, click this link: https://meet.google.com/yve-weib-mjg To join by phone instead, dial ‪(US) +1 575-395-6435‬ and enter this PIN: ‪139 996 170#‬ More phone numbers: https://tel.meet/yve-weib-mjg?pin=7996454642344
Actually wait
Let some else join
r

Rupsha Chaudhuri

06/09/2022, 9:18 PM
Sure... let me know when to hop on
And if you want to do condition
r

Rupsha Chaudhuri

06/09/2022, 9:22 PM
got it.. let me try this with conditions
instead of dynamic
k

Ketan (kumare3)

06/09/2022, 9:24 PM
Got it
r

Rupsha Chaudhuri

06/09/2022, 9:31 PM
Not sure about the syntax when using create_node.. but let me try it first
thanks @Ketan (kumare3)
Looks like I can't use conditional.. since it depends on the output of a previous node
Copy code
Flytekit does not support unary expressions of the form `if_(x) - where x is an input value or output of a previous node.
k

Ketan (kumare3)

06/09/2022, 9:41 PM
You cannot do truth value directly
But for Boolean you can do is_true
r

Rupsha Chaudhuri

06/09/2022, 9:41 PM
ah
k

Ketan (kumare3)

06/09/2022, 9:42 PM
@workflow def bool_input_wf(b: bool) -> int: return conditional("test").if_(b.is_true()).then(success()).else_().then(failed())
This is shortcoming in python operator system
r

Rupsha Chaudhuri

06/09/2022, 9:42 PM
alright.. let me try this
this worked.. thank you!
I did end up having to write a "hacky" task that takes a string and returns the same string because .then() also needs a task
k

Ketan (kumare3)

06/09/2022, 11:04 PM
Ya but that is weird what do you want to do in then
r

Rupsha Chaudhuri

06/09/2022, 11:05 PM
I got it to work.. so not a problem.. just found it a bit strange, that's all 🙂
21 Views