Debian Codegraph @

commissioning/acceptance/mark_array_ok.py

raw symbols SCIP
1 """I have also noticed a trend in a number of the failed cases that
2 involve array comparisons: the mean discrepancy is very small,
3 and there are a small number of significant outliers. At present,
4 such a test fails the rigorous criteria we are using. However,
5 I am thinking of writing a utility to identify these cases and
6 mark them as acceptable failures. Any comments/objections?
7
8
9 Basic idea:
10 - look for failed tests, possibly only of the array types
11 - for each test,
12 extract tra_discrepmean, tra_outliers, tda_sigthresh
13 if abs(mean)<sigthresh and outliers<something,
14 set attn=N
15 print something to stdout
16
17 """
18 from __future__ import print_function
19 import sqlite3
20 import time, sys
21
22 def run(test_run,maxoutliers=50,maxdev=0.015):
23
24 #Connect to the DB
25 db = sqlite3.connect("/aten/data1/ssb/test/stf/cgi/db/stf.db")
26 idlist=[]
27
28 #Pick out the failed tests from the test run
29 ctr = db.execute("""SELECT result_scalar.key_id, result_scalar.test_name
30 FROM result_scalar
31 WHERE result_scalar.test_run = ?
32 AND result_scalar.status = 'F'
33 AND project = 'syn_pysyn'
34 AND host = 'gaudete' """,(test_run,))
35
36 #Loop over the tests to pick out the ones we want to analyze
37 for x in ctr:
38 key,name=x
39 if "testcr" in name: #then it's an array test; carry on.
40 ctra = db.execute("""SELECT result_tra.value
41 FROM result_tra
42 WHERE result_tra.key_id = ?
43 AND result_tra.name = 'discrepmean'""",
44 (key,))
45
46 for xx in ctra:
47 discrepmean=float(xx[0])
48
49 ctra2 = db.execute("""SELECT result_tra.value
50 FROM result_tra
51 WHERE result_tra.key_id = ?
52 AND result_tra.name = 'outliers'""",
53 (key,))
54
55 #Now apply the test
56 for xxx in ctra2:
57 n_outliers=float(xxx[0])
58 if ( (abs(discrepmean) <= maxdev) and
59 (n_outliers < maxoutliers) ):
60 idlist.append(key)
61 print(name, discrepmean, n_outliers)
62 #If it passes the test, update the attention flag
63 db.execute("""UPDATE result_scalar SET attn = 'N'
64 WHERE key_id = ?""",(key,))
65 #and insert the reason
66 db.execute("""INSERT INTO result_tra
67 ( key_id, name, value ) values (?, ?, ? )""" ,
68 ( key, "attn_code", "autoaccept") )
69
70
71 db.commit()
72 db.close()
73 print(len(idlist), " acceptable failures found and marked")
74
75 #Make a qid so we can find these later if we want to
76 if len(idlist) > 0:
77 qdb = sqlite3.connect("/aten/data1/ssb/test/stf/cgi/db/stf_query.db")
78
79 # create a new qid
80 now = time.time()
81 c = qdb.execute("INSERT INTO query_id ( time ) VALUES ( ? ) ",(now,))
82 qid = c.lastrowid
83 qdb.commit()
84
85 #Now make our list
86 for k in idlist:
87 qdb.execute("INSERT INTO query ( qid, key_id ) VALUES ( ?, ? ) ", (qid, k) )
88 #print "Insert loop: ", k, time.asctime()
89
90 qdb.commit()
91 qdb.close()
92
93 #Write a URL
94 url="http://stsdas.stsci.edu/cgi-bin/stf.cgi?query=summary&qid=%s\n"%qid
95 sys.stdout.write(url)
96
97 if __name__ == '__main__':
98 run(*sys.argv[1:])