62 from argparse
import ArgumentParser, FileType
64 p = ArgumentParser(description=
"Compute differences in the defects "
65 "database between tags")
67 arg(
"tags", metavar=
"DetStatus-Tag", nargs=2, type=str,
68 help=
"Two tags to show the difference between")
69 arg(
"-p",
"--project", default=
None,
70 help=
"Limit considered runs to those in project")
71 arg(
"-P",
"--period", default=
None, help=
"Data period")
72 arg(
"-r",
"--run", type=int, help=
"Run number to process")
73 arg(
"-R",
"--range", help=
"Run range: e.g. 150000-151000")
74 arg(
"-d",
"--defect", action=
"append", dest=
"defects", default=
None,
75 help=
"Defects to show the difference between. "
76 "(If empty, show all. -d can be specified multiple times.)")
77 arg(
"-i",
"--ignore-not-considered", action=
"store_true",
78 help=
"Ignore ranges in which GLOBAL_NOTCONSIDERED is set for either tag")
79 arg(
"--output", default=sys.stdout, type=FileType(
"w"),
80 help=
"Place to out the output (Default stdout)")
81 arg(
"-s",
"--by-system", action=
"store_true",
82 help=
"If specified, show systems which differ, not defects")
83 arg(
"-v",
"--virtual", action=
"store_true",
84 help=
"If specified, show virtual defect differences as well as primary"
85 " (produces a lot of output)")
90 tag1, tag2 = args.tags
93 since, until =
None,
None
99 since, until = (args.run, 0), (args.run+1, 0)
100 range_iovs = IOVSet.from_runs([args.run])
102 run1, run2 = map(int, args.range.split(
"-"))
103 since, until = (run1, 0), (run2, 0)
113 period_dict = project_dict[args.project]
118 runs =
set(period_dict[args.period])
121 for period, period_runs
in period_dict.iteritems():
122 runs.update(period_runs)
124 since, until = (
min(runs), 0), (
max(runs)+1, 0)
125 range_iovs = IOVSet.from_runs(runs)
128 print(
'range to process:')
129 print(
'since, until =', since, until)
134 kwargs = dict(primary_only=
not args.virtual, channels=args.defects, since=since, until=until)
136 def fetch_defects(tag):
140 print(
"Retrieving defects..")
141 defects1, defects2 = fetch_defects(tag1), fetch_defects(tag2)
144 print(
"Computing diff..")
145 diff_iovs =
make_defectdiff_iovs(defects1, defects2, args.by_system, args.ignore_not_considered)
146 for since, until, t1, t2
in diff_iovs: