51 parser = ArgumentParser(description=
'List defect IOVs')
52 add_arg = parser.add_argument
55 add_arg(
'-p',
'--project', default=
'data15_13TeV',
56 help=
'Data project (default: data15_13TeV)')
57 add_arg(
'-P',
'--period', default=
None, nargs=
'*', help=
'Data period(s)')
59 add_arg(
'-r',
'--run', default=
None, type=int, help=
'Run number to process')
60 add_arg(
'-R',
'--range', help=
'Inclusive run range: e.g. 150000-151000')
63 add_arg(
'-d',
'--defects', default=
None, nargs=
'*',
64 help=
'Defects to process. Use * for wildcard (default: None)')
67 add_arg(
'-c',
'--connection-string', default=DEFAULT_CONNECTION_STRING,
68 help=
'Database connection to use (default: %s)' % DEFAULT_CONNECTION_STRING)
71 add_arg(
'-t',
'--tag', default=
'HEAD',
72 help=
'Tag to use (default: HEAD)')
75 args = parser.parse_args()
78 since, until =
None,
None
83 since, until = (args.run, 0), (args.run+1, 0)
84 range_iovs = IOVSet.from_runs([args.run])
86 run1, run2 = map(int, args.range.split(
'-'))
87 since, until = (run1, 0), (run2, 0)
93 period_dict = project_dict[args.project]
96 if args.period
and len(args.period) > 0:
97 for period
in args.period:
98 run_set.update(period_dict[period])
101 for period, runs
in period_dict.iteritems():
103 since, until = (
min(run_set), 0), (
max(run_set)+1, 0)
104 range_iovs = IOVSet.from_runs(run_set)
107 print(
'range to process:')
108 print(
'since, until =', since, until)
111 db = DefectsDB(args.connection_string, tag=args.tag)
114 defect_iovs = db.retrieve(since, until, channels=args.defects)
115 defect_iovset_list = defect_iovs.by_channel.values()
119 result_dict = defaultdict(IOVSet)
120 for since, until, states
in process_iovs(range_iovs, *defect_iovset_list):
121 in_range, defects = states[0], states[1:]
125 result_dict[d.channel].
add(since, until, d.channel, d.comment)
128 for channel, result
in result_dict.iteritems():
129 result.solidify(DefectIOV)
130 print(
'\n' + channel +
'\n')