Closed rkrutyholowa closed 3 years ago
Whilst progress bars are useful, they tend to not play nicely with output logs. Instead I've added a function that will monitor progress and report the percentage complete in ~5% increments.
E.g.
SIMBAD version: 0.2.2 Running with CCP4 version: 7.1 from directory: /Users/adamsimpkin/opt/ccp4-20210118 Running on host: 192.168.1.108 Running on platform: Darwin-20.2.0-x86_64-i386-64bit Job started at: Thu, 28 Jan 2021 19:23:47
Invoked with command-line: simbad-contaminant -nproc 4 -organism CHICK input/2fbb.mtz
Running in directory: /Users/adamsimpkin/dev/SIMBAD/examples/contaminant_example/SIMBAD_0
Working on chunk 1 out of 1 Running PHASER rotation functions Percentage complete: 0.0% Percentage complete: 10.3% Percentage complete: 20.5% ...
This should hopefully make it into CCP4 before too long.
I think it would be great to let your users know how much time/database records are left until SIMBAD finishes the job. I'm currently running it for >1 week on 4 cores of Intel Xeon and yet I still have no idea how long it will take. Something like this could work:
`# Print iterations progress - from https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"): """ Call in a loop to create terminal progress bar @params: iteration - Required : current iteration (Int) total - Required : total iterations (Int) prefix - Optional : prefix string (Str) suffix - Optional : suffix string (Str) decimals - Optional : positive number of decimals in percent complete (Int) length - Optional : character length of bar (Int) fill - Optional : bar fill character (Str) printEnd - Optional : end character (e.g. "\r", "\r\n") (Str) """ percent = ("{0:." + str(decimals) + "f}").format(100 (iteration / float(total))) filledLength = int(length iteration // total) bar = fill filledLength + '-' (length - filledLength) print('\r%s |%s| %s%% %s \r' % (prefix, bar, percent, suffix), end = printEnd)
Print New Line on Complete
import sys import time
l = 60
Initial call to print 0% progress
printProgressBar(0, l, prefix = 'Progress:', suffix = 'Complete', length = 50) for i in range(l):
Do stuff...
`
In general - good code, thanks for making it available!