1
2
3
4 """
5 Retrieves the JARs from the latest Hudson based build of the LOCI software
6 repository; predominently Bio-Formats.
7 """
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import urllib
27 import sys
28 import re
29 import os
30
31 from subprocess import Popen
32 from getopt import getopt, GetoptError
33 from glob import glob
34
35
36 try:
37 from xml.etree.ElementTree import XML, ElementTree, tostring
38 except ImportError:
39 from elementtree.ElementTree import XML, ElementTree, tostring
40
42 """Prints usage so that we don't have to. :)"""
43 cmd = sys.argv[0]
44 if error is not None:
45 print error
46 print """Usage: %s
47 Retrieves the latest metadata validator test report from Hudson and extracts
48 some statistics for each file.
49
50 Options:
51 --report Prints tab seperated statistics for each file's
52 setId() timings
53 --summary Prints a summary of all files [default]
54 --help Prints this help text
55 --config=[4.1|TRUNK] Sets the metadata validator instance to use
56 [defaults to TRUNK]
57
58 Examples:
59 %s --summary --config=4.1
60 %s --report --config=TRUNK > report.csv
61
62 Report bugs to ome-devel@lists.openmicroscopy.org.uk""" % (cmd, cmd, cmd)
63 sys.exit(2)
64
65
66 URLs = {
67 '4.1': "http://hudson.openmicroscopy.org.uk/job/omero-metadata-validator-Beta4.1/lastSuccessfulBuild/",
68 'TRUNK': "http://hudson.openmicroscopy.org.uk/job/omero-metadata-validator/lastSuccessfulBuild/",
69 }
70
71
72 TEST_SUFFIX = "testReport/"
73
74
75 API_SUFFIX = "api/xml"
76
78 url = urllib.urlopen("%s%s" % (URLs[config], API_SUFFIX))
79 hudson_xml = url.read()
80 url.close()
81 root = XML(hudson_xml)
82 build_no = root.findtext("./number")
83 bioformats_rev = 'Unknown'
84 for artifact in root.findall("./artifact"):
85 file_name = artifact.findtext("./fileName")
86 match = re.match(r'bio-formats-r(\d+).jar', file_name)
87 if match:
88 bioformats_rev = match.group(1)
89 break
90 omero_rev = root.findtext("./changeSet/revision/revision")
91 url = urllib.urlopen("%s%s%s" % (URLs[config], TEST_SUFFIX, API_SUFFIX))
92 hudson_xml = url.read()
93 url.close()
94 return { 'root': XML(hudson_xml), 'build_no': build_no,
95 'bioformats_rev': bioformats_rev, 'omero_rev': omero_rev }
96
97 -def report(root, build_no, bioformats_rev, omero_rev):
98 suites = root.findall("./suite")
99 print "filename\ttestMetadataLevelMinimumSetId\ttestMetadataLevelAllSetId"
100 for suite in suites:
101 suite_name = suite.findtext("name")
102 cases = suite.findall("case")
103 minimum_set_id = None
104 all_set_id = None
105
106 for case in cases:
107 case_name = case.findtext("name")
108 if "testMetadataLevelMinimumSetId" == case_name:
109 minimum_set_id = case.findtext("duration")
110 if "testMetadataLevelAllSetId" == case_name:
111 all_set_id = case.findtext("duration")
112 if minimum_set_id is not None and all_set_id is not None:
113 print "\t".join([suite_name, minimum_set_id, all_set_id])
114
115 -def summary(root, build_no, bioformats_rev, omero_rev):
116 suites = root.findall("./suite")
117
118 minimum_set_id_min = { 'filename': None, 'min': float('inf') }
119 minimum_set_id_max = { 'filename': None, 'max': None }
120 minimum_set_id_total = 0.0
121 all_set_id_min = { 'filename': None, 'min': float('inf') }
122 all_set_id_max = { 'filename': None, 'max': None }
123 all_set_id_total = 0.0
124
125 suite_count = 0
126 for suite in suites:
127 suite_name = suite.findtext("name")
128 cases = suite.findall("case")
129 for case in cases:
130 case_name = case.findtext("name")
131 if "testMetadataLevelMinimumSetId" == case_name:
132 minimum_set_id = float(case.findtext("duration"))
133 if minimum_set_id < minimum_set_id_min['min']:
134 minimum_set_id_min['min'] = minimum_set_id
135 minimum_set_id_min['filename'] = suite_name
136 if minimum_set_id > minimum_set_id_max['max']:
137 minimum_set_id_max['max'] = minimum_set_id
138 minimum_set_id_max['filename'] = suite_name
139 minimum_set_id_total += minimum_set_id
140 if "testMetadataLevelAllSetId" == case_name:
141 all_set_id = float(case.findtext("duration"))
142 if all_set_id < all_set_id_min['min']:
143 all_set_id_min['min'] = all_set_id
144 all_set_id_min['filename'] = suite_name
145 if all_set_id > all_set_id_max['max']:
146 all_set_id_max['max'] = all_set_id
147 all_set_id_max['filename'] = suite_name
148 all_set_id_total += all_set_id
149
150 suite_count += 1
151
152 print "Metadata validator build: %s" % build_no
153 print "Bio-Formats revision: %s" % bioformats_rev
154 print "OMERO.server revision: %s" % omero_rev
155 print "Suite count: %d" % suite_count
156 x = minimum_set_id_min
157 if x['filename'] is not None:
158 print " ---- "
159 print "Minimum MINIMUM setId() time %fsec: %s" % (x['min'], x['filename'])
160 x = minimum_set_id_max
161 if x['filename'] is not None:
162 print "Maximum MINIMUM setId() time %fsec: %s" % (x['max'], x['filename'])
163 print "Total MINIMUM setId() time %fsec" % (minimum_set_id_total)
164 print "Average MINIMUM setId() time %fsec" % \
165 (minimum_set_id_total / suite_count)
166 print " ---- "
167 x = all_set_id_min
168 print "Minimum ALL setId() time %fsec: %s" % (x['min'], x['filename'])
169 x = all_set_id_max
170 print "Maximum ALL setId() time %fsec: %s" % (x['max'], x['filename'])
171 print "Total ALL setId() time %fsec" % (all_set_id_total)
172 print "Average ALL setId() time %fsec" % (all_set_id_total / suite_count)
173
174 if __name__ == "__main__":
175 try:
176 options, args = getopt(sys.argv[1:], "",
177 ['summary', 'report', 'help', 'config='])
178 except GetoptError, (msg, opt):
179 usage(msg)
180
181 config = 'TRUNK'
182 to_do = summary
183 for option, argument in options:
184 if '--help' == option:
185 usage()
186 if '--report' == option:
187 to_do = report
188 if '--config' == option:
189 config = argument
190 metadata = download(config)
191 to_do(metadata['root'], metadata['build_no'],
192 metadata['bioformats_rev'], metadata['omero_rev'])
193