https://prefect.io logo
Title
k

kasteph

05/22/2023, 3:15 PM
d

Deceivious

05/22/2023, 3:23 PM
Yea
k

kasteph

05/22/2023, 3:29 PM
what if subflows have to be dynamically created as in a for-loop?
would it work just as well to do like so:
parallel_subflows = []
for s in stuff:
   subflow = subflow_func(s)
   parallel_subflows.append(subflow_func())
await asyncio.gather(*parallel_subflows)
It's the same
k

kasteph

05/22/2023, 4:22 PM
Neither the Prefect example nor mine use a list comprehension
d

Deceivious

05/22/2023, 4:33 PM
Ah yes but you can pass dynamic args and it'll work
k

kasteph

05/22/2023, 4:34 PM
thanks, testing it now!
n

Nate

05/22/2023, 7:53 PM
in case you want your subflows to be a standalone deployment @kasteph, i'll leave this here
k

kasteph

05/22/2023, 7:53 PM
wow, lifesaver :heart_hands:
:party-parrot: 1
@Nate could asyncio run the apply method of the deployment instead (assuming using
Deployment.build_from_flow
)? e.g.
asyncio.run(get_total_pokemon_weight_deployment.apply())
n

Nate

05/22/2023, 8:45 PM
it depends on whether the context you're calling from is async or sync. if you're in an sync context, you should just be able to call
get_total_pokemon_weight_deployment.apply()
- in async context you can just
await
it
shouldnt have to use
asyncio.run
i dont think
k

kasteph

05/22/2023, 10:13 PM
worked nicely, thanks 🙂
n

Nate

05/22/2023, 10:15 PM
👍