20
20
import json
21
21
import os
22
22
import platform
23
+ import re
23
24
import sys
24
25
import time
25
26
import urllib
@@ -154,15 +155,19 @@ def update_epoch_value(d, name, epoch, value):
154
155
return (epoch , value , changed )
155
156
156
157
157
- def read_stats_dict_from_csv (f ):
158
+ def read_stats_dict_from_csv (f , select_stat = '' ):
158
159
infieldnames = ["epoch" , "name" , "value" ]
159
160
c = csv .DictReader (f , infieldnames ,
160
161
dialect = 'excel-tab' ,
161
162
quoting = csv .QUOTE_NONNUMERIC )
162
163
d = {}
164
+ sre = re .compile ('.*' if len (select_stat ) == 0 else
165
+ '|' .join (select_stat ))
163
166
for row in c :
164
167
epoch = int (row ["epoch" ])
165
168
name = row ["name" ]
169
+ if sre .search (name ) is None :
170
+ continue
166
171
value = int (row ["value" ])
167
172
update_epoch_value (d , name , epoch , value )
168
173
return d
@@ -189,7 +194,8 @@ def set_csv_baseline(args):
189
194
existing = None
190
195
if os .path .exists (args .set_csv_baseline ):
191
196
with open (args .set_csv_baseline , "r" ) as f :
192
- existing = read_stats_dict_from_csv (f )
197
+ existing = read_stats_dict_from_csv (f ,
198
+ select_stat = args .select_stat )
193
199
print ("updating %d baseline entries in %s" %
194
200
(len (existing ), args .set_csv_baseline ))
195
201
else :
@@ -273,7 +279,8 @@ def write_comparison(args, old_stats, new_stats):
273
279
274
280
275
281
def compare_to_csv_baseline (args ):
276
- old_stats = read_stats_dict_from_csv (args .compare_to_csv_baseline )
282
+ old_stats = read_stats_dict_from_csv (args .compare_to_csv_baseline ,
283
+ select_stat = args .select_stat )
277
284
m = merge_all_jobstats ((s for d in args .remainder
278
285
for s in load_stats_dir (d , ** vars (args ))),
279
286
** vars (args ))
0 commit comments