|
ATLAS Offline Software
|
|
def | maketime (n) |
|
def | print_system_iovs (result) |
|
def | run_one (system, lbtime, run_iovs) |
|
def | run_parallel (systems, lbtime, run_iovs, N) |
|
def | run_sequential (systems, lbtime, run_iovs) |
|
def | go (iov, systems, db, indb, timewise=False, use_flask=False) |
|
def | main (argv) |
|
◆ go()
def python.main.go |
( |
|
iov, |
|
|
|
systems, |
|
|
|
db, |
|
|
|
indb, |
|
|
|
timewise = False , |
|
|
|
use_flask = False |
|
) |
| |
Run the DCS calculator for `run` on the `systems` specified, saving the
result to the `database`.
Definition at line 93 of file DataQuality/DCSCalculator2/python/main.py.
93 def go(iov, systems, db, indb, timewise=False, use_flask=False):
95 Run the DCS calculator for `run` on the `systems` specified, saving the
96 result to the `database`.
100 with timer(
"Read LBLB"):
102 lblb =
fetch_iovs(
"LBLB", since, until, with_channel=
False, database=(indb
if indb.startswith(
'sqlite')
else 'COOLONL_TRIGGER/%s' % indb))
103 assert lblb,
"No luminosity blocks for desired range. [%s, %s)" % (since, until)
114 log.debug(
"Will process %i LBs over %i runs", len(lblb), len(run_iovs))
116 log.info(
"DCSC2 will run over range: %r %s", tuple(run_iovs.range_iov),
"(%i lbs)" % len(lblb))
120 systems = [system()
for system
in systems
121 if not getattr(system,
"__DISABLED__",
False)]
130 if log.isEnabledFor(logging.DEBUG):
133 log.info(
"Calculation complete")
137 with timer(
"write result (%i iovs)" % len(result_iovs)):
138 log.debug(
"Writing result (%i iovs)", len(result_iovs))
139 defect_iovs =
list(
filter(
lambda iov: isinstance(iov, DefectIOV), result_iovs))
140 defect_iovs_full = [
DefectIOVFull(recoverable=
False, user=
'sys:defectcalculator', **_._asdict())
141 for _
in defect_iovs]
142 defect_iovs_full.append(
DefectIOVFull(recoverable=
False, user=
'sys:defectcalculator',
143 channel=
'GLOBAL_DCS_UNCHECKED', present=
False,
144 comment=
'Calculator did run',
145 since=since, until=until))
146 if len(defect_iovs) > 0:
147 log.warning(f
'db {db}, read_only {not use_flask}')
148 ddb = DefectsDB(db, read_only=use_flask, create=
not use_flask)
149 defect_names =
set(i.channel
for i
in defect_iovs_full)
150 for defect
in defect_names:
151 if defect
in ddb.defect_id_map:
153 ddb.create_defect(defect,
"Created by DCSCalculator2")
154 with ddb.storage_buffer
if not use_flask
else nullcontext():
158 secret_path = os.environ.get(
'COOLFLASK_SECRET',
'/afs/cern.ch/user/a/atlasdqm/private/coolflask_secret/coolflask_secret.json')
159 auth = json.loads(
open(secret_path).
read())
162 ddb.insert_multiple(defect_iovs_full, use_flask=use_flask, flask_auth=auth)
164 log.warning(
"DCS Calculator failed to upload defects to DB")
165 if config.opts.email_on_failure:
166 from DataQualityUtils.panic
import panic
167 from traceback
import format_exc
168 runnum = lbtime[0].Run
if len(lbtime)>0
else '??????'
169 panicmsg =
"DCS Calculator failed to upload defects to database for run %s\n\n%s" % (runnum, format_exc())
174 args = len(result_iovs),
hash(result_iovs)
175 log.info(
"Success. Calculated %i iovs. Result hash: 0x%0x8.", *args)
◆ main()
def python.main.main |
( |
|
argv | ) |
|
Definition at line 177 of file DataQuality/DCSCalculator2/python/main.py.
179 optp, opts, args = config.parse_options(argv)
183 log.debug(
"Commandline arguments: %s", argv)
184 log.debug(
"Current configuration: %s", (opts))
186 if opts.shell_on_exception:
188 from IPython.core
import ultratb
189 sys.excepthook = ultratb.FormattedTB(call_pdb=
True)
193 if opts.systems
is None:
194 systems = ALL_SYSTEMS
199 for system
in opts.systems:
200 if system
not in SYSTEM_MAP:
201 invalid_systems.append(system)
203 systems.append(SYSTEM_MAP[system])
206 optp.error(
"Invalid system(s) specified: {0}. "
207 "Available systems: {1}".
format(invalid_systems, SYSTEM_MAP.keys()))
210 if (opts.run
and opts.range)
or (
not opts.run
and not opts.range):
211 optp.error(
"Specify either -r or -R")
213 since, until = opts.run, opts.run
215 since, until = map(int, opts.range.split(
"-"))
219 optp.error(
"--lbs and --range are incompatible. "
220 "Use --lbs with --run")
221 sincelb, untillb = map(int, opts.lbs.split(
"-"))
226 go(iov, systems, opts.output_database, opts.input_database, opts.timewise, opts.flask)
◆ maketime()
def python.main.maketime |
( |
|
n | ) |
|
◆ print_system_iovs()
def python.main.print_system_iovs |
( |
|
result | ) |
|
◆ run_one()
def python.main.run_one |
( |
|
system, |
|
|
|
lbtime, |
|
|
|
run_iovs |
|
) |
| |
Definition at line 46 of file DataQuality/DCSCalculator2/python/main.py.
46 def run_one(system, lbtime, run_iovs):
48 with timer(
"Run DCS calculator 2 for %s" % system):
49 return system.run(lbtime, run_iovs)
51 log.warning(
"DCS Calculator failed to run for %s.", system)
52 if config.opts.dont_ignore_system_exceptions:
54 log.exception(
"Continuing. Use -e -X commandline to investigate")
55 if config.opts.email_on_failure:
56 from DataQualityUtils.panic
import panic
57 from traceback
import format_exc
58 runnum = lbtime[0].Run
if len(lbtime)>0
else '??????'
59 panicmsg =
"DCS Calculator failed to execute in run %s for system %s.\n\n%s" % (runnum, system, format_exc())
62 except (KeyboardInterrupt, SystemExit):
◆ run_parallel()
def python.main.run_parallel |
( |
|
systems, |
|
|
|
lbtime, |
|
|
|
run_iovs, |
|
|
|
N |
|
) |
| |
Definition at line 65 of file DataQuality/DCSCalculator2/python/main.py.
66 pool = Pool(N
if N > 0
else len(systems))
68 for system
in systems:
69 result = pool.apply_async(run_one, (system, lbtime, run_iovs))
70 results.append(result)
72 all_results = IOVSet()
73 for system, result
in zip(systems, map(
lambda x: x.get(), results)):
74 log.info(
" -- result for %s", system)
77 all_results.extend(result)
◆ run_sequential()
def python.main.run_sequential |
( |
|
systems, |
|
|
|
lbtime, |
|
|
|
run_iovs |
|
) |
| |
Definition at line 81 of file DataQuality/DCSCalculator2/python/main.py.
82 result_iovs = IOVSet()
84 for system
in systems:
85 log.info(
" -- running for %s", system)
86 system_result =
run_one(system, lbtime, run_iovs)
89 result_iovs.extend(system_result)
◆ log
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
def run_sequential(systems, lbtime, run_iovs)
def fetch_iovs(folder_name, since=None, until=None, channels=None, tag="", what="all", max_records=-1, with_channel=True, loud=False, database=None, convert_time=False, named_channels=False, selection=None, runs=None, with_time=False, unicode_strings=False)
def timer(name, disabled=False)
def print_system_iovs(result)
def run_iovs_from_lblb(lblb)
def pprint_objects(objects, where=stdout)
def run_one(system, lbtime, run_iovs)
def DefectIOVFull(channel, present, comment, recoverable=False, user='sys:defectcalculator')
def run_parallel(systems, lbtime, run_iovs, N)
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
def init_logger(verbose=False, quiet=False)
def go(iov, systems, db, indb, timewise=False, use_flask=False)