CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
relval_machine Namespace Reference

Functions

def convert_keys_to_string
 
def fix_run
 
def get_json_files
 
def load_steps_and_workflows
 

Variables

tuple steps = Steps()
 
tuple workflows = Matrix()
 

Function Documentation

def relval_machine.convert_keys_to_string (   dictionary)
Recursively converts dictionary keys to strings.
    Utility to help deal with unicode keys in dictionaries created from json requests.
    In order to pass dict to function as **kwarg we should transform key/value to str.

Definition at line 35 of file relval_machine.py.

References str.

Referenced by load_steps_and_workflows().

35 
36 def convert_keys_to_string(dictionary):
37  """ Recursively converts dictionary keys to strings.
38  Utility to help deal with unicode keys in dictionaries created from json requests.
39  In order to pass dict to function as **kwarg we should transform key/value to str.
40  """
41  if isinstance(dictionary, str):
42  return str(dictionary)
43  elif isinstance(dictionary, collections.Mapping):
44  return dict(map(convert_keys_to_string, dictionary.items()))
45  elif isinstance(dictionary, collections.Iterable):
46  return type(dictionary)(map(convert_keys_to_string, dictionary))
47  else:
48  return dictionary
def convert_keys_to_string
#define str(s)
def relval_machine.fix_run (   run)

Definition at line 25 of file relval_machine.py.

References print(), python.rootplot.root2matplotlib.replace(), and submitPVValidationJobs.split().

Referenced by load_steps_and_workflows().

25 
26 def fix_run(run):
27  runs = run.replace(" ", "").replace("[", "").replace("]", "").split(",")
28  int_runs = []
29  for item in runs:
30  if item.isdigit():
31  int_runs.append(int(item))
32  else:
33  print("WARNING: run is in bad format: {0}".format(run))
34  return int_runs
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def relval_machine.get_json_files ( )

Definition at line 12 of file relval_machine.py.

Referenced by load_steps_and_workflows().

12 
13 def get_json_files():
14  cwd = os.path.join(os.getcwd(), "json_data")
15  if not os.path.exists(cwd):
16  return []
17 
18  json_files = []
19  for f in os.listdir(cwd):
20  full_path = os.path.join(cwd, f)
21  if os.path.isfile(full_path) and f.endswith(".json"):
22  json_files.append(full_path)
23  return json_files
24 
def relval_machine.load_steps_and_workflows ( )

Definition at line 49 of file relval_machine.py.

References convert_keys_to_string(), fix_run(), get_json_files(), and mps_monitormerge.items.

49 
51  data_files = get_json_files()
52  for index, data_file in enumerate(data_files):
53  with open(data_file, "r") as f:
54  data = json.load(f)
55  data = convert_keys_to_string(data)
56  label = data["label"]
57  steps_names = []
58  for step_name, step in data["steps"].items():
59  steps_names.append((step_name, step["sequence_number"]))
60  if step_name in steps:
61  continue # this step was inserted already
62 
63  # inputInfo case
64  if "inputInfo" in step:
65  input_info = step["inputInfo"]
66  if "run" in input_info:
67  input_info["run"] = fix_run(input_info["run"])
68 
69  steps[step_name] = {
70  'INPUT': InputInfo(**input_info)
71  }
72  # step with parameters
73  elif "parameters" in step:
74  steps[step_name] = step["parameters"]
75  else:
76  raise Exception("Wrong step format in {0} file".format(data_file))
77 
78  sorted_steps = sorted(steps_names, key=lambda step: step[1]) # sort steps by sequence number
79  sorted_steps_names = [step_name[0] for step_name in sorted_steps] # filter only step names
80 
81  workflows[1000000.0 + 0.1*index] = [label, sorted_steps_names]
82 
83 
85 
def load_steps_and_workflows
def convert_keys_to_string

Variable Documentation

tuple relval_machine.steps = Steps()

Definition at line 9 of file relval_machine.py.

Referenced by HLTMuonValidator.dqmBeginRun(), DD4hep_TrackingMaterialPlotter.fill_gradient(), TrackingMaterialPlotter.fill_gradient(), DD4hep_ListGroups.fillGradient(), ListGroups.fillGradient(), MuonResiduals6DOFrphiFitter.fit(), MuonResiduals5DOFFitter.fit(), MuonResiduals6DOFFitter.fit(), XHistogram.splitSegment(), DD4hep_XHistogram.splitSegment(), HLTMuonValidator.stepLabels(), CosmicMuonUtilities.stepPropagate(), and CSCGasCollisions.writeSummary().

tuple relval_machine.workflows = Matrix()

Definition at line 8 of file relval_machine.py.