Sorry, another question: what is an flyte-way of r...
# ask-the-community
x
Sorry, another question: what is an flyte-way of running a flyte task inside a non-flyte function but avoiding the
promise
handling issue due to the flyte task returning a promise that the non-flyte function doesn’t know how to handle? Example:
Copy code
@dynamic
def flyte_task():
   return something

def non_flyte_func():
   add_one = 1 + flyte_task()
   return add_one
If run remotely as it, it would error out with an error like
Unsupported operand type for +: int and Promise
. In my use case, it’s not easy to convert
non_flyte_func
to flyte task
e
A fully eager mode is being worked on right now that will allow you to avoid promises all together. But until then there are two options that I know of. 1. Use dynamic tasks to work directly with inputs and then use tasks inside to combine the promises that come from tasks. This sounds like it isn’t an option for you. 2. Try using flyte remote to call registered workflows and wait to inspect outputs. https://docs.flyte.org/projects/flytekit/en/latest/remote.html.
x
Thanks! I actually prefer option 1. I’ll try to refactor the code a little bit
e
Good luck! If you run into issues feel free to post more code and I’ll try to assist.
x
thanks!
Option1 worked! I basically wrapped add_one in another tasks so like
Copy code
@dynamic
def flyte_task():
   return something

@task
def add_one(x):
   return x + 1

def non_flyte_func():
   add_one = add_one(x=flyte_task())
   return add_one
101 Views