'Don't estimate total runtime with tqdm

I'm using tqdm to generate the progress bar for a loop where iterations take an increasing amount of time with increasing value of the iterator. The iterations per second and estimated completion metrics are thus not particularly meaningful, as previous iterations cannot (easily) be used to predict the runtime of future iterations.

Is there an easy way to disable displaying the estimation of iterations per second and total runtime with tqdm?

Relevant example code:

from tqdm import tqdm
import time

for t in tqdm(range(10)):
    time.sleep(t)


Solution 1:[1]

tqdm's README describes the bar_format argument as follows:

Specify a custom bar string formatting. May impact performance. [default: '{l_bar}{bar}{r_bar}'], where l_bar='{desc}: {percentage:3.0f}%|' and r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]'...

Since the part you don't care about is mostly in "{r_bar}", you can just tweak that part of the default value as follows to omit [{elapsed}<{remaining}, {rate_fmt}:

from time import sleep
from tqdm import tqdm

for time in tqdm(range(10),
                 bar_format = "{l_bar}|{bar}| {n_fmt}/{total_fmt}{postfix}"):
    sleep(time)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Casey Jones