Cli: fence-posting problem
LecrisUT opened this issue · 0 comments
LecrisUT commented
- I have marked all applicable categories:
- documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
- new feature request
- I have visited the source website, and in particular
read the known issues - I have searched through the issue tracker for duplicates
- I have mentioned version numbers, operating system and
environment, where applicable:import tqdm, sys print(tqdm.__version__, sys.version, sys.platform)
Description
In order to first initialize the tqdm
progress bar in the shell environment there must be something output so that the tqdm starts to output to console. But if the commands in the loop are slow, it would not create the initial progress bar for a while.
Suggestion
There could be 2 ways around it
- have tqdm cli run once outside the loop with or without stdin but with the same format to create the initial progress-bar (fencepost issue)
- option to parse stdin through regex to trigger an increment or not, e.g.
r"Done (?P<it>\d+)/(?P<total>\d+)"
. Note the group names that can be used to extract other data for tqdm
Consideration
This approach would not be efficient, but the usecase here is especially for slow processes that are needed to be monitored, so this would not be an issue.