graphai.core.utils.progress_bar module

class graphai.core.utils.progress_bar.ProgressBar(n_iterations, bar_length=50)

Bases: object

Class representing a progress bar to keep track of execution progress. Usage is as follows:

>>> letters = ['a', 'b', 'c', 'd']
>>> pb = ProgressBar(len(letters))
>>> for letter in letters:
>>>     # Run some time-consuming tasks
>>>     pb.update()
[############......................................] 25.00%
[########################..........................] 50.00%
[####################################..............] 75.00%
[##################################################] 100.00%

This prints at each iteration a progress bar and the percentage of completion, overwriting the previous one.

The state of progress ban be reset as follows:

>>> letters = ['a', 'b', 'c', 'd']
>>> ...
>>> pb = ProgressBar(len(letters))
>>> for letter in letters:
>>>     # Run some time-consuming tasks
>>>     pb.update()
>>> ...
>>> pb.reset()
>>> for letter in letters:
>>>     # Run more time-consuming tasks
>>>     pb.update()
update()

Increments by one the iterations counter and prints the progress bar.

reset(n_iterations=None)

Resets the progress bar for reuse.

Parameters:

n_iterations (int) – Total number of iterations for completion.