Closed bfernando1 closed 2 years ago
Thank you for raising this feature request. To be sure I understand correctly. In this example, you want to see the title as "random_sleep"?
nr_with_processors = nr.with_processors([RichProgressBar()])
result = nr_with_processors.run(task=random_sleep)
@ubaumann Yes, that's right! I think passing our own description for the task being run would be effective. That way we can freely re-use a task in different contexts with the progress bars.
If we move some of the init tasks to start we could read task.name and use that value. This way it can be set simply by normal usage of nornir.run(name="some task name", task=sometask)
I made a quick test and put it in a pull request #6 Is it as you imagined it? I put both panels in a variable so that in the future we can also change the color of the panel from yellow to red as soon as a task fails or other functions.
from time import sleep
from nornir_rich.progress_bar import RichProgressBar
def random_sleep(task: Task) -> Result:
delay = randrange(10)
sleep(delay)
return Result(host=task.host, result=f"{delay} seconds delay")
nr.data.reset_failed_hosts()
nr_with_processors = nr.with_processors([RichProgressBar()])
result = nr_with_processors.run(task=random_sleep)
I like it. Nice work.
Merged. So I close this issue. Will try to realease a new release soon
Feature Request I'd like to see the title: Overall Progress be substituted with the current task. This would help me see which task is being worked on.