Edinburgh-Genome-Foundry / Proglog

:memo: Logs and progress bars manager for Python
MIT License
107 stars 5 forks source link

Accessing estimated time left within inherited ProgressBarLogger #3

Open yaljazairi opened 1 year ago

yaljazairi commented 1 year ago

I was using MoviePy to concatenate some videos with each other and reached the point when I must get the percentage values of the progress bar. After searching for a solution I concluded that it was using the default_bar_logger in order to show Rendering process in bars view.

For this reason I inherited the ProgressBarLogger in a Python class and could until now only get the percentage value of rendering. The question is: How could we get the value of the estimated time left until rendering is finished (which comes between [ ]. e.g: 02:05<05:00 )?


| 68/100 [00:05<00:02, 12.55it/s, now=None]

Here's the implemented logger:


from proglog import ProgressBarLogger

class MyLogger(ProgressBarLogger):
    def callback(self, **changes):
        for (parameter, value) in changes.items():
            print (f"{value}")

    def bars_callback(self, bar, attr, value, old_value=None):
        percentage = (value / self.bars[bar]['total']) * 100
        print(f"percentage: {int(percentage)}")

Output:


percentage: 1
percentage: 2
percentage: 3
.
.
percentage: 100

For now I'm only able to get the percentage value correctly but have no idea how to reach estimated time left!

I would appreciate your help for this matter. Thanks in advance!

Zulko commented 1 year ago

How could we get the value of the estimated time left until rendering is finished

I don't believe Proglog enables this for now, two possible ways to solve this would be

velocity = loops_since_last_iterations / duration_since_last_iteration
estimated_time = number_of_iterations_left / velocity