f_rich_progress不吃掉python prompt; evalutor在结束之后正常消失progres bar

This commit is contained in:
yh_cc 2022-04-11 23:11:52 +08:00
parent 388e426d78
commit d10c6395f2
2 changed files with 3 additions and 3 deletions

View File

@ -219,6 +219,7 @@ class Evaluator:
def remove_progress_bar(self, dataloader_name):
if self.progress_bar == 'rich' and hasattr(self, '_rich_task_id'):
f_rich_progress.destroy_task(self._rich_task_id)
f_rich_progress.refresh() # 使得最终的bar可以消失
delattr(self, '_rich_task_id')
elif self.progress_bar == 'raw':
desc = 'Evaluation ends'
@ -229,6 +230,7 @@ class Evaluator:
def finally_progress_bar(self):
if self.progress_bar == 'rich' and hasattr(self, '_rich_task_id'):
f_rich_progress.destroy_task(self._rich_task_id)
f_rich_progress.refresh()
delattr(self, '_rich_task_id')
@property

View File

@ -94,9 +94,6 @@ class FRichProgress(Progress, metaclass=Singleton):
self.print = self.console.print
self.log = self.console.log
# start new
self.start()
self.console.show_cursor(show=True)
return self
def set_transient(self, transient: bool = True):
@ -154,6 +151,7 @@ class FRichProgress(Progress, metaclass=Singleton):
super().start()
self.console.show_cursor(show=True)
if (sys.stdin and sys.stdin.isatty()) and get_global_rank() == 0:
f_rich_progress = FRichProgress().new_progess(
"[progress.description]{task.description}",