From 6c1b0fb33cc6dcd5430233cf4399fe93fd863a9b Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Mon, 22 Apr 2019 15:34:39 -0400 Subject: [PATCH] Fix iteration order dependency. Causes tests to fail in Python 3.5, but not Python 3.7 due to dependency on iteration order of dicts. Refs #14939 Arvados-DCO-1.1-Signed-off-by: Tom Morris --- .../crunchstat_summary/summarizer.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/crunchstat-summary/crunchstat_summary/summarizer.py b/tools/crunchstat-summary/crunchstat_summary/summarizer.py index bf905a3946..6d567e68dc 100644 --- a/tools/crunchstat-summary/crunchstat_summary/summarizer.py +++ b/tools/crunchstat-summary/crunchstat_summary/summarizer.py @@ -207,17 +207,18 @@ class Summarizer(object): stats['user+sys'] = stats.get('user', 0) + stats.get('sys', 0) if 'tx' in stats or 'rx' in stats: stats['tx+rx'] = stats.get('tx', 0) + stats.get('rx', 0) - for stat, val in stats.items(): - if group == 'interval': - if stat == 'seconds': - this_interval_s = val - continue - elif not (this_interval_s > 0): + if group == 'interval': + if 'seconds' in stats: + this_interval_s = stats.get('seconds',0) + del stats['seconds'] + if this_interval_s <= 0: logger.error( "BUG? interval stat given with duration {!r}". format(this_interval_s)) - continue - else: + else: + logger.error('BUG? interval stat missing duration') + for stat, val in stats.items(): + if group == 'interval' and this_interval_s: stat = stat + '__rate' val = val / this_interval_s if stat in ['user+sys__rate', 'tx+rx__rate']: -- 2.30.2