328 Read trigger configuration keys (SMK, L1PSK, HLTPSK) and DB info from OKS via WEBDAQ REST API.
330 This reads the keys from the partition's TriggerConfiguration object and its
331 related L1TriggerConfiguration and TriggerDBConnection objects.
334 - Partition -> TriggerConfiguration -> L1TriggerConfiguration (Lvl1PrescaleKey)
335 - Partition -> TriggerConfiguration -> TriggerDBConnection (SuperMasterKey)
336 - Partition -> TriggerConfiguration -> HLTImplementationDB (hltPrescaleKey)
339 partition: The partition name (default: from TDAQ_PARTITION env var)
340 webdaq_base: Base URL for webis_server (default: from TDAQ_WEBDAQ_BASE env var)
341 strict: If True, raise an exception if OKS read fails (for --online-environment)
344 dict with keys: SMK, L1PSK, HLTPSK, db_alias (values may be None if not found)
347 RuntimeError: If strict=True and OKS read fails
352 if webdaq_base
is None:
353 webdaq_base = os.environ.get(
'TDAQ_WEBDAQ_BASE')
356 msg =
"TDAQ_WEBDAQ_BASE not set, cannot read from OKS"
358 raise RuntimeError(msg +
" (required for --online-environment)")
360 return {
'SMK':
None,
'L1PSK':
None,
'HLTPSK':
None,
'db_alias':
None}
363 if partition
is None:
364 partition = os.environ.get(
'TDAQ_PARTITION',
'ATLAS')
366 log.info(
"Reading trigger configuration keys from OKS via WEBDAQ: %s (partition=%s)",
367 webdaq_base, partition)
369 result = {
'SMK':
None,
'L1PSK':
None,
'HLTPSK':
None,
'db_alias':
None}
371 def extract_oks_data(response_json):
373 Extract data from OKS compact format: [name, type, attributes, relationships]
374 Returns tuple (attributes_dict, relationships_dict)
376 if isinstance(response_json, list)
and len(response_json) >= 4:
377 return response_json[2], response_json[3]
378 elif isinstance(response_json, list)
and len(response_json) >= 3:
379 return response_json[2], {}
380 return response_json, {}
383 """Extract object ID from a relationship reference."""
384 if isinstance(ref, list)
and len(ref) >= 2:
386 elif isinstance(ref, dict)
and 'id' in ref:
388 elif isinstance(ref, str):
397 url = f
"{webdaq_base}/info/current/{partition}/oks/Partition/{partition}?format=compact"
398 log.debug(
"Fetching Partition from OKS: %s", url)
400 response = requests.get(url, timeout=10)
401 if response.status_code == 200:
402 part_attrs, part_rels = extract_oks_data(response.json())
403 log.debug(
"Partition attributes: %s", part_attrs)
404 log.debug(
"Partition relationships: %s", part_rels)
408 if 'TriggerConfiguration' in part_rels:
409 trig_conf_id = get_ref_id(part_rels[
'TriggerConfiguration'])
412 log.debug(
"TriggerConfiguration ID: %s", trig_conf_id)
415 url = f
"{webdaq_base}/info/current/{partition}/oks/TriggerConfiguration/{trig_conf_id}?format=compact"
416 response = requests.get(url, timeout=10)
417 if response.status_code == 200:
418 trig_attrs, trig_rels = extract_oks_data(response.json())
419 log.debug(
"TriggerConfiguration attributes: %s", trig_attrs)
420 log.debug(
"TriggerConfiguration relationships: %s", trig_rels)
423 if 'l1' in trig_rels:
424 l1_id = get_ref_id(trig_rels[
'l1'])
426 url = f
"{webdaq_base}/info/current/{partition}/oks/L1TriggerConfiguration/{l1_id}?format=compact"
427 resp = requests.get(url, timeout=10)
428 if resp.status_code == 200:
429 l1_attrs, _ = extract_oks_data(resp.json())
430 log.debug(
"L1TriggerConfiguration attributes: %s", l1_attrs)
431 if 'Lvl1PrescaleKey' in l1_attrs:
432 result[
'L1PSK'] = int(l1_attrs[
'Lvl1PrescaleKey'])
433 log.info(
"Got L1PSK=%d from OKS", result[
'L1PSK'])
436 if 'TriggerDBConnection' in trig_rels:
437 db_id = get_ref_id(trig_rels[
'TriggerDBConnection'])
439 url = f
"{webdaq_base}/info/current/{partition}/oks/TriggerDBConnection/{db_id}?format=compact"
440 resp = requests.get(url, timeout=10)
441 if resp.status_code == 200:
442 db_attrs, _ = extract_oks_data(resp.json())
443 log.debug(
"TriggerDBConnection attributes: %s", db_attrs)
444 if 'SuperMasterKey' in db_attrs:
445 result[
'SMK'] = int(db_attrs[
'SuperMasterKey'])
446 log.info(
"Got SMK=%d from OKS", result[
'SMK'])
447 if 'Alias' in db_attrs:
448 result[
'db_alias'] = db_attrs[
'Alias']
449 log.info(
"Got db_alias=%s from OKS", result[
'db_alias'])
452 if 'hlt' in trig_rels:
453 hlt_id = get_ref_id(trig_rels[
'hlt'])
455 url = f
"{webdaq_base}/info/current/{partition}/oks/HLTImplementationDB/{hlt_id}?format=compact"
456 resp = requests.get(url, timeout=10)
457 if resp.status_code == 200:
458 hlt_attrs, _ = extract_oks_data(resp.json())
459 log.debug(
"HLTImplementationDB attributes: %s", hlt_attrs)
460 if 'hltPrescaleKey' in hlt_attrs:
461 result[
'HLTPSK'] = int(hlt_attrs[
'hltPrescaleKey'])
462 log.info(
"Got HLTPSK=%d from OKS", result[
'HLTPSK'])
464 msg = f
"Failed to fetch Partition from OKS: HTTP {response.status_code}"
466 raise RuntimeError(msg +
" (required for --online-environment)")
469 except requests.exceptions.RequestException
as e:
470 msg = f
"Error fetching trigger keys from OKS: {e}"
472 raise RuntimeError(msg +
" (required for --online-environment)")
474 except (ValueError, KeyError, TypeError)
as e:
475 msg = f
"Error parsing trigger keys from OKS: {e}"
477 raise RuntimeError(msg +
" (required for --online-environment)")
482 missing = [k
for k
in [
'SMK',
'L1PSK',
'HLTPSK']
if result.get(k)
is None]
484 raise RuntimeError(f
"Failed to get {', '.join(missing)} from OKS (required for --online-environment)")
829 """Update run parameters from IS, file, or conditions DB"""
832 if getattr(args,
'online_environment',
False):
833 log.info(
"Reading run parameters from Information Service via WEBDAQ")
837 solenoid_override = getattr(args,
'solenoid_current',
None)
838 toroids_override = getattr(args,
'toroids_current',
None)
841 partition=getattr(args,
'partition',
None),
842 webdaq_base=getattr(args,
'webdaq_base',
None),
844 solenoid_current_override=solenoid_override,
845 toroids_current_override=toroids_override)
847 if args.run_number
is None and run_params.run_number
is not None:
848 args.run_number = run_params.run_number
849 log.info(
"Using run_number=%d from IS", args.run_number)
850 if args.lb_number
is None and run_params.lb_number
is not None:
851 args.lb_number = run_params.lb_number
852 log.info(
"Using lb_number=%d from IS", args.lb_number)
853 if args.sor_time
is None and run_params.sor_time
is not None:
854 args.sor_time = run_params.sor_time
855 log.info(
"Using sor_time=%s from IS", args.sor_time)
856 if args.detector_mask
is None and run_params.detector_mask
is not None:
857 args.detector_mask = run_params.detector_mask
858 log.info(
"Using detector_mask=%s from IS", args.detector_mask)
860 args.solenoid_current = run_params.solenoid_current
861 args.toroids_current = run_params.toroids_current
862 args.beam_type = run_params.beam_type
863 args.beam_energy = run_params.beam_energy
865 if (args.run_number
is not None and args.lb_number
is None)
or (args.run_number
is None and args.lb_number
is not None):
866 log.error(
"Both or neither of the options -R (--run-number) and -L (--lb-number) have to be specified")
870 from eformat
import EventStorage
871 dr = EventStorage.pickDataReader(args.file[0])
872 if args.run_number
is None:
873 args.run_number = dr.runNumber()
874 args.lb_number = dr.lumiblockNumber()
875 args.T0_project_tag = dr.projectTag()
876 args.beam_type = dr.beamType()
877 args.beam_energy = dr.beamEnergy()
878 args.trigger_type = dr.triggerType()
879 args.stream = dr.stream()
880 args.lumiblock = dr.lumiblockNumber()
881 args.file_detector_mask =
"{:032x}".format(dr.detectorMask())
883 args.T0_project_tag = getattr(args,
'T0_project_tag',
'')
884 args.beam_type = getattr(args,
'beam_type', 0)
885 args.beam_energy = getattr(args,
'beam_energy', 0)
886 args.trigger_type = getattr(args,
'trigger_type', 0)
887 args.stream = getattr(args,
'stream',
'')
888 args.lumiblock = getattr(args,
'lumiblock', 0)
889 args.file_detector_mask = getattr(args,
'file_detector_mask',
'00000000000000000000000000000000')
892 if (args.sor_time
is None or args.detector_mask
is None)
and args.run_number
is not None:
893 sor_params = AthHLT.get_sor_params(args.run_number)
894 log.debug(
'SOR parameters: %s', sor_params)
895 if sor_params
is None:
896 log.error(
"Run %d does not exist. If you want to use this run-number specify "
897 "remaining run parameters, e.g.: --sor-time=now --detector-mask=all", args.run_number)
900 if args.sor_time
is None and sor_params
is not None:
901 args.sor_time =
arg_sor_time(str(sor_params[
'SORTime']))
903 if args.detector_mask
is None and sor_params
is not None:
904 dmask = sor_params[
'DetectorMask']
905 if args.run_number < AthHLT.CondDB._run2:
909 if args.dump_config_exit
and not args.run_number:
914 if getattr(args,
'solenoid_current',
None)
is None:
915 args.solenoid_current = RunParams.DEFAULT_SOLENOID_CURRENT
916 log.debug(
"Using default solenoid_current=%.1f", args.solenoid_current)
917 if getattr(args,
'toroids_current',
None)
is None:
918 args.toroids_current = RunParams.DEFAULT_TOROIDS_CURRENT
919 log.debug(
"Using default toroids_current=%.1f", args.toroids_current)
1084 parser = argparse.ArgumentParser(prog=
'athenaEF.py', formatter_class=
1085 lambda prog : argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=32, width=100),
1086 usage =
'%(prog)s [OPTION]... -f FILE jobOptions',
1088 parser.expert_groups = []
1091 g = parser.add_argument_group(
'Options')
1092 g.add_argument(
'jobOptions', nargs=
'?', help=
'job options: CA module (package.module:function), pickle file (.pkl), or JSON file (.json)')
1093 g.add_argument(
'--threads', metavar=
'N', type=int, default=1, help=
'number of threads')
1094 g.add_argument(
'--concurrent-events', metavar=
'N', type=int, help=
'number of concurrent events if different from --threads')
1095 g.add_argument(
'--log-level',
'-l', metavar=
'LVL', default=
'INFO', help=
'OutputLevel of athena')
1096 g.add_argument(
'--precommand',
'-c', metavar=
'CMD', action=
'append', default=[],
1097 help=
'Python commands executed before job options')
1098 g.add_argument(
'--postcommand',
'-C', metavar=
'CMD', action=
'append', default=[],
1099 help=
'Python commands executed after job options')
1100 g.add_argument(
'--interactive',
'-i', action=
'store_true', help=
'interactive mode')
1101 g.add_argument(
'--help',
'-h', nargs=
'?', choices=[
'all'], action=MyHelp, help=
'show help')
1103 g = parser.add_argument_group(
'Input/Output')
1104 g.add_argument(
'--file',
'--filesInput',
'-f', action=
'append', help=
'input RAW file')
1105 g.add_argument(
'--save-output',
'-o', metavar=
'FILE', help=
'output file name')
1106 g.add_argument(
'--number-of-events',
'--evtMax',
'-n', metavar=
'N', type=int, default=
None,
1107 help=
'processes N events (default: from DB/config, -1 means all)')
1108 g.add_argument(
'--skip-events',
'--skipEvents',
'-k', metavar=
'N', type=int, default=
None,
1109 help=
'skip N first events')
1110 g.add_argument(
'--loop-files', action=argparse.BooleanOptionalAction, default=
None,
1111 help=
'loop over input files if no more events')
1112 g.add_argument(
'--efdf-interface-library', metavar=
'LIB', default=
None,
1113 help=
'name of the EFDF interface shared library to load (default: TrigDFEmulator)')
1116 g = parser.add_argument_group(
'Performance and debugging')
1117 g.add_argument(
'--perfmon', action=
'store_true', help=
'enable PerfMon')
1118 g.add_argument(
'--tcmalloc', action=
'store_true', default=
True, help=
'use tcmalloc')
1119 g.add_argument(
'--stdcmalloc', action=
'store_true', help=
'use stdcmalloc')
1120 g.add_argument(
'--stdcmath', action=
'store_true', help=
'use stdcmath library')
1121 g.add_argument(
'--imf', action=
'store_true', default=
True, help=
'use Intel math library')
1122 g.add_argument(
'--show-includes',
'-s', action=
'store_true', help=
'show printout of included files')
1125 g = parser.add_argument_group(
'Conditions')
1126 g.add_argument(
'--run-number',
'-R', metavar=
'RUN', type=int,
1127 help=
'run number (if None, read from first event)')
1128 g.add_argument(
'--lb-number',
'-L', metavar=
'LBN', type=int,
1129 help=
'lumiblock number (if None, read from first event)')
1130 g.add_argument(
'--conditions-run', metavar=
'RUN', type=int, default=
None,
1131 help=
'reference run number for conditions lookup (use when IS run number has no COOL data)')
1132 g.add_argument(
'--sor-time', type=arg_sor_time,
1133 help=
'The Start Of Run time. Three formats are accepted: '
1134 '1) the string "now", for current time; '
1135 '2) the number of nanoseconds since epoch (e.g. 1386355338658000000 or int(time.time() * 1e9)); '
1136 '3) human-readable "20/11/18 17:40:42.3043". If not specified the sor-time is read from the conditions DB')
1137 g.add_argument(
'--detector-mask', metavar=
'MASK', type=arg_detector_mask,
1138 help=
'detector mask (if None, read from the conditions DB), use string "all" to enable all detectors')
1141 g = parser.add_argument_group(
'Database')
1142 g.add_argument(
'--use-database',
'-b', action=
'store_true',
1143 help=
'configure from trigger database using SMK')
1144 g.add_argument(
'--db-server', metavar=
'DB', default=
'TRIGGERDB_RUN3', help=
'DB server name (alias)')
1145 g.add_argument(
'--smk', type=int, default=
None, help=
'Super Master Key')
1146 g.add_argument(
'--l1psk', type=int, default=
None, help=
'L1 prescale key')
1147 g.add_argument(
'--hltpsk', type=int, default=
None, help=
'HLT prescale key')
1148 g.add_argument(
'--use-crest', action=
'store_true', default=
False,
1149 help=
'Use CREST for trigger configuration')
1150 g.add_argument(
'--crest-server', metavar=
'URL', default=
None,
1151 help=
'CREST server URL (defaults to flags.Trigger.crestServer)')
1152 g.add_argument(
'--dump-config', action=
'store_true', help=
'Dump joboptions JSON file')
1153 g.add_argument(
'--dump-config-exit', action=
'store_true', help=
'Dump joboptions JSON file and exit')
1156 g = parser.add_argument_group(
'Magnets')
1157 g.add_argument(
'--solenoid-current', type=float, default=
None,
1158 help=
'Solenoid current in Amperes (default: nominal current for offline running, required from IS online)')
1159 g.add_argument(
'--toroids-current', type=float, default=
None,
1160 help=
'Toroids current in Amperes (default: nominal current for offline running, required from IS online)')
1163 g = parser.add_argument_group(
'Online')
1164 g.add_argument(
'--online-environment', action=
'store_true',
1165 help=
'Enable online environment: read run parameters from IS and trigger '
1166 'configuration keys (SMK, L1PSK, HLTPSK) from OKS via WEBDAQ REST API')
1167 g.add_argument(
'--partition', metavar=
'NAME', default=
None,
1168 help=
'TDAQ partition name (defaults to TDAQ_PARTITION environment variable)')
1169 g.add_argument(
'--webdaq-base', metavar=
'URL', default=
None,
1170 help=
'WEBDAQ base URL (defaults to TDAQ_WEBDAQ_BASE environment variable)')
1173 g = parser.add_argument_group(
'Online Histogramming')
1174 g.add_argument(
'--oh-monitoring',
'-M', action=
'store_true', default=
False,
1175 help=
'enable online histogram publishing via WebdaqHistSvc')
1178 g = parser.add_argument_group(
'Expert')
1179 parser.expert_groups.append(g)
1180 (args, unparsed_args) = parser.parse_known_args()
1184 from PyUtils.Helpers
import ROOTSetup
1185 ROOTSetup(batch=
True)
1189 ROOT.ROOT.EnableThreadSafety()
1192 import AthenaCommon.Logging
1193 AthenaCommon.Logging.log.setLevel(getattr(logging, args.log_level))
1194 AthenaCommon.Logging.log.setFormat(
"%(asctime)s Py:%(name)-31s %(levelname)7s %(message)s")
1195 if args.show_includes:
1196 from AthenaCommon.Include
import include
1197 include.setShowIncludes(
True )
1200 if not args.concurrent_events:
1201 args.concurrent_events = args.threads
1204 from TrigPSC
import PscConfig
1205 from TrigPSC.PscDefaultFlags
import defaultOnlineFlags
1208 flags = defaultOnlineFlags()
1211 from AthenaCommon
import Constants
1212 flags.Exec.OutputLevel = getattr(Constants, args.log_level)
1215 if args.oh_monitoring:
1216 flags.Trigger.Online.useOnlineWebdaqHistSvc =
True
1217 log.info(
"Enabled WebdaqHistSvc for online histogram publishing")
1220 log.info(
"Using CREST for trigger configuration: %s", args.use_crest)
1222 flags.Trigger.useCrest =
True
1223 if args.crest_server:
1224 flags.Trigger.crestServer = args.crest_server
1226 args.crest_server = flags.Trigger.crestServer
1230 if args.use_database:
1234 PscConfig.forcePSK = (args.hltpsk
is not None)
or args.online_environment
1239 if not args.use_database
and args.jobOptions
and not args.jobOptions.endswith(
'.json'):
1240 PscConfig.unparsedArguments = unparsed_args
1241 for flag_arg
in unparsed_args:
1242 flags.fillFromString(flag_arg)
1244 PscConfig.interactive = args.interactive
1245 PscConfig.exitAfterDump = args.dump_config_exit
1253 if args.conditions_run
is not None:
1254 log.info(
"Using conditions from reference run %d (overriding run %s for IOV lookup)",
1255 args.conditions_run, args.run_number)
1256 flags.Input.ConditionsRunNumber = args.conditions_run
1259 if args.number_of_events
is not None and args.number_of_events > 0:
1260 flags.Exec.MaxEvents = args.number_of_events
1263 if args.skip_events
is not None and args.skip_events > 0:
1264 flags.Exec.SkipEvents = args.skip_events
1270 flags.PerfMon.doFastMonMT = args.perfmon
1274 flags.Trigger.Online.useEFByteStreamSvc =
True
1277 ef_files = args.file
if args.file
else []
1280 ef_overrides[
'Files'] = ef_files
1282 ef_overrides.update({
1283 'T0ProjectTag' : args.T0_project_tag,
1284 'BeamType' : args.beam_type,
1285 'BeamEnergy' : args.beam_energy,
1286 'TriggerType' : args.trigger_type,
1287 'Stream' : args.stream,
1288 'Lumiblock' : args.lumiblock,
1289 'DetMask' : args.file_detector_mask,
1291 if args.run_number
is not None:
1292 ef_overrides[
'RunNumber'] = args.run_number
1293 if args.save_output
is not None:
1294 ef_overrides[
'OutputFileName'] = args.save_output
1295 if args.loop_files
is not None:
1296 ef_overrides[
'LoopOverFiles'] = args.loop_files
1297 if args.number_of_events
is not None:
1298 ef_overrides[
'NumEvents'] = args.number_of_events
1299 if args.skip_events
is not None:
1300 ef_overrides[
'SkipEvents'] = args.skip_events
1301 if args.efdf_interface_library
is not None:
1302 ef_overrides[
'EFDFInterfaceLibraryName'] = args.efdf_interface_library
1305 _prop2flag = {
'Files':
'Files',
'OutputFileName':
'OutputFileName',
1306 'LoopOverFiles':
'LoopFiles',
'NumEvents':
'NumEvents',
1307 'SkipEvents':
'SkipEvents',
'RunNumber':
'RunNumber',
1308 'T0ProjectTag':
'T0ProjectTag',
'BeamType':
'BeamType',
1309 'BeamEnergy':
'BeamEnergy',
'TriggerType':
'TriggerType',
1310 'Stream':
'Stream',
'Lumiblock':
'Lumiblock',
'DetMask':
'DetMask',
1311 'EFDFInterfaceLibraryName':
'LibraryName'}
1312 for prop, value
in ef_overrides.items():
1313 setattr(flags.Trigger.Online.EFInterface, _prop2flag[prop], value)
1317 log.info(
"Executing precommand(s)")
1318 for cmd
in args.precommand:
1319 log.info(
" %s", cmd)
1320 exec(cmd, globals(), {
'flags': flags})
1323 is_database = args.use_database
1327 if not is_database
and args.jobOptions:
1328 jobOptions = args.jobOptions
1329 is_pickle = jobOptions.endswith(
'.pkl')
1330 is_json = jobOptions.endswith(
'.json')
1336 crestconn = TriggerCrestUtil.getCrestConnection(args.db_server)
1337 db_alias = f
"{args.crest_server}/{crestconn}"
1338 log.info(
"Loading configuration via CREST from %s with SMK %d", db_alias, args.smk)
1340 db_alias = args.db_server
1341 log.info(
"Loading configuration from database %s with SMK %d", db_alias, args.smk)
1346 num_threads=args.threads, num_slots=args.concurrent_events,
1347 ef_overrides=ef_overrides)
1348 log.info(
"Configuration loaded from database")
1352 log.info(
"Loading configuration from pickle file: %s", jobOptions)
1353 with open(jobOptions,
'rb')
as f:
1354 acc = pickle.load(f)
1355 log.info(
"Configuration loaded from pickle")
1359 log.info(
"Loading configuration from JSON file: %s", jobOptions)
1363 num_threads=args.threads, num_slots=args.concurrent_events,
1364 ef_overrides=ef_overrides)
1365 log.info(
"Configuration loaded from JSON")
1373 log.info(
"Loading CA configuration from: %s", jobOptions)
1376 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
1377 from AthenaConfiguration.MainServicesConfig
import addMainSequences
1378 from TrigServices.TriggerUnixStandardSetup
import commonServicesCfg
1379 from AthenaConfiguration.ComponentFactory
import CompFactory
1381 locked_flags = flags.clone()
1385 cfg = ComponentAccumulator(CompFactory.AthSequencer(
"AthMasterSeq", Sequential=
True))
1386 cfg.setAppProperty(
'ExtSvcCreates',
False)
1387 cfg.setAppProperty(
"MessageSvcType",
"TrigMessageSvc")
1388 cfg.setAppProperty(
"JobOptionsSvcType",
"TrigConf::JobOptionsSvc")
1391 addMainSequences(locked_flags, cfg)
1392 cfg.merge(commonServicesCfg(locked_flags))
1395 cfg_func = AthHLT.getCACfg(jobOptions)
1396 cfg.merge(cfg_func(flags))
1399 if args.postcommand:
1400 log.info(
"Executing postcommand(s)")
1401 for cmd
in args.postcommand:
1402 log.info(
" %s", cmd)
1403 exec(cmd, globals(), {
'flags': flags,
'cfg': cfg})
1404 args.postcommand = []
1407 fname =
"HLTJobOptions"
1408 log.info(
"Dumping configuration to %s.pkl and %s.json", fname, fname)
1409 with open(f
"{fname}.pkl",
"wb")
as f:
1412 from TrigConfIO.JsonUtils
import create_joboptions_json
1413 create_joboptions_json(f
"{fname}.pkl", f
"{fname}.json")
1416 if args.dump_config_exit:
1417 log.info(
"Configuration dumped to %s.json. Exiting...", fname)
1422 log.info(
"Configuration dumped to %s.json. Re-exec...", fname)
1423 AthHLT.reload_from_json(f
"{fname}.json", suppress_args=PscConfig.unparsedArguments + [
'--dump-config'], jobOptions=args.jobOptions)
1426 if args.postcommand:
1427 log.info(
"Executing postcommand(s)")
1428 for cmd
in args.postcommand:
1429 log.info(
" %s", cmd)
1430 exec(cmd, globals(), {
'flags': flags,
'acc': acc})
1433 if args.dump_config
or args.dump_config_exit:
1434 fname =
"HLTJobOptions"
1438 from TrigConfIO.HLTTriggerConfigAccess
import HLTJobOptionsAccess
1439 log.info(
"Fetching configuration from database for dump...")
1440 jo_access = HLTJobOptionsAccess(dbalias=acc.db_server, smkey=acc.smk)
1441 props = jo_access.algorithms()
1443 log.info(
"Dumping configuration to %s.json", fname)
1444 hlt_json = {
'filetype':
'joboptions',
'properties': props}
1445 with open(f
"{fname}.json",
"w")
as f:
1446 json.dump(hlt_json, f, indent=4, sort_keys=
True, ensure_ascii=
True)
1450 props = acc.properties
1452 log.info(
"Dumping configuration to %s.json", fname)
1453 hlt_json = {
'filetype':
'joboptions',
'properties': props}
1454 with open(f
"{fname}.json",
"w")
as f:
1455 json.dump(hlt_json, f, indent=4, sort_keys=
True, ensure_ascii=
True)
1457 log.warning(
"No properties available to dump")
1461 app_props, msg_props, comp_props = acc.gatherProps()
1462 props = {
"ApplicationMgr": app_props,
"MessageSvc": msg_props}
1463 for comp, name, value
in comp_props:
1464 props.setdefault(comp, {})[name] = value
1466 log.info(
"Dumping configuration to %s.json", fname)
1467 hlt_json = {
'filetype':
'joboptions',
'properties': props}
1468 with open(f
"{fname}.json",
"w")
as f:
1469 json.dump(hlt_json, f, indent=4, sort_keys=
True, ensure_ascii=
True)
1474 if args.dump_config_exit:
1475 log.info(
"Configuration dumped. Exiting...")
1479 log.info(
"Starting Athena execution...")
1484 worker_dir = os.path.join(os.getcwd(),
"athenaHLT_workers",
"athenaHLT-01")
1485 if not os.path.exists(worker_dir):
1486 log.info(
"Creating worker directory: %s", worker_dir)
1487 os.makedirs(worker_dir, exist_ok=
True)
1492 if args.interactive:
1493 log.info(
"Interactive mode - call acc.run() to execute")
1495 code.interact(local={
'acc': acc,
'flags': flags})
1498 from AthenaCommon
import ExitCodes
1502 sc = acc.run(args.number_of_events)
1504 exitcode = ExitCodes.EXE_ALG_FAILURE
1505 except SystemExit
as e:
1506 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code == 1
else e.code
1508 traceback.print_exc()
1509 exitcode = ExitCodes.UNKNOWN_EXCEPTION
1513 log.info(
'Leaving with code %d: "%s"', exitcode, ExitCodes.what(exitcode))