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

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.

References genParticles_cff.map, and str.

Referenced by load_steps_and_workflows().

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 
def convert_keys_to_string(dictionary)
#define str(s)
def relval_machine.fix_run (   run)

Definition at line 26 of file relval_machine.py.

References createfilelist.int, edm.print(), python.rootplot.root2matplotlib.replace(), and cms::dd.split().

Referenced by load_steps_and_workflows().

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 
std::vector< std::string_view > split(std::string_view, const char *)
def fix_run(run)
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def relval_machine.get_json_files ( )

Definition at line 13 of file relval_machine.py.

Referenced by load_steps_and_workflows().

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 
def relval_machine.load_steps_and_workflows ( )

Definition at line 50 of file relval_machine.py.

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

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 
86 
def fix_run(run)
def load_steps_and_workflows()
def convert_keys_to_string(dictionary)