- Medium: It contributes to significant difficulty to complete my task, but I can work around it.
Do ray remote functions output results in correct order?
If I call
ray.get([do_some_work.remote(x) for x in range(2)]
do_some_work(1) finishes earlier than
do_some_work(0), will I get:
I would like to get option (b), so if the answer is (a), is there a way to make enforce that I get option (b)?
Taking code from the Ray tutorial “Tips for first-time users”:
@ray.remote def do_some_work(x): time.sleep(random.uniform(0, 4)) # Replace this with work you need to do. return x data_list = ray.get([do_some_work.remote(x) for x in range(4)])
do_some_work takes a variable amount of time, will Ray know I want the results to be:
[do_some_work(0), do_some_work(1), do_some_work(2), do_some_work(2)]
or will it output in the order of whichever job finishes earlier?