ATLAS Offline Software
Loading...
Searching...
No Matches
test_coracool Namespace Reference

Functions

 fetch_lb_timestamps (since, until)
 test_coracool ()
 test_refcounting ()

Variables

str folder_path = "/SCT/DAQ/Configuration/Module"
 database = Databases.get_instance("COOLONL_SCT/COMP200")
 folder = database.getFolder(folder_path)
 since
 until

Function Documentation

◆ fetch_lb_timestamps()

test_coracool.fetch_lb_timestamps ( since,
until )
Read the timestamps of all luminosity blocks between 
the run-lumi IoV (since, until)

Definition at line 25 of file test_coracool.py.

25def fetch_lb_timestamps(since, until):
26 """
27 Read the timestamps of all luminosity blocks between
28 the run-lumi IoV (since, until)
29 """
30 timestamps = fetch_iovs("COOLONL_TRIGGER/COMP200::/TRIGGER/LUMI/LBLB", since, until,
31 with_channel=False, what="all")
32 return timestamps[0].StartTime, timestamps[-1].EndTime, timestamps
33

◆ test_coracool()

test_coracool.test_coracool ( )

Definition at line 34 of file test_coracool.py.

34def test_coracool():
35
36 if "<coracool>" not in folder.description():
37 print(f"{folder.fullPath()} is not a coracool folder")
38 return
39
40 variables = ["group", "id"]
41
42 record = namedtuple("coracool_record", "since until channel elements")
43 element = namedtuple("element", " ".join(variables))
44
45 start = time()
46
47 objects = browse_coracool(database, folder_path, since, until,
48 cool.ChannelSelection(), "", variables, record, element)
49
50 elapsed = time()-start
51 print("Took %.2f to browse_coracool" % elapsed)
52
53 print(len(objects))
54
55 bad = [x for x in objects if any(el.group == -1 for el in x.elements)]
56 print(len(bad))
57
58 return
59
void print(char *figname, TCanvas *c1)
PyObject * browse_coracool(IDatabasePtr cooldb, const string &folder, ValidityKey since, ValidityKey until, const ChannelSelection &cs=ChannelSelection::all(), const char *tag="", PyObject *to_fetch=NULL, PyObject *object_converter=NULL, PyObject *inner_object_converter=NULL, PyObject *iovkey_wrapper=NULL)

◆ test_refcounting()

test_coracool.test_refcounting ( )

Definition at line 60 of file test_coracool.py.

60def test_refcounting():
61 record = namedtuple("coracool_record", "since until channel elements")
62 element = namedtuple("element", "group id")
63
64 from time import time
65 start = time()
66
67 # repr() can allocate a list object the first time it's called.
68 # (cf. Py_ReprEnter)
69 # Make sure that happens now, before we do the gc check.
70 repr([1])
71
72 objects = None
73
74 before_objects = set(id(x) for x in gc.get_objects())
75 gc.collect()
76
77 try: raise RuntimeError
78 except Exception: pass
79
80 print("Objects alive before call:", len(gc.get_objects()))
81
82 try:
83 objects = browse_coracool(database, folder_path, since, until,
84 cool.ChannelSelection(), "", ["group", "id"],
85 record, element)
86
87 except Exception as e:
88 print("Caught exception ", e)
89 del e
90
91 elapsed = time() - start
92 print("Took %.3f to browse folder" % elapsed)
93
94 assert objects is not None, 'Null return from browse_coracool'
95
96 print("Return type:", type(objects), type(objects[0]))
97 print("Result length =", len(objects))
98 print("Result index 0 length =", len(objects[0]))
99 print("Result index 0 =", objects[0])
100 del objects
101
102
103 print("Objects alive before cleanup:", len(gc.get_objects()))
104
105 gc.collect()
106
107 print("Objects alive after:", len(gc.get_objects()))
108
109 after_objects = gc.get_objects()
110
111 new_objects = set(id(x) for x in after_objects) - before_objects
112
113 # new_objects = filter(lambda x: id(x) in new_objects and x != before_objects, after_objects)
114 new_objects = [x for x in after_objects if id(x) in new_objects and x != before_objects and x != new_objects]
115
116 assert new_objects == [], 'Lingering objects after garbage collection'
117
118
STL class.

Variable Documentation

◆ database

test_coracool.database = Databases.get_instance("COOLONL_SCT/COMP200")

Definition at line 20 of file test_coracool.py.

◆ folder

test_coracool.folder = database.getFolder(folder_path)

Definition at line 21 of file test_coracool.py.

◆ folder_path

str test_coracool.folder_path = "/SCT/DAQ/Configuration/Module"

Definition at line 18 of file test_coracool.py.

◆ since

test_coracool.since

Definition at line 22 of file test_coracool.py.

◆ until

test_coracool.until

Definition at line 22 of file test_coracool.py.