![]() |
![]() |
Namespaces | |
namespace | embedder |
namespace | matcher |
namespace | prototypes |
namespace | validator |
Functions | |
def | addCrabInputFile |
def | copyFilesFromCastor |
def | copyFilesLocal |
def | dqmWorkflowName |
def | haddInCastor |
def | haddLocal |
def | listFilesInCastor |
def | listFilesLocal |
def | loadCmsProcess |
def | loadCmsProcessFile |
def | loadCrabCfg |
def | loadCrabDefault |
def | parseInput |
def | prependPaths |
def | replaceTemplate |
def | setGridEnv |
def | writeCfg |
def | writeCfgPkl |
Variables | |
tuple | arch = os.getenv('SCRAM_ARCH', None) |
tuple | localrt = os.getenv('LOCALRT', None) |
def tools::addCrabInputFile | ( | crabCfg, | |
inputFile | |||
) |
Definition at line 173 of file tools.py.
00174 : 00175 additionalInputFiles = '' 00176 if crabCfg.has_option('USER','additional_input_files'): 00177 additionalInputFiles = crab_cfg_parser.get('USER','additional_input_files') 00178 00179 if additionalInputFiles: additionalInputFiles += ',%s' % inputFile 00180 else: additionalInputFiles = inputFile 00181 00182 crabCfg.set('USER','additional_input_files',additionalInputFiles) 00183 00184 return crabCfg
def tools::copyFilesFromCastor | ( | castor_dir, | |
output_dir, | |||
type = 'root' |
|||
) |
Definition at line 47 of file tools.py.
00048 : 00049 from subprocess import call 00050 files = listFilesInCastor(castor_dir,type,'') 00051 00052 print "Copying files from %s to %s" % (castor_dir,output_dir) 00053 for item in files: 00054 cmd = ['rfcp',item,output_dir] 00055 print "..." + item 00056 retcode = call(cmd) 00057 if retcode != 0: raise RuntimeError,'Error in copying file %s to directory %s' % (item,output_dir) 00058 00059 return 0
def tools::copyFilesLocal | ( | dir, | |
output_dir, | |||
type = 'root' |
|||
) |
Definition at line 60 of file tools.py.
00061 : 00062 if not dir: raise ValueError,'Please specify valid dir' 00063 if not output_dir: raise ValueError,'Please specify valid output dir' 00064 00065 from subprocess import call 00066 files = listFilesLocal(dir,type) 00067 cmd = ['cp'] 00068 cmd.extend(files) 00069 cmd.append(output_dir) 00070 print cmd 00071 retcode = call(cmd) 00072 return retcode
def tools::dqmWorkflowName | ( | datasetpath, | |
type, | |||
rev = 1 |
|||
) |
def tools::haddInCastor | ( | castor_dir, | |
result_file, | |||
type = 'root' , |
|||
prefix = 'rfio:' , |
|||
suffix = None |
|||
) |
Definition at line 73 of file tools.py.
00073 :',suffix = None): 00074 if not castor_dir: raise ValueError,'Please specify valid castor dir' 00075 if not result_file: raise ValueError,'Please specify valid output file name' 00076 00077 #cmd = 'hadd %s `./listfilesCastor %s | grep %s`'%(result_file,castor_dir,type) 00078 #print "Running",cmd 00079 #os.system(cmd) 00080 from subprocess import call 00081 files = listFilesInCastor(castor_dir,type,prefix) 00082 if suffix: files = [item + suffix for item in files] 00083 00084 cmd = ['hadd',result_file] 00085 cmd.extend(files) 00086 #print cmd 00087 retcode = call(cmd) 00088 return retcode 00089
def tools::haddLocal | ( | dir, | |
result_file, | |||
type = 'root' |
|||
) |
Definition at line 90 of file tools.py.
00091 : 00092 if not dir: raise ValueError,'Please specify valid dir' 00093 if not result_file: raise ValueError,'Please specify valid output file name' 00094 00095 from subprocess import call 00096 files = listFilesLocal(dir,type) 00097 cmd = ['hadd',result_file] 00098 cmd.extend(files) 00099 #print cmd 00100 retcode = call(cmd) 00101 return retcode
def tools::listFilesInCastor | ( | castor_dir, | |
type = 'root' , |
|||
prefix = 'rfio:' |
|||
) |
Definition at line 22 of file tools.py.
00022 :'): 00023 if not castor_dir: raise ValueError,'Please specify valid castor dir' 00024 00025 from subprocess import Popen,PIPE 00026 p1 = Popen(['nsls',castor_dir],stdout=PIPE) 00027 #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE) 00028 #files = [prefix + castor_dir + "/" + item[:-1] for item in p2.stdout] 00029 #p2.stdout.close() 00030 files = [ "%s%s/%s" % (prefix,castor_dir,item.rstrip()) for item in p1.stdout if item.find(type) != -1 ] 00031 p1.stdout.close() 00032 return files 00033
def tools::listFilesLocal | ( | dir, | |
type = 'root' |
|||
) |
Definition at line 34 of file tools.py.
00035 : 00036 if not dir: raise ValueError,'Please specify valid dir' 00037 00038 #from subprocess import Popen,PIPE 00039 #p1 = Popen(['ls',dir],stdout=PIPE) 00040 #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE) 00041 #files = [dir + "/" + item[:-1] for item in p2.stdout] 00042 #p2.stdout.close() 00043 files = os.listdir(dir) 00044 files = [ "%s/%s" % (dir,item) for item in files if item.find(type) != -1 ] 00045 00046 return files
def tools::loadCmsProcess | ( | psetPath | ) |
def tools::loadCmsProcessFile | ( | psetName | ) |
def tools::loadCrabCfg | ( | cfgName = None | ) |
def tools::loadCrabDefault | ( | crabCfg, | |
config | |||
) |
Definition at line 185 of file tools.py.
00186 : 00187 # CRAB section 00188 if not crabCfg.has_section('CRAB'): crabCfg.add_section('CRAB') 00189 crabCfg.set('CRAB','jobtype','cmssw') 00190 00191 if hasattr(config,'scheduler') and config.scheduler: crabCfg.set('CRAB','scheduler',config.scheduler) 00192 else: crabCfg.set('CRAB','scheduler','CAF') 00193 00194 if hasattr(config,'useserver') and config.useserver: crabCfg.set('CRAB','use_server',1) 00195 00196 # CMSSW section 00197 if not crabCfg.has_section('CMSSW'): crabCfg.add_section('CMSSW') 00198 if hasattr(config,'datasetpath') and config.datasetpath: crabCfg.set('CMSSW','datasetpath',config.datasetpath) 00199 else: crabCfg.set('CMSSW','datasetpath','/XXX/YYY/ZZZ') 00200 crabCfg.set('CMSSW','pset','pset.py') 00201 00202 # Splitting config 00203 crabCfg.remove_option('CMSSW','total_number_of_events') 00204 crabCfg.remove_option('CMSSW','events_per_job') 00205 crabCfg.remove_option('CMSSW','number_of_jobs') 00206 crabCfg.remove_option('CMSSW','total_number_of_lumis') 00207 crabCfg.remove_option('CMSSW','lumis_per_job') 00208 crabCfg.remove_option('CMSSW','lumi_mask') 00209 crabCfg.remove_option('CMSSW','split_by_run') 00210 00211 if hasattr(config,'runselection') and config.runselection: crabCfg.set('CMSSW','runselection',config.runselection) 00212 """ 00213 if hasattr(config,'totalnumberevents'): crabCfg.set('CMSSW','total_number_of_events',config.totalnumberevents) 00214 if hasattr(config,'eventsperjob'): crabCfg.set('CMSSW','events_per_job',config.eventsperjob) 00215 """ 00216 if hasattr(config,'splitByLumi') and config.splitByLumi: 00217 crabCfg.set('CMSSW','total_number_of_lumis',config.totalnumberlumis) 00218 crabCfg.set('CMSSW','lumis_per_job',config.lumisperjob) 00219 if hasattr(config,'lumimask') and config.lumimask: crabCfg.set('CMSSW','lumi_mask',config.lumimask) 00220 else: 00221 crabCfg.set('CMSSW','split_by_run',1) 00222 00223 # USER section 00224 if not crabCfg.has_section('USER'): crabCfg.add_section('USER') 00225 00226 # Stageout config 00227 if hasattr(config,'stageOutCAF') and config.stageOutCAF: 00228 crabCfg.set('USER','return_data',0) 00229 crabCfg.set('USER','copy_data',1) 00230 crabCfg.set('USER','storage_element','T2_CH_CAF') 00231 crabCfg.set('USER','user_remote_dir',config.userdircaf) 00232 crabCfg.set('USER','check_user_remote_dir',0) 00233 elif hasattr(config,'stageOutLocal') and config.stageOutLocal: 00234 crabCfg.set('USER','return_data',1) 00235 crabCfg.set('USER','copy_data',0) 00236 crabCfg.remove_option('USER','storage_element') 00237 crabCfg.remove_option('USER','user_remote_dir') 00238 crabCfg.remove_option('USER','check_user_remote_dir') 00239 00240 if hasattr(config,'email') and config.email: crabCfg.set('USER','eMail',config.email) 00241 crabCfg.set('USER','xml_report','crabReport.xml') 00242 00243 if hasattr(config,'runOnGrid') and config.runOnGrid: 00244 crabCfg.remove_section('CAF') 00245 else: 00246 if not crabCfg.has_section('CAF'): crabCfg.add_section('CAF') 00247 crabCfg.set('CAF','queue',config.queueAtCAF) 00248 00249 return crabCfg
def tools::parseInput | ( | inputFields, | |
requiredFields = () |
|||
) |
Definition at line 114 of file tools.py.
00115 : 00116 00117 class options: pass 00118 for item in sys.argv: 00119 option = item.split('=')[0] 00120 if option in inputFields: 00121 value = item.split('=')[1] 00122 if value in ('true','True','yes','Yes'): value = True 00123 elif value in ('false','False','no','No'): value = False 00124 00125 setattr(options,option,value) 00126 00127 for item in requiredFields: 00128 if not hasattr(options,item): 00129 raise RuntimeError,'Need to set "%s"' % item 00130 00131 return options
def tools::prependPaths | ( | process, | |
seqname | |||
) |
def tools::replaceTemplate | ( | template, | |
opts | |||
) |
def tools::setGridEnv | ( | cmssw_dir | ) |
def tools::writeCfg | ( | process, | |
dir, | |||
psetName | |||
) |
def tools::writeCfgPkl | ( | process, | |
dir, | |||
psetName | |||
) |
Definition at line 152 of file tools.py.
00153 : 00154 if not os.path.exists(dir): os.makedirs(dir) 00155 00156 pklFileName = psetName.split('.')[0] + '.pkl' 00157 pklFile = open(dir + '/' + pklFileName,"wb") 00158 myPickle = pickle.Pickler(pklFile) 00159 myPickle.dump(process) 00160 pklFile.close() 00161 00162 outFile = open(dir + '/' + psetName,"w") 00163 outFile.write("import FWCore.ParameterSet.Config as cms\n") 00164 outFile.write("import pickle\n") 00165 outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName) 00166 outFile.close() 00167
tuple tools::arch = os.getenv('SCRAM_ARCH', None) |
Definition at line 4 of file __init__.py.
tuple tools::localrt = os.getenv('LOCALRT', None) |
Definition at line 3 of file __init__.py.