Skip to content

Commit 62a417e

Browse files
authored
Merge pull request #207 from radical-cybertools/fix/balance
warn on unbalanced resource accounting
2 parents 795f7da + 02786c4 commit 62a417e

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

src/radical/analytics/utils/plot.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sys
44
import glob
55

6+
from collections import defaultdict
7+
68
import pandas as pd
79
import numpy as np
810
import matplotlib as mpl
@@ -228,6 +230,7 @@ def get_pilot_series(session, pilot, tmap, resrc, percent=True):
228230

229231
td = entity.description
230232
etype = entity.etype
233+
check = defaultdict(list)
231234

232235
transitions = tmap.get(etype)
233236
if not transitions:
@@ -287,18 +290,38 @@ def get_pilot_series(session, pilot, tmap, resrc, percent=True):
287290

288291
ts = entity.timestamps(event=event)
289292
if not ts:
290-
# print('%s: no event %s for %s' % (uid, event, etype))
293+
# print('%s: no event %s for %s' % (entity.uid, event, etype))
291294
continue
292295

293296
for r in resrc:
294297
amount = t_resrc[r]
295298
if amount == 0:
296299
continue
297300
t = (ts[0] - t_min)
301+
check['%s:%s' % (r, p_from)].append([event, -amount])
302+
check['%s:%s' % (r, p_to )].append([event, +amount])
298303
contribs[r][p_from].append([t, -amount])
299304
contribs[r][p_to ].append([t, +amount])
300-
# print('%6.3f : %-30s : %-25s : %-15s --> %-15s [%s]' %
301-
# (t, uid, event, p_from, p_to, amount))
305+
# print('%6.3f : %-30s : %-25s : %-15s =-> %-15s [%s]' %
306+
# (t, entity.uid, event, p_from, p_to, amount))
307+
308+
309+
for metric in check:
310+
311+
# all contributions to a metric should sum to zero
312+
# if not, pprint them
313+
tot = sum([x[1] for x in check[metric]])
314+
if tot != 0:
315+
print('=== %s: %s' % (entity.uid, etype))
316+
print('WARNING: unbalanced contributions to %s: %s' %
317+
(metric, tot))
318+
319+
for m in check:
320+
print(' %-20s : %8d' % (m, sum([x[1] for x in check[m]])))
321+
# for e in entity.events:
322+
# print(' %6.3f : %-20s : %s' % (e[ru.TIME] - t_min,
323+
# e[ru.EVENT], e[ru.STATE]))
324+
break
302325

303326
# we now have, for all metrics, a list of resource changes, in the form of
304327
#

0 commit comments

Comments
 (0)