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
|
#!/usr/bin/env python3
import os, time,sys
class configuration:
datasetPat = '/StreamExpress/Run2018*-SiStripCalMinBias__AAG__-Express-v*/ALCARECO'
CMSSWDIR = 'TO_FILL_IN'
RUNDIR = CMSSWDIR+'CalibTracker/SiStripCommon/test/MakeCalibrationTrees/'
CASTORDIR = '/store/group/dpg_tracker_strip/comm_tracker/Strip/Calibration/calibrationtree/GR18__AAG__'
nFilesPerJob= 25
collection = "ALCARECOSiStripCalMinBias__AAG__"
globalTag = "TO_UPDATE"
initEnv = ""
dasClient = "dasgoclient"
eosLs = "eos ls "
def __init__(self,AAG=False,debug=False):
self.relaunchList= []
self.firstRun = -1
self.lastRun = 999999
self.launchedRuns = []
self.AAG = AAG
self.datasetPat = self.datasetPat.replace("__AAG__","AAG" if self.AAG else "")
self.CASTORDIR = self.CASTORDIR.replace ("__AAG__","_Aag" if self.AAG else "")
self.collection = self.collection.replace("__AAG__","AAG" if self.AAG else "")
self.initEnv+='cd ' + self.CMSSWDIR + '; '
self.initEnv+='export CMS_PATH=/cvmfs/cms.cern.ch; '
self.initEnv+='source /afs/cern.ch/cms/cmsset_default.sh' + ';'
self.initEnv+='eval `scramv1 runtime -sh`' + ';'
proxyFile = "/afs/cern.ch/user/%s/%s/private/x509up_u%s"%(os.environ["USER"][0],os.environ["USER"],os.geteuid())
if not os.path.isfile(proxyFile):
print("WARNING : No private proxy file to use. Can't run on data outside of CERN")
else:
T = (time.time()-os.stat(proxyFile).st_mtime)
print("proxy file created %sh and %s min ago"%(int(T)/3600, int(T)/60- 60*(int(T)/3600)))
if T < 36000:
# Proxy valid for 12hours --> Ignore files created more than 10h ago"
self.initEnv+='export X509_USER_PROXY=%s ;'%proxyFile
else:
print("WARNING : proxy file expired. Can't run on data outside of CERN")
self.initEnv+='cd -;'
self.submit = not debug
self.integrity = False
self.setupEnviron()
print("Integrity = %s"%self.checkIntegrity())
def checkIntegrity(self):
goodConfig=True
#Check dataset :
d = self.datasetPat.split("/")
if not len(d) == 4:
print("Bad dataset. Expecting 4 '/'")
goodConfig=False
if not d[0]=='':
print("Bad dataset. Expecting nothing before first '/'")
goodConfig=False
if not len(d[1])>0 or not len(d[2]) > 0 or not len(d[3]) > 0:
print("Bad dataset. Expecting text between '/'")
goodConfig=False
if os.path.isdir(self.datasetPat):
print("Bad dataset. Can't be an existing directory")
goodConfig=False
#Check all paths exist
if not os.path.isdir(self.CMSSWDIR):
print("CMSSW dir does not exist.")
goodConfig = False
if not os.path.isdir(self.RUNDIR):
print("RUN dir does not exist.")
goodConfig = False
#Check castor path exists FIXME
cmd = self.eosLs.replace("-lrth","")+self.CASTORDIR
cmd = cmd[:-2]+"*"
(status,output) = subprocess.getstatusoutput(cmd)
if status or not self.CASTORDIR.split("/")[-1] in output:
print(cmd)
print(output)
print("CASTOR dir does not exist.")
goodConfig = False
self.integrity = goodConfig
return goodConfig
def setupEnviron(self):
os.environ['PATH'] = os.getenv('PATH')+':/afs/cern.ch/cms/sw/common/'
os.environ['CMS_PATH']='/afs/cern.ch/cms'
os.environ['FRONTIER_PROXY'] = 'http://cmst0frontier.cern.ch:3128'
os.environ['SCRAM_ARCH']='slc6_amd64_gcc530'
def __str__(self):
description = "Configuration :\n"
description+= "First run = %s\n" %self.firstRun
description+= "After Abort= %s\n" %self.AAG
description+= "dataset = %s\n" %self.datasetPat
description+= "CMSSW = %s\n" %self.CMSSWDIR
description+= "RUNDIR = %s\n" %self.RUNDIR
description+= "CASTOR = %s\n" %self.CASTORDIR
description+= "nFiles = %s\n" %self.nFilesPerJob
description+= "collection = %s\n" %self.collection
description+= "initEnv = %s\n" %self.initEnv
description+= "submit = %s\n" %self.submit
return description
if __name__ == "__main__":
c = configuration(True)
print(c)
|