Created
February 1, 2023 20:07
-
-
Save xiaohan2012/dc78d280ca73dd0b3b4248b814feb245 to your computer and use it in GitHub Desktop.
Progress bar in Ray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ray | |
from tqdm import tqdm | |
class RayProgressBar: | |
@staticmethod | |
def num_jobs_done_iter(obj_ids): | |
while obj_ids: | |
done, obj_ids = ray.wait(obj_ids) | |
yield ray.get(done[0]) | |
@staticmethod | |
def show(obj_ids): | |
seq = RayProgressBar.num_jobs_done_iter(obj_ids) | |
for x in tqdm(seq, total=len(obj_ids)): | |
pass | |
@staticmethod | |
def check(): | |
assert ray.is_initialized() | |
# usage: | |
# obj_ids = [func.remote() for _ in range(10)] | |
# RayProgressBar.show(obj_ids) | |
# res = ray.get(obj_ids) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment