diff options
author | Pjotr Prins | 2015-03-18 12:36:03 +0300 |
---|---|---|
committer | Pjotr Prins | 2015-03-18 12:36:03 +0300 |
commit | de84be30502af4be014fa4c0a2e7b54e51cff6f6 (patch) | |
tree | 604ed374e6061fcc524c9b85c71a30181e784bd6 /wqflask | |
parent | 6b8321d77e915dc5aec0c272c1cb84c2af3e6191 (diff) | |
download | genenetwork2-de84be30502af4be014fa4c0a2e7b54e51cff6f6.tar.gz |
Progress handler
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/my_pylmm/pyLMM/gn2.py | 19 | ||||
-rw-r--r-- | wqflask/wqflask/my_pylmm/pyLMM/standalone.py | 15 |
2 files changed, 27 insertions, 7 deletions
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/gn2.py b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py index f8033ac5..b487ea25 100644 --- a/wqflask/wqflask/my_pylmm/pyLMM/gn2.py +++ b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py @@ -12,17 +12,26 @@ import logging # logging.basicConfig(level=logging.DEBUG) # np.set_printoptions() +last_location = None +last_progress = 0 + def set_progress_storage(location): global storage storage = location def progress(location, count, total): - """ - Progress update - """ - storage.store("percent_complete",round(count*100.0)/total) - logger.info("Progress: %s %d%%" % (location,round(count*100.0/total))) + global last_location + global last_progress + + perc = round(count*100.0/total) + # print(last_progress,";",perc) + if perc != last_progress and (location != last_location or perc > 98 or perc > last_progress + 5): + storage.store("percent_complete",perc) + logger.info("Progress: %s %d%%" % (location,perc)) + last_location = location + last_progress = perc + def mprint(msg,data): """ Array/matrix print function diff --git a/wqflask/wqflask/my_pylmm/pyLMM/standalone.py b/wqflask/wqflask/my_pylmm/pyLMM/standalone.py index b3d480c3..7cc3e871 100644 --- a/wqflask/wqflask/my_pylmm/pyLMM/standalone.py +++ b/wqflask/wqflask/my_pylmm/pyLMM/standalone.py @@ -17,13 +17,24 @@ logger = logging.getLogger('lmm2') logging.basicConfig(level=logging.DEBUG) np.set_printoptions(precision=3,suppress=True) +last_location = None +last_progress = 0 + def set_progress_storage(location): global storage storage = location def progress(location, count, total): - storage.store("percent_complete",round(count*100.0)/total) - logger.info("Progress: %s %d%%" % (location,round(count*100.0/total))) + global last_location + global last_progress + + perc = round(count*100.0/total) + # print(last_progress,";",perc) + if perc != last_progress and (location != last_location or perc > 98 or perc > last_progress + 5): + storage.store("percent_complete",perc) + logger.info("Progress: %s %d%%" % (location,perc)) + last_location = location + last_progress = perc def mprint(msg,data): """ |