<@ULVA73B9P> can I use wait_for when doing `.map()...
# ask-marvin
t
@Marvin can I use wait_for when doing
.map()
? do I need to pass unmapped to my args in wait_for?
m
Certainly! You can use
wait_for
when using the
.map()
function in Prefect. Mapping in Prefect creates individual task runs for each element in the input data. If your mapped function needs to wait for a previous task to complete, you can specify this with
wait_for
. Regarding your second question: when using
wait_for
in conjunction with
.map()
, if you want to provide a static value (i.e., a value that shouldn’t be iterated over) to your tasks, you would indeed use
unmapped
. The
unmapped
function wraps your static argument to ensure that it's treated as a constant across all mapped tasks rather than being iterated. Here are some docs that cover these concepts in both Prefect 2.x and 3.x: - For Prefect 3.x, the idea of using
.map()
for handling iterables and the use of
unmapped
for static values is discussed in this document. - A similar explanation for Prefect 2.x can be found here, highlighting examples of task mapping and handling static arguments. Let me know if there's anything else you'd like to unravel from the depths of this automation galaxy!
n
to clarify • yes • no, as in the stuff you pass to
wait_for
does not need to be annotated with
unmapped
unmapped is only for arguments to
map
that you do not want to map over
🙌 1
t
awesome, thank you nate!