Hi folks... I have a `@dynamic` task that calls a ...
# ask-the-community
r
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
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
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
You cannot access result
As it is not materialized yet
r
so how do I structure this?
k
Want to jump on a call
r
Is dynamic the wrong construct?
sure
k
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
Sure... let me know when to hop on
And if you want to do condition
r
got it.. let me try this with conditions
instead of dynamic
k
Got it
r
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
You cannot do truth value directly
But for Boolean you can do is_true
r
ah
k
@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
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
Ya but that is weird what do you want to do in then
r
I got it to work.. so not a problem.. just found it a bit strange, that's all 🙂
232 Views