ATLAS Offline Software
Classes | Functions
ros-hitstats-to-json Namespace Reference

Classes

class  LastUpdatedOrderedDict
 
class  LookUpDict
 

Functions

def get_lines (pattern, filename)
 
def split_lines (pattern, lines)
 
def main ()
 

Function Documentation

◆ get_lines()

def ros-hitstats-to-json.get_lines (   pattern,
  filename 
)

Definition at line 42 of file ros-hitstats-to-json.py.

42 def get_lines(pattern, filename):
43  if not os.path.isfile(filename):
44  logging.warning("Cannot open file {}".format(filename))
45  return None
46  with open(filename) as logfile:
47  lines = re.findall("{}.*$".format(pattern),
48  logfile.read(), re.MULTILINE)
49  if len(lines) == 0:
50  logging.warning("Could not find pattern \"{}\" in file {}".format(pattern, filename))
51  return None
52  return lines
53 
54 

◆ main()

def ros-hitstats-to-json.main ( )

Definition at line 67 of file ros-hitstats-to-json.py.

67 def main():
68  logging.basicConfig(stream=sys.stdout,
69  format='%(levelname)-8s %(message)s',
70  level=logging.INFO)
71 
72  ros_stats = LastUpdatedOrderedDict()
73 
74  lines = get_lines(r'^\s*ROS-', 'ros_hitstats_reject.txt')
75  table = split_lines(r'\||,', lines)
76 
77  for row in table:
78  name = row[LookUpDict.ROS_NAME]
79  hit_rate = row[LookUpDict.TOTAL_ROB_FRAC_PER_EVT]
80  data_rate = row[LookUpDict.TOTAL_BYTES_PER_EVT]
81  ros_stats[name] = LastUpdatedOrderedDict({
82  'hits-per-evt': hit_rate,
83  'kbytes-per-evt': float(data_rate)/1000
84  })
85 
86  data = LastUpdatedOrderedDict()
87  output_file = 'extra-results.json'
88  if os.path.isfile(output_file):
89  with open(output_file) as f:
90  data.update(json.load(f, object_pairs_hook=LastUpdatedOrderedDict))
91 
92  data.update({'ros-stats': ros_stats})
93 
94  with open(output_file, 'w') as f:
95  json.dump(data, f, indent=4)
96 
97 

◆ split_lines()

def ros-hitstats-to-json.split_lines (   pattern,
  lines 
)

Definition at line 55 of file ros-hitstats-to-json.py.

55 def split_lines(pattern, lines):
56  result = []
57  for line in lines:
58  split_result = []
59  for token in re.split(pattern, line):
60  token = token.replace(' ', '')
61  if not token == '':
62  split_result.append(token)
63  result.append(split_result)
64  return result
65 
66 
ros-hitstats-to-json.main
def main()
Definition: ros-hitstats-to-json.py:67
ros-hitstats-to-json.split_lines
def split_lines(pattern, lines)
Definition: ros-hitstats-to-json.py:55
vtune_athena.format
format
Definition: vtune_athena.py:14
Trk::open
@ open
Definition: BinningType.h:40
readCCLHist.float
float
Definition: readCCLHist.py:83
ros-hitstats-to-json.get_lines
def get_lines(pattern, filename)
Definition: ros-hitstats-to-json.py:42