-
Notifications
You must be signed in to change notification settings - Fork 32
/
update-context-collection.py
42 lines (32 loc) · 1.15 KB
/
update-context-collection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import strax
import straxen
from straxen.contexts import *
from utilix import DB
import datetime
db = DB()
# list of contexts that gets tracked in runDB context collection
# needs to be maintained for each straxen release
context_list = ['xenonnt_led',
'xenonnt_online',
]
# returns the list of dtype, hashes for a given strax context
def get_hashes(st):
return set([(d, st.key_for('0', d).lineage_hash)
for p in st._plugin_class_registry.values()
for d in p.provides])
def main():
for context in context_list:
# get these from straxen.contexts.*
st = eval("%s()" % context)
hashes = get_hashes(st)
hash_dict = {dtype: h for dtype, h in hashes}
doc = dict(name=context,
date_added=datetime.datetime.utcnow(),
hashes=hash_dict,
straxen_version=straxen.__version__,
strax_version=strax.__version__
)
# update the context collection using utilix + runDB_api
db.update_context_collection(doc)
if __name__ == "__main__":
main()