Progress bar time remaining goes missing when progress_regex not a match
simularis opened this issue · comments
- OS: windows 11 x64
- Python Version: 3.10.6
- Gooey Version: 1.2.1-release branch
- Thorough description of problem
- Expected Behavior
When using progress bar and'show_time_remaining':True
, console lines not matching theprogress_regex
should be ignored and not affect the time remaining display based on last matching progress update. - Actual Behavior
Console lines not matching theprogress_regex
cause the time remaining to disappear until the next matching line.
- Expected Behavior
- A minimal code example
- Screenshot (if visual quirk)
- Anything else you may think will be helpful
Minimal code example
from time import sleep
from gooey import Gooey, GooeyParser
from itertools import cycle
@Gooey(
terminal_font_family='Courier New',
progress_regex=r"^progress: (?P<current>-?\d+)/(?P<total>\d+)$",
progress_expr="current / total * 100",
timing_options={
'show_time_remaining':True,
'hide_time_remaining_on_complete':False
})
def parse_args():
parser = GooeyParser(prog="example_progress_bar_5")
parser.add_argument("alpha", type=float, help="Seconds per 10% progress", default=1)
parser.add_argument("beta", type=int, help="Extra messages between progress updates",default=3)
parser.add_argument("gamma", type=str, nargs='+', help="List of your messages",
default=["info ...", "message ...", "warning ..."])
args = parser.parse_args()
return args.alpha, args.beta, args.gamma
def main():
alpha, beta, gamma = parse_args()
myprocess = cycle(gamma)
print("Step 1")
for i in range(0, 51, 10):
sleep(alpha)
print("progress: {}/{}".format(i,100),flush=True)
print("Step 2")
for i in range(50, 101, 10):
sleep(alpha / (beta+1))
for j in range(beta):
# some extra text before progress
print(next(myprocess),flush=True)
sleep(alpha / (beta+1))
print("progress: {}/{}".format(i,100),flush=True)
if __name__ == "__main__":
main()
Screenshots
What | Screenshot |
---|---|
Console | ![]() |
Progress bar during step 1 (progress messages only) | ![]() |
Progress bar during step 2 (progress messages and other messages) | ![]() |
Relevant excerpts
ProcessController
Lines 114 to 129 in be4b11b
Lines 152 to 162 in a451f52
Timing
Lines 19 to 25 in a451f52
Suggested fix
Update gooey/gui/util/time.py:
@@ -19,7 +19,7 @@ class Timing(object):
def _updateEstimate(self, *args, **kwargs):
prog = kwargs.get('progress')
if(not prog):
- self.estimatedRemaining = None
+ # self.estimatedRemaining = None
return
if(prog > 0):
self.estimatedRemaining = estimate_time_remaining(prog,self.startTime)