Closed bmabey closed 8 years ago
Sounds super useful! I would suggest adding time_format
parameter to ProgBar
and ProgPercent
that takes values 'seconds', 'hours', 'days', 'weeks' etc.
Here is a quick & dirty example of what I have in mind:
def get_time(seconds, time_format='seconds'):
timestr = str(seconds)
if format == 'minutes':
minutes = seconds // 60
seconds = seconds % 60
timestr = '%02d:%02d' % (minutes, seconds)
if format == 'hours':
pass
# not implemented yet
if format == 'days':
pass
# not implemented yet
return timestr
>>> get_time(123, time_format='minutes')
02:03
Do you want to add a function like this?
Or alternatively, using strftime
:
import time
def get_time(seconds, strftime='%H:%M:%S'):
# add days
if seconds >= 86400:
strftime = '%d:' + strftime
seconds -= 86400
# add weeks
# add months
# add years
return time.strftime(strftime, time.gmtime(seconds))
>>> print(get_time(123456))
01:10:17:36
Just need to be careful to deal with the overflow, e.g,.
>>> print(get_time(123456789999999))
shouldn't return
07:09:46:39
How should year, month and week be displayed? One way I think can be to display years, weeks, days, hours, minutes and seconds as YY:WW:DD::HH:MM:SS.
Hm, I am not sure if we necessarily need to add days, weeks, and years. I am afraid that the command line output will be to wide in this case. I really think hours would already by sufficient; people are running tasks not more than a few days at max, and E.g., if the output is 168:00:00
, it's also kind of obvious that it's a week -- the PBS scheduler is using the same h:mm:ss
output btw, which most people are familiar with.
The suggestions have been addressed in pull request #19
Thanks everyone!
It would be helpful if long running tasks could display the ETA like: ETA: 1 hour, 23 min, 40 sec
Or something like that.
WDYT?