Browse Source

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

tags/v1.0.0alpha
yh_cc 3 years ago
parent
commit
d10c6395f2
2 changed files with 3 additions and 3 deletions
  1. +2
    -0
      fastNLP/core/controllers/evaluator.py
  2. +1
    -3
      fastNLP/core/utils/rich_progress.py

+ 2
- 0
fastNLP/core/controllers/evaluator.py 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


+ 1
- 3
fastNLP/core/utils/rich_progress.py 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}",


Loading…
Cancel
Save