Tim Galvin
06/21/2024, 8:37 AM.map
interface. Is there a way to make task B wait on the corresponding item from task A to finish via the wait_for=
argument?
numbers = list(range(100))
a_futures = task_a.map(numbers)
b_futures = task_b.map(numbers, wait_for=a_futures)
My understanding is that in this case that task_b will wait for all items in the list provided to wait_for
to finish before starting task b.
This is a contrived example. Yes, I could change the signature for task_b to accept outputs form task_a. I have done this, but it feels smelly as a lot of the output is not needed.Nate
06/21/2024, 2:22 PMb_futures
would wait on the `i`th future from a_futures
?Kevin Grismore
06/21/2024, 2:25 PM.submit
those two tasks in sequence, having B wait_for
the future from A in each iteration. Maybe nate has a nicer answer thoughTim Galvin
06/21/2024, 3:27 PM.map
interface is very clean and makes life a breeze. I am just unsure what the best way to do things is. In this example it is trivial to 'make' task b accept some input from task a and ignore it, but for some more complex things it may be a little uglyTim Galvin
06/21/2024, 3:28 PM.submit
would be workable as well, but it can get ugly quick. If there was something like an unmapped
bur for the wait_for
that would be exactly what I am looking forNate
06/21/2024, 4:41 PMTim Galvin
06/22/2024, 9:07 AMtelescope_mss = glob("*.ms")
image_data = image_ms_data.map(ms=telescope_mss)
zip = zip_ms_data.map(ms=telescope_mss, wait_for=image_data)
This is kind of the situation I see myself lurking around. I love using the .map interface, it makes the code very readable and easy to follow. In the above situation I can not zip the measurement sets (these nasty radio-telescope formats that are folders in folders, many small files and many big files that HPCs absolutely hate) until the imaging is finished.
Although I could pass the image_data future into the input of zip_ms, it would mean I either have to modify the return of image_ms_data
and updated what zip_ms
expects, or add a dummy arg input to make dependency that way.
This type of use case pops up a little for me. As I try to convinces the powers the be that we have a workable maintainable solution I'd love to keep my usage of prefect as consistent as possible.Nate
06/22/2024, 4:18 PMTim Galvin
06/23/2024, 3:37 AM