10 """Create the configuration JSON file from the properties in `pkl_file`
11 and save it into `json_file`. If `createDBJson` then also create the
12 JSON file for database upload at P1."""
14 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
16 with open(pkl_file,
"rb")
as f:
19 if isinstance(cfg, ComponentAccumulator):
20 app_props, msg_props, comp_props = cfg.gatherProps()
21 props[
"ApplicationMgr"] = app_props
22 props[
"MessageSvc"] = msg_props
23 for comp, name, value
in comp_props:
24 props.setdefault(comp, {})[name] = value
30 hlt_json = {
'filetype' :
'joboptions'}
31 hlt_json[
'properties'] = props
34 with open(json_file,
"w")
as f:
35 json.dump(hlt_json, f, indent=4, sort_keys=
True, ensure_ascii=
True)
40 assert json_file[-5:] ==
".json"
41 db_file = json_file.replace(
".json",
".db.json")
47 """ modifies a number of job properties to run from the TriggerDB and writes out modified JSON
49 from AthenaCommon.Logging
import logging
50 log = logging.getLogger(
"JsonUtils")
52 with open(json_file,
'r')
as f:
54 properties = jocat[
'properties']
56 def mod(props, alg, prop, fnc):
58 log.warning(
"Asked to modify property of %s but it does not exist", alg)
61 origVal = props[alg].
get(prop,
"")
62 props[alg][prop] = fnc(origVal)
66 mod( properties,
"LVL1ConfigSvc",
"InputType",
lambda x :
"DB" )
67 mod( properties,
"HLTConfigSvc",
"InputType",
lambda x :
"DB" )
68 mod( properties,
"HLTPrescaleCondAlg",
"Source",
lambda x :
"COOL" )
69 mod( properties,
"HLTPrescaleCondAlg",
"TriggerDB",
lambda x :
"JOSVC" )
71 mod( properties,
"LVL1ConfigSvc",
"HLTJsonFileName",
lambda x :
"None" )
72 mod( properties,
"LVL1ConfigSvc",
"L1JsonFileName",
lambda x :
"None" )
73 mod( properties,
"TrigConf__BunchGroupCondAlg",
"Filename",
lambda x :
"None" )
74 mod( properties,
"HLTConfigSvc",
"HLTJsonFileName",
lambda x :
"None" )
75 mod( properties,
"HLTConfigSvc",
"L1JsonFileName",
lambda x :
"None" )
76 mod( properties,
"HLTConfigSvc",
"MonitoringJsonFileName",
lambda x :
"None" )
77 mod( properties,
"HLTPrescaleCondAlg",
"Filename",
lambda x :
"None" )
79 with open(db_file,
'w')
as f:
80 json.dump(jocat, f, indent=4, sort_keys=
True, ensure_ascii=
True)
83 if __name__ ==
"__main__":
86 print(
"Syntax: %s HLTJobOptions.[pkl,json]" % sys.argv[0].
split(
"/")[-1])
87 print(
" .pkl: convert to JSON and DB JSON")
88 print(
" .json: convert to DB JSON")
92 ext = os.path.splitext(fname)[1]
94 with open(fname)
as fh:
95 hlt_json = json.load( fh )
96 properties = hlt_json[
"properties"]
101 print(
"Unkown file format")