Is there possible to run `tasks` inside `tasks` an...
# prefect-community
a
Is there possible to run
tasks
inside
tasks
and
flows
inside
tasks
? I was able to call a
flow
inside a task but got a
ValueError: Could not infer an active Flow context
error every time I tried to send parameters to the
flows
from the
tasks
. Got the same error when calling a
task
within a
task
.
c
Hi @Argemiro Neto, I’d be super interested in hearing your use case for needing this - I think there are some users who have got something like this to work, but it is currently not a first class feature
a
What I am trying to accomplish is grouping some common tasks inside a unique
flow
and then call that from a
task
c
is there a reason you can’t include those tasks directly in your “parent” Flow? Check out
flow.update
for easily combining multiple flows into one Flow: https://docs.prefect.io/api/unreleased/core/flow.html#prefect-core-flow-flow-update
a
Thank you for the tip, I'll check it out. The idea is reusing some common tasks through multiple stages of the flow instead of repeating every time
👍 1
hey, @Chris White! I checked the
update
function. I need to map the task results in a sequence of tasks with data dependency (flow like) between them. This sequence should run independently of each other. At this point, I'm running the first flow, checking the results outside
prefect
and then running a loop with
second_flow.run()
for each item. Is there a way to dynamically import tasks from a flow setting the
Paramters
or a better way than mixing
prefect
with raw python?
c
I’m afraid I don’t understand the setup you’re describing; could you provide some more detail?
a
Sure! My workflow should be: 1. fetch from a database a list of activities to run (json files). 2. Perform some
tasks
on all the items, like, updating
timestamp
. 3. The application should stop if #1 or #2 fails. 4. Run a series of tasks on each activity from #2. If one of the tasks from one activity fails it should not fail the other activities' tasks.