Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:44:24

0001 #!/usr/bin/env python3
0002 from __future__ import print_function
0003 import os, time,sys
0004 
0005 class configuration:
0006    datasetPat  = '/StreamExpress/Run2018*-SiStripCalMinBias__AAG__-Express-v*/ALCARECO'
0007    CMSSWDIR    = 'TO_FILL_IN'
0008    RUNDIR      = CMSSWDIR+'CalibTracker/SiStripCommon/test/MakeCalibrationTrees/'
0009    CASTORDIR   = '/store/group/dpg_tracker_strip/comm_tracker/Strip/Calibration/calibrationtree/GR18__AAG__'
0010    nFilesPerJob= 25
0011    collection  = "ALCARECOSiStripCalMinBias__AAG__"
0012    globalTag   = "TO_UPDATE"
0013    initEnv     = ""
0014    dasClient   = "dasgoclient"
0015    eosLs       = "eos ls "
0016    def  __init__(self,AAG=False,debug=False):
0017       self.relaunchList= []
0018       self.firstRun    = -1
0019       self.lastRun     = 999999
0020       self.launchedRuns = []
0021       self.AAG          = AAG
0022       self.datasetPat   = self.datasetPat.replace("__AAG__","AAG" if self.AAG else "")
0023       self.CASTORDIR    = self.CASTORDIR.replace ("__AAG__","_Aag" if self.AAG else "")
0024       self.collection   = self.collection.replace("__AAG__","AAG" if self.AAG else "")
0025       self.initEnv+='cd ' + self.CMSSWDIR + '; '
0026       self.initEnv+='export CMS_PATH=/cvmfs/cms.cern.ch; '
0027       self.initEnv+='source /afs/cern.ch/cms/cmsset_default.sh' + ';'
0028       self.initEnv+='eval `scramv1 runtime -sh`' + ';'
0029 
0030       proxyFile = "/afs/cern.ch/user/%s/%s/private/x509up_u%s"%(os.environ["USER"][0],os.environ["USER"],os.geteuid())
0031       if not os.path.isfile(proxyFile):
0032         print("WARNING : No private proxy file to use. Can't run on data outside of CERN")
0033       else:
0034         T = (time.time()-os.stat(proxyFile).st_mtime)
0035         print("proxy file created %sh and %s min ago"%(int(T)/3600, int(T)/60- 60*(int(T)/3600)))
0036         if T < 36000:
0037           # Proxy valid for 12hours --> Ignore files created more than 10h ago"
0038           self.initEnv+='export X509_USER_PROXY=%s ;'%proxyFile
0039         else:
0040           print("WARNING : proxy file expired. Can't run on data outside of CERN")
0041 
0042       self.initEnv+='cd -;'
0043       self.submit = not debug
0044       self.integrity = False
0045       self.setupEnviron()
0046       print("Integrity = %s"%self.checkIntegrity())
0047 
0048    def checkIntegrity(self):
0049       goodConfig=True
0050 
0051       #Check dataset :
0052       d = self.datasetPat.split("/")
0053       if not len(d) == 4:
0054          print("Bad dataset. Expecting 4 '/'")
0055          goodConfig=False
0056       if not d[0]=='':
0057          print("Bad dataset. Expecting nothing before first '/'")
0058          goodConfig=False
0059       if not len(d[1])>0 or not len(d[2]) > 0 or not len(d[3]) > 0:
0060          print("Bad dataset. Expecting text between '/'")
0061          goodConfig=False
0062       if os.path.isdir(self.datasetPat):
0063          print("Bad dataset. Can't be an existing directory")
0064          goodConfig=False
0065       #Check all paths exist
0066       if not os.path.isdir(self.CMSSWDIR):
0067          print("CMSSW dir does not exist.")
0068          goodConfig = False
0069       if not os.path.isdir(self.RUNDIR):
0070          print("RUN dir does not exist.")
0071          goodConfig = False
0072 
0073       #Check castor path exists FIXME
0074       cmd = self.eosLs.replace("-lrth","")+self.CASTORDIR
0075       cmd = cmd[:-2]+"*"
0076       (status,output) = subprocess.getstatusoutput(cmd)
0077       if status or not self.CASTORDIR.split("/")[-1] in output:
0078          print(cmd)
0079          print(output)
0080          print("CASTOR dir does not exist.")
0081          goodConfig = False
0082       self.integrity = goodConfig
0083       return goodConfig
0084 
0085    def setupEnviron(self):
0086       os.environ['PATH'] = os.getenv('PATH')+':/afs/cern.ch/cms/sw/common/'
0087       os.environ['CMS_PATH']='/afs/cern.ch/cms'
0088       os.environ['FRONTIER_PROXY'] = 'http://cmst0frontier.cern.ch:3128'
0089       os.environ['SCRAM_ARCH']='slc6_amd64_gcc530'
0090    def __str__(self):
0091       description = "Configuration :\n"
0092       description+= "First run  = %s\n"   %self.firstRun
0093       description+= "After Abort= %s\n"   %self.AAG
0094       description+= "dataset    = %s\n"   %self.datasetPat
0095       description+= "CMSSW      = %s\n"   %self.CMSSWDIR
0096       description+= "RUNDIR     = %s\n"   %self.RUNDIR
0097       description+= "CASTOR     = %s\n"   %self.CASTORDIR
0098       description+= "nFiles     = %s\n"   %self.nFilesPerJob
0099       description+= "collection = %s\n"   %self.collection
0100       description+= "initEnv    = %s\n"   %self.initEnv
0101       description+= "submit     = %s\n"   %self.submit
0102       return description
0103 
0104 if __name__ == "__main__":
0105    c = configuration(True)
0106    print(c)
0107 
0108