CMS 3D CMS Logo

Functions
relval_machine Namespace Reference

Functions

def convert_keys_to_string (dictionary)
 
def fix_run (run)
 
def get_json_files ()
 
def load_steps_and_workflows ()
 

Function Documentation

◆ convert_keys_to_string()

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 36 of file relval_machine.py.

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, six.iteritems(dictionary)))
45  elif isinstance(dictionary, collections.Iterable):
46  return type(dictionary)(map(convert_keys_to_string, dictionary))
47  else:
48  return dictionary
49 

References genParticles_cff.map, and str.

Referenced by load_steps_and_workflows().

◆ fix_run()

def relval_machine.fix_run (   run)

Definition at line 26 of file relval_machine.py.

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
35 

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

Referenced by load_steps_and_workflows().

◆ get_json_files()

def relval_machine.get_json_files ( )

Definition at line 13 of file relval_machine.py.

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 
25 

Referenced by load_steps_and_workflows().

◆ load_steps_and_workflows()

def relval_machine.load_steps_and_workflows ( )

Definition at line 50 of file relval_machine.py.

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 

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

relval_machine.fix_run
def fix_run(run)
Definition: relval_machine.py:26
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
relval_machine.convert_keys_to_string
def convert_keys_to_string(dictionary)
Definition: relval_machine.py:36
relval_machine.load_steps_and_workflows
def load_steps_and_workflows()
Definition: relval_machine.py:50
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
str
#define str(s)
Definition: TestProcessor.cc:52
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
createfilelist.int
int
Definition: createfilelist.py:10
relval_machine.get_json_files
def get_json_files()
Definition: relval_machine.py:13
format
genParticles_cff.map
map
Definition: genParticles_cff.py:11
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444