When multiprocessing, the main progress may fetch nothing from TaskManager because there are still some running tasks. So main progress should wait until all tasks are trained well by other progress or machines. Args: query (dict, optional): the query dict. Defa
(self, query={})
| 454 | return sum(task_stat.values()) |
| 455 | |
| 456 | def wait(self, query={}): |
| 457 | """ |
| 458 | When multiprocessing, the main progress may fetch nothing from TaskManager because there are still some running tasks. |
| 459 | So main progress should wait until all tasks are trained well by other progress or machines. |
| 460 | |
| 461 | Args: |
| 462 | query (dict, optional): the query dict. Defaults to {}. |
| 463 | """ |
| 464 | task_stat = self.task_stat(query) |
| 465 | total = self._get_total(task_stat) |
| 466 | last_undone_n = self._get_undone_n(task_stat) |
| 467 | if last_undone_n == 0: |
| 468 | return |
| 469 | self.logger.warning(f"Waiting for {last_undone_n} undone tasks. Please make sure they are running.") |
| 470 | with tqdm(total=total, initial=total - last_undone_n) as pbar: |
| 471 | while True: |
| 472 | time.sleep(10) |
| 473 | undone_n = self._get_undone_n(self.task_stat(query)) |
| 474 | pbar.update(last_undone_n - undone_n) |
| 475 | last_undone_n = undone_n |
| 476 | if undone_n == 0: |
| 477 | break |
| 478 | |
| 479 | def __str__(self): |
| 480 | return f"TaskManager({self.task_pool})" |
no test coverage detected