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

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

References genParticles_cff.map, and str.

Referenced by load_steps_and_workflows().

◆ fix_run()

def relval_machine.fix_run (   run)

Definition at line 25 of file relval_machine.py.

25 def fix_run(run):
26  runs = run.replace(" ", "").replace("[", "").replace("]", "").split(",")
27  int_runs = []
28  for item in runs:
29  if item.isdigit():
30  int_runs.append(int(item))
31  else:
32  print("WARNING: run is in bad format: {0}".format(run))
33  return int_runs
34 

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

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

Referenced by load_steps_and_workflows().

◆ load_steps_and_workflows()

def relval_machine.load_steps_and_workflows ( )

Definition at line 49 of file relval_machine.py.

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

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:25
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:35
relval_machine.load_steps_and_workflows
def load_steps_and_workflows()
Definition: relval_machine.py:49
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
str
#define str(s)
Definition: TestProcessor.cc:53
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:12
format
genParticles_cff.map
map
Definition: genParticles_cff.py:11
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444