ATLAS Offline Software
Functions | Variables
python.JsonUtils Namespace Reference

Functions

def create_joboptions_json (pkl_file, json_file, createDBJson=True)
 
def modifyConfigForP1 (json_file, db_file)
 

Variables

 fname
 
 ext
 
 hlt_json
 
 properties
 

Function Documentation

◆ create_joboptions_json()

def python.JsonUtils.create_joboptions_json (   pkl_file,
  json_file,
  createDBJson = True 
)
Create the configuration JSON file from the properties in `pkl_file`
and save it into `json_file`. If `createDBJson` then also create the
JSON file for database upload at P1.

Definition at line 9 of file JsonUtils.py.

9 def create_joboptions_json(pkl_file, json_file, createDBJson = True):
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."""
13 
14  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15 
16  with open(pkl_file, "rb") as f:
17  cfg = pickle.load(f)
18  props = {}
19  if isinstance(cfg, ComponentAccumulator): # CA-based configuration
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
25  else: # legacy job options
26  svc = pickle.load(f) # some specialized services (only in legacy config)
27  props = cfg
28  props.update(svc) # merge the two dictionaries
29 
30  hlt_json = {'filetype' : 'joboptions'}
31  hlt_json['properties'] = props
32 
33  # write JSON file
34  with open(json_file, "w") as f:
35  json.dump(hlt_json, f, indent=4, sort_keys=True, ensure_ascii=True)
36 
37  if createDBJson:
38  # also create a configuration JSON file that can be uploaded
39  # to the triggerdb for running at P1
40  assert json_file[-5:] == ".json"
41  db_file = json_file.replace(".json", ".db.json")
42 
43  modifyConfigForP1(json_file, db_file)
44 
45 

◆ modifyConfigForP1()

def python.JsonUtils.modifyConfigForP1 (   json_file,
  db_file 
)
modifies a number of job properties to run from the TriggerDB and writes out modified JSON

Definition at line 46 of file JsonUtils.py.

46 def modifyConfigForP1(json_file, db_file):
47  """ modifies a number of job properties to run from the TriggerDB and writes out modified JSON
48  """
49  from AthenaCommon.Logging import logging
50  log = logging.getLogger("JsonUtils")
51 
52  with open(json_file, 'r') as f:
53  jocat = json.load(f)
54  properties = jocat['properties']
55 
56  def mod(props, alg, prop, fnc):
57  if alg not in props:
58  log.warning("Asked to modify property of %s but it does not exist", alg)
59  return
60 
61  origVal = props[alg].get(prop, "")
62  props[alg][prop] = fnc(origVal)
63 
64 
65  # L1 and HLT Config Svc must read from db
66  mod( properties, "LVL1ConfigSvc", "InputType", lambda x : "DB" )
67  mod( properties, "HLTConfigSvc", "InputType", lambda x : "DB" )
68  mod( properties, "HLTPrescaleCondAlg", "Source", lambda x : "COOL" ) # prescales will be read from COOL online
69  mod( properties, "HLTPrescaleCondAlg", "TriggerDB", lambda x : "JOSVC" ) # configuration will be taken from the JOSvc at P1
70  # remove filenames to avoid duplicates
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" )
78 
79  with open(db_file,'w') as f:
80  json.dump(jocat, f, indent=4, sort_keys=True, ensure_ascii=True)
81 
82 

Variable Documentation

◆ ext

python.JsonUtils.ext

Definition at line 92 of file JsonUtils.py.

◆ fname

python.JsonUtils.fname

Definition at line 91 of file JsonUtils.py.

◆ hlt_json

python.JsonUtils.hlt_json

Definition at line 95 of file JsonUtils.py.

◆ properties

python.JsonUtils.properties

Definition at line 96 of file JsonUtils.py.

Logging
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
python.JsonUtils.create_joboptions_json
def create_joboptions_json(pkl_file, json_file, createDBJson=True)
Definition: JsonUtils.py:9
python.JsonUtils.modifyConfigForP1
def modifyConfigForP1(json_file, db_file)
Definition: JsonUtils.py:46
Trk::open
@ open
Definition: BinningType.h:40
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127