-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_test.py
119 lines (98 loc) · 3.23 KB
/
module_test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#Main python script for the VEGAS analysis pipeline
import sys
import time
from plutils import *
inst_filename = sys.argv[1]
try:
f = open(inst_filename)
except OSError:
print("Instructions file ", inst_filename, " could not be opened.")
raise
else:
f.close()
print(inst_filename)
testmod.testmod()
#Test the database functionality
print('-'*25)
print('Testing DB functionality')
tmpCD={'GLOBALCONFIG' : {'DBHOSTNAME' : 'romulus.ucsc.edu', 'DBNAME' : 'VERITAS', 'DBUSERNAME' : 'readonly'}}
dbcnx=database.DBConnection(configdict=tmpCD)
host=dbcnx.host
db=dbcnx.db
user=dbcnx.user
print('host = ', host)
print('db = ', db)
print('user = ', user)
tmp_runnum='79227'
print('Info for run ', tmp_runnum, ':')
flasher=dbcnx.get_calib_run(tmp_runnum)
ddate=dbcnx.get_ddate(tmp_runnum)
src_id=dbcnx.get_source_id(tmp_runnum)
print(' flasher run = ', flasher)
print(' ddate = ', ddate)
print(' src_id = ', src_id)
'''
#Test condor functionality
print('-'*25)
print('Testing condor functionality')
print('Attempting initalization/configuration...')
cs=condor.CondorJob(executable='sleep_test.sh', arguments='5', universe='vanilla', workingdir='/home/vhep/ssscott/tmp', log='condor_test.log', output='condor_test.out', error='condor_test.error', requirements='')
print(' status = ', cs.status)
print('Attempting submission...')
cs.submit()
print(' status = ', cs.status)
print(' job id = ', cs.jobid)
print('Waiting for test job to terminate...')
while(cs.get_status() != 'terminated'):
print(' status = ', cs.get_status())
time.sleep(1)
print('Job should have terminated...')
print(' status = ', cs.status)
print(' exit status = ', cs.exitstatus)
'''
print('-'*25)
print('Testing instructions file instreader')
read_inst = instreader.InstFileReader(inst_filename)
configdict = read_inst.get_config_dict()
print ('configdict: ', configdict)
"""
print('-'*25)
print('Testing config file configwriter')
cw = configwriter.ConfigWriter(configdict,'VASTAGE1:GRP1',1, '/home/vhep/ssscott/tmp')
cw.write('config')
cw.write('cuts')
print(' Config file: ', cw.configfilepath)
print(' Cuts file: ', cw.cutsfilepath)
"""
# Run Group Manager
print('-'*25)
print('Testing run group manager functionality')
rgm = runmanager.RunGroupManager(configdict,dbcnx)
grpdict = rgm.get_group_dict()
print(' Groupdict:')
print(' ', grpdict)
subgroup1 = 'GRP1:GRP2'
subgroup2 = 'GRP1'
print(' subgroup1: ', subgroup1)
rg1 = rgm.get_run_groups(subgroup1)
print(' ', rg1)
for grpid,rg in rg1.items():
for rid,r in rg.datarundict.items():
print(' datarun: {0} {1} {2} {3}'.format(r.runnum, r.ddate, r.calib, r.timecuts))
for rid,r in rg.calibrundict.items():
print(' calibrun: {0} {1}'.format(r.runnum, r.ddate))
rg2 =rgm.get_run_groups(subgroup2)
print(' subgroup2: ', rg2)
print(' ', rg2)
for grpid,rg in rg2.items():
for rid,r in rg.datarundict.items():
print(' datarun: {0} {1} {2} {3}'.format(r.runnum, r.ddate, r.calib, r.timecuts))
for rid,r in rg.calibrundict.items():
print(' calibrun: {0} {1}'.format(r.runnum, r.ddate))
#Analysis Testing
print('-'*25)
print('Initalizing analysis core...')
ac = analysis.AnalysisCore(configdict=configdict, runmanager=rgm)
print('Status = {0}'.format(ac.get_status()))
print('Executing...')
ac.execute()