mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-28 19:27:47 +00:00
15 lines
344 B
Python
15 lines
344 B
Python
|
|
from tqdm import tqdm
|
||
|
|
import ray
|
||
|
|
|
||
|
|
def parallel_compute_with_bar(computations) -> list:
|
||
|
|
|
||
|
|
def to_iterator(obj_ids):
|
||
|
|
while obj_ids:
|
||
|
|
done, obj_ids = ray.wait(obj_ids)
|
||
|
|
yield ray.get(done[0])
|
||
|
|
|
||
|
|
ret = []
|
||
|
|
for x in tqdm(to_iterator(computations), total=len(computations)):
|
||
|
|
ret.append(x)
|
||
|
|
|
||
|
|
return ret
|