Hi all,
I have a question about Orion, is there a way to call tasks from other tasks? In prefect 1.0 it's possible to call
some_task.run(args)
from other tasks and it's very handy, cause very often it's necessary to call existing tasks (especially from prefect task library) deep inside other tasks. in Orion I didn't find how to do that, but pretty sure there should be some way?
j
Jeff Hale
08/20/2022, 9:01 PM
SEE UPDATED ANSWER LOWER IN THREAD
You can accomplish the same thing in Prefect 2, but you might just do it differently.
In Prefect 2 the docs say that “Tasks may not be called from other tasks.”
However now you can easily use subflows, calling one flow from another flow.
Alternatively, you can write logic in your flow to call various tasks:
Copy code
@Flo()
def my_flow():
result = task1()
if result == 1:
task2()
elif result == 2:
task3()
else:
task4()
In Prefect 2 there isn’t a task library, but Blocks and Collections can be integrated into your tasks and flows and let you reuse configuration. Blocks can save you from needing to call functions to get configuration information.
🙏 1
b
Ben Muller
08/21/2022, 1:38 AM
You can use
.fn()
🙌 1
j
Jeff Hale
08/21/2022, 12:14 PM
@Ben Muller is correct. That was my initial thought, too, but then I checked the docs. Looks like we need to update the docs. 🙂
@vk, here’s an example of how you can call the transform task from within another task
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.