5 |
|
from BlackWhiteListParser import BlackWhiteListParser |
6 |
|
import common |
7 |
|
import Scram |
8 |
+ |
from LFNBaseName import * |
9 |
|
|
10 |
|
import os, string, glob |
11 |
|
|
34 |
|
self.executable = '' |
35 |
|
self.executable_arch = self.scram.getArch() |
36 |
|
self.tgz_name = 'default.tgz' |
36 |
– |
self.additional_tgz_name = 'additional.tgz' |
37 |
|
self.scriptName = 'CMSSW.sh' |
38 |
|
self.pset = '' #scrip use case Da |
39 |
|
self.datasetPath = '' #scrip use case Da |
56 |
|
# msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch) |
57 |
|
# raise CrabException(msg) |
58 |
|
# |
59 |
< |
|
60 |
< |
self.setParam_('application', self.version) |
59 |
> |
|
60 |
|
|
61 |
|
### collect Data cards |
62 |
|
|
72 |
|
self.datasetPath = tmp |
73 |
|
self.selectNoInput = 0 |
74 |
|
|
76 |
– |
# ML monitoring |
77 |
– |
# split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM |
78 |
– |
if not self.datasetPath: |
79 |
– |
self.setParam_('dataset', 'None') |
80 |
– |
self.setParam_('owner', 'None') |
81 |
– |
else: |
82 |
– |
## SL what is supposed to fail here? |
83 |
– |
try: |
84 |
– |
datasetpath_split = self.datasetPath.split("/") |
85 |
– |
# standard style |
86 |
– |
self.setParam_('datasetFull', self.datasetPath) |
87 |
– |
self.setParam_('dataset', datasetpath_split[1]) |
88 |
– |
self.setParam_('owner', datasetpath_split[2]) |
89 |
– |
except: |
90 |
– |
self.setParam_('dataset', self.datasetPath) |
91 |
– |
self.setParam_('owner', self.datasetPath) |
92 |
– |
|
93 |
– |
self.setParam_('taskId', common._db.queryTask('name')) ## new BL--DS |
94 |
– |
|
75 |
|
self.dataTiers = [] |
76 |
|
|
77 |
|
## now the application |
78 |
|
self.executable = cfg_params.get('CMSSW.executable','cmsRun') |
99 |
– |
self.setParam_('exe', self.executable) |
79 |
|
log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable) |
80 |
|
|
81 |
|
if not cfg_params.has_key('CMSSW.pset'): |
112 |
|
# script_exe file as additional file in inputSandbox |
113 |
|
self.scriptExe = cfg_params.get('USER.script_exe',None) |
114 |
|
if self.scriptExe : |
115 |
< |
if not os.path.isfile(self.scriptExe): |
116 |
< |
msg ="ERROR. file "+self.scriptExe+" not found" |
117 |
< |
raise CrabException(msg) |
118 |
< |
self.additional_inbox_files.append(string.strip(self.scriptExe)) |
115 |
> |
if not os.path.isfile(self.scriptExe): |
116 |
> |
msg ="ERROR. file "+self.scriptExe+" not found" |
117 |
> |
raise CrabException(msg) |
118 |
> |
self.additional_inbox_files.append(string.strip(self.scriptExe)) |
119 |
|
|
120 |
|
#CarlosDaniele |
121 |
|
if self.datasetPath == None and self.pset == None and self.scriptExe == '' : |
122 |
< |
msg ="Error. script_exe not defined" |
123 |
< |
raise CrabException(msg) |
122 |
> |
msg ="Error. script_exe not defined" |
123 |
> |
raise CrabException(msg) |
124 |
|
|
125 |
|
## additional input files |
126 |
|
if cfg_params.has_key('USER.additional_input_files'): |
200 |
|
## remove |
201 |
|
self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None) |
202 |
|
if self.sourceSeed: |
203 |
< |
print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
204 |
< |
self.incrementSeeds.append('sourceSeed') |
203 |
> |
print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
204 |
> |
self.incrementSeeds.append('sourceSeed') |
205 |
|
|
206 |
|
self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None) |
207 |
|
if self.sourceSeedVtx: |
208 |
< |
print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
209 |
< |
self.incrementSeeds.append('VtxSmeared') |
208 |
> |
print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
209 |
> |
self.incrementSeeds.append('VtxSmeared') |
210 |
|
|
211 |
|
self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None) |
212 |
|
if self.sourceSeedG4: |
213 |
< |
print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
214 |
< |
self.incrementSeeds.append('g4SimHits') |
213 |
> |
print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
214 |
> |
self.incrementSeeds.append('g4SimHits') |
215 |
|
|
216 |
|
self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None) |
217 |
|
if self.sourceSeedMix: |
218 |
< |
print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
219 |
< |
self.incrementSeeds.append('mix') |
218 |
> |
print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds." |
219 |
> |
self.incrementSeeds.append('mix') |
220 |
|
|
221 |
|
self.firstRun = cfg_params.get('CMSSW.first_run',None) |
222 |
|
|
241 |
|
blockSites = self.DataDiscoveryAndLocation(cfg_params) |
242 |
|
#DBSDLS-end |
243 |
|
|
265 |
– |
self.tgzNameWithPath = self.getTarBall(self.executable) |
244 |
|
|
245 |
|
## Select Splitting |
246 |
|
if self.selectNoInput: |
262 |
|
except: |
263 |
|
msg='Error while manipuliating ParameterSet: exiting...' |
264 |
|
raise CrabException(msg) |
265 |
+ |
self.tgzNameWithPath = self.getTarBall(self.executable) |
266 |
|
|
267 |
|
def DataDiscoveryAndLocation(self, cfg_params): |
268 |
|
|
317 |
|
|
318 |
|
return sites |
319 |
|
|
320 |
< |
# to Be Removed DS -- BL |
320 |
> |
# to Be Removed DS -- BL |
321 |
|
# def setArgsList(self, argsList): |
322 |
|
# self.argsList = argsList |
323 |
|
|
371 |
|
else : |
372 |
|
totalNumberOfJobs = self.ncjobs |
373 |
|
|
395 |
– |
|
374 |
|
blocks = blockSites.keys() |
375 |
|
blockCount = 0 |
376 |
|
# Backup variable in case self.maxEvents counted events in a non-included block |
425 |
|
except KeyError: |
426 |
|
common.logger.message("File "+str(file)+" has unknown number of events: skipping") |
427 |
|
|
428 |
< |
|
428 |
> |
eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining) |
429 |
|
# if less events in file remain than eventsPerJobRequested |
430 |
< |
if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) : |
430 |
> |
if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested): |
431 |
|
# if last file in block |
432 |
|
if ( fileCount == numFilesInBlock-1 ) : |
433 |
|
# end job using last file, use remaining events in block |
511 |
|
for block in blocks: |
512 |
|
if block in jobsOfBlock.keys() : |
513 |
|
blockCounter += 1 |
514 |
< |
screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block))) |
514 |
> |
screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]), |
515 |
> |
','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block))) |
516 |
|
if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0: |
517 |
|
noSiteBlock.append( spanRanges(jobsOfBlock[block]) ) |
518 |
|
bloskNoSite.append( blockCounter ) |
651 |
|
#common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job])) |
652 |
|
common._db.updateJob_(listID,listField)## new BL--DS |
653 |
|
## Pay Attention Here....DS--BL |
654 |
< |
self.argsList = (len(jobParams[1])+1) |
654 |
> |
self.argsList = (len(jobParams[1])+1) |
655 |
|
|
656 |
|
return |
678 |
– |
# |
679 |
– |
# def getJobTypeArguments(self, nj, sched): |
680 |
– |
# result = '' |
681 |
– |
# jobs=[] |
682 |
– |
# jobs.append(nj) |
683 |
– |
# for i in common._db.queryJob('arguments',jobs):## BL--DS |
684 |
– |
# result=result+str(i)+" " |
685 |
– |
# return result |
657 |
|
|
658 |
|
def numberOfJobs(self): |
659 |
|
# Fabio |
689 |
|
|
690 |
|
## check if working area is release top |
691 |
|
if swReleaseTop == '' or swArea == swReleaseTop: |
692 |
+ |
common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop) |
693 |
|
return |
694 |
|
|
695 |
|
import tarfile |
732 |
|
|
733 |
|
## Now check if any data dir(s) is present |
734 |
|
swAreaLen=len(swArea) |
735 |
+ |
self.dataExist = False |
736 |
|
for root, dirs, files in os.walk(swArea): |
737 |
|
if "data" in dirs: |
738 |
+ |
self.dataExist=True |
739 |
|
common.logger.debug(5,"data "+root+"/data"+" to be tarred") |
740 |
|
tar.add(root+"/data",root[swAreaLen:]+"/data") |
741 |
+ |
|
742 |
+ |
### CMSSW ParameterSet |
743 |
+ |
if not self.pset is None: |
744 |
+ |
cfg_file = common.work_space.jobDir()+self.configFilename() |
745 |
+ |
tar.add(cfg_file,self.configFilename()) |
746 |
+ |
common.logger.debug(5,"File added to "+self.tgzNameWithPath+" : "+str(tar.getnames())) |
747 |
|
|
748 |
|
|
749 |
|
## Add ProdCommon dir to tar |
751 |
|
prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon' |
752 |
|
if os.path.isdir(prodcommonPath): |
753 |
|
tar.add(prodcommonPath,prodcommonDir) |
754 |
+ |
common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames())) |
755 |
|
|
756 |
+ |
##### ML stuff |
757 |
+ |
ML_file_list=['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py'] |
758 |
+ |
path=os.environ['CRABDIR'] + '/python/' |
759 |
+ |
for file in ML_file_list: |
760 |
+ |
tar.add(path+file,file) |
761 |
|
common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames())) |
762 |
+ |
|
763 |
+ |
##### Utils |
764 |
+ |
Utils_file_list=['parseCrabFjr.py','writeCfg.py', 'JobReportErrorCode.py'] |
765 |
+ |
for file in Utils_file_list: |
766 |
+ |
tar.add(path+file,file) |
767 |
+ |
common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames())) |
768 |
+ |
|
769 |
+ |
##### AdditionalFiles |
770 |
+ |
for file in self.additional_inbox_files: |
771 |
+ |
tar.add(file,string.split(file,'/')[-1]) |
772 |
+ |
common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames())) |
773 |
+ |
|
774 |
|
tar.close() |
775 |
|
except : |
776 |
|
raise CrabException('Could not create tar-ball') |
781 |
|
raise CrabException('Input sandbox size of ' + str(float(tarballinfo.st_size)/1024.0/1024.0) + ' MB is larger than the allowed ' + str(self.MaxTarBallSize) + ' MB input sandbox limit and not supported by the used GRID submission system. Please make sure that no unnecessary files are in all data directories in your local CMSSW project area as they are automatically packed into the input sandbox.') |
782 |
|
|
783 |
|
## create tar-ball with ML stuff |
786 |
– |
self.MLtgzfile = common.work_space.pathForTgz()+'share/MLfiles.tgz' |
787 |
– |
try: |
788 |
– |
tar = tarfile.open(self.MLtgzfile, "w:gz") |
789 |
– |
path=os.environ['CRABDIR'] + '/python/' |
790 |
– |
#for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py','writeCfg.py']: |
791 |
– |
### FEDE #### |
792 |
– |
for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py','writeCfg.py', 'JobReportErrorCode.py']: |
793 |
– |
############### |
794 |
– |
tar.add(path+file,file) |
795 |
– |
common.logger.debug(5,"Files added to "+self.MLtgzfile+" : "+str(tar.getnames())) |
796 |
– |
tar.close() |
797 |
– |
except : |
798 |
– |
raise CrabException('Could not create ML files tar-ball') |
799 |
– |
|
800 |
– |
return |
801 |
– |
|
802 |
– |
def additionalInputFileTgz(self): |
803 |
– |
""" |
804 |
– |
Put all additional files into a tar ball and return its name |
805 |
– |
""" |
806 |
– |
import tarfile |
807 |
– |
tarName= common.work_space.pathForTgz()+'share/'+self.additional_tgz_name |
808 |
– |
tar = tarfile.open(tarName, "w:gz") |
809 |
– |
for file in self.additional_inbox_files: |
810 |
– |
tar.add(file,string.split(file,'/')[-1]) |
811 |
– |
common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames())) |
812 |
– |
tar.close() |
813 |
– |
return tarName |
784 |
|
|
785 |
|
def wsSetupEnvironment(self, nj=0): |
786 |
|
""" |
795 |
|
txt += 'elif [ $middleware == OSG ]; then\n' |
796 |
|
txt += ' WORKING_DIR=`/bin/mktemp -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n' |
797 |
|
txt += ' if [ ! $? == 0 ] ;then\n' |
828 |
– |
#txt += ' echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n' |
829 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10016"\n' |
830 |
– |
#txt += ' echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n' |
831 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
832 |
– |
#txt += ' exit 1\n' |
798 |
|
txt += ' echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n' |
799 |
|
txt += ' job_exit_code=10016\n' |
800 |
|
txt += ' func_exit\n' |
817 |
|
txt += scram+' project CMSSW '+self.version+'\n' |
818 |
|
txt += 'status=$?\n' |
819 |
|
txt += 'if [ $status != 0 ] ; then\n' |
855 |
– |
#txt += ' echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n' |
856 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10034"\n' |
857 |
– |
#txt += ' echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n' |
858 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
820 |
|
txt += ' echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n' |
821 |
|
txt += ' job_exit_code=10034\n' |
861 |
– |
#txt += ' if [ $middleware == OSG ]; then \n' |
862 |
– |
#txt += ' cd $RUNTIME_AREA\n' |
863 |
– |
#txt += ' echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n' |
864 |
– |
#txt += ' echo ">>> Remove working directory: $WORKING_DIR"\n' |
865 |
– |
#txt += ' /bin/rm -rf $WORKING_DIR\n' |
866 |
– |
#txt += ' if [ -d $WORKING_DIR ] ;then\n' |
867 |
– |
#txt += ' echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n' |
868 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10018"\n' |
869 |
– |
#txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n' |
870 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
871 |
– |
#txt += ' echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n' |
872 |
– |
#txt += ' job_exit_code=10017\n' |
873 |
– |
#txt += ' fi\n' |
874 |
– |
#txt += ' fi \n' |
875 |
– |
#txt += ' exit 1 \n' |
822 |
|
txt += ' func_exit\n' |
823 |
|
txt += 'fi \n' |
824 |
|
txt += 'cd '+self.version+'\n' |
879 |
– |
########## FEDE FOR DBS2 ###################### |
825 |
|
txt += 'SOFTWARE_DIR=`pwd`\n' |
826 |
|
txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n' |
882 |
– |
############################################### |
883 |
– |
### needed grep for bug in scramv1 ### |
827 |
|
txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n' |
828 |
+ |
txt += 'if [ $? != 0 ] ; then\n' |
829 |
+ |
txt += ' echo "ERROR ==> Problem with the command: "\n' |
830 |
+ |
txt += ' echo "eval \`'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME \` at `hostname`"\n' |
831 |
+ |
txt += ' job_exit_code=10034\n' |
832 |
+ |
txt += ' func_exit\n' |
833 |
+ |
txt += 'fi \n' |
834 |
|
# Handle the arguments: |
835 |
|
txt += "\n" |
836 |
|
txt += "## number of arguments (first argument always jobnumber)\n" |
837 |
|
txt += "\n" |
889 |
– |
# txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n" |
838 |
|
txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n" |
839 |
|
txt += "then\n" |
892 |
– |
#txt += " echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n" |
893 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 50113"\n' |
894 |
– |
#txt += ' echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n' |
895 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
840 |
|
txt += " echo 'ERROR ==> Too few arguments' +$nargs+ \n" |
841 |
|
txt += ' job_exit_code=50113\n' |
898 |
– |
#txt += ' if [ $middleware == OSG ]; then \n' |
899 |
– |
#txt += ' cd $RUNTIME_AREA\n' |
900 |
– |
#txt += ' echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n' |
901 |
– |
#txt += ' echo ">>> Remove working directory: $WORKING_DIR"\n' |
902 |
– |
#txt += ' /bin/rm -rf $WORKING_DIR\n' |
903 |
– |
#txt += ' if [ -d $WORKING_DIR ] ;then\n' |
904 |
– |
#txt += ' echo "SET_EXE_ENV 50114 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n' |
905 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 50114"\n' |
906 |
– |
#txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n' |
907 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
908 |
– |
#txt += ' echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n' |
909 |
– |
#txt += ' job_exit_code=10017\n' |
910 |
– |
#txt += ' fi\n' |
911 |
– |
#txt += ' fi\n' |
912 |
– |
#txt += " exit 1\n" |
842 |
|
txt += " func_exit\n" |
843 |
|
txt += "fi\n" |
844 |
|
txt += "\n" |
861 |
|
txt += 'PrimaryDataset=null\n' |
862 |
|
txt += 'DataTier=null\n' |
863 |
|
txt += 'ApplicationFamily=MCDataTier\n' |
864 |
< |
if self.pset != None: |
864 |
> |
if self.pset != None: |
865 |
|
pset = os.path.basename(job.configFilename()) |
866 |
|
txt += '\n' |
867 |
|
txt += 'cp $RUNTIME_AREA/'+pset+' .\n' |
883 |
|
|
884 |
|
txt += 'mv -f '+pset+' pset.cfg\n' |
885 |
|
|
957 |
– |
if len(self.additional_inbox_files) > 0: |
958 |
– |
txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n' |
959 |
– |
txt += ' tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n' |
960 |
– |
txt += 'fi\n' |
961 |
– |
pass |
886 |
|
|
887 |
|
if self.pset != None: |
888 |
|
txt += '\n' |
894 |
|
txt += 'echo "PSETHASH = $PSETHASH" \n' |
895 |
|
txt += '\n' |
896 |
|
return txt |
897 |
< |
#### FEDE ##### |
897 |
> |
|
898 |
|
def wsUntarSoftware(self, nj=0): |
899 |
|
""" |
900 |
|
Put in the script the commands to build an executable |
906 |
|
if os.path.isfile(self.tgzNameWithPath): |
907 |
|
txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n' |
908 |
|
txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n' |
909 |
+ |
txt += 'ls -Al \n' |
910 |
|
txt += 'untar_status=$? \n' |
911 |
|
txt += 'if [ $untar_status -ne 0 ]; then \n' |
912 |
|
txt += ' echo "ERROR ==> Untarring .tgz file failed"\n' |
928 |
|
pass |
929 |
|
|
930 |
|
return txt |
931 |
< |
|
931 |
> |
|
932 |
|
def wsBuildExe(self, nj=0): |
933 |
|
""" |
934 |
|
Put in the script the commands to build an executable |
938 |
|
txt = '\n#Written by cms_cmssw::wsBuildExe\n' |
939 |
|
txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n' |
940 |
|
|
941 |
< |
txt += 'mv $RUNTIME_AREA/lib . \n' |
942 |
< |
txt += 'mv $RUNTIME_AREA/module . \n' |
943 |
< |
txt += 'mv $RUNTIME_AREA/ProdCommon . \n' |
944 |
< |
|
945 |
< |
|
946 |
< |
#if os.path.isfile(self.tgzNameWithPath): |
947 |
< |
# txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n' |
948 |
< |
# txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n' |
949 |
< |
# txt += 'untar_status=$? \n' |
1025 |
< |
# txt += 'if [ $untar_status -ne 0 ]; then \n' |
1026 |
< |
# txt += ' echo "ERROR ==> Untarring .tgz file failed"\n' |
1027 |
< |
# txt += ' job_exit_code=$untar_status\n' |
1028 |
< |
# txt += ' func_exit\n' |
1029 |
< |
# txt += 'else \n' |
1030 |
< |
# txt += ' echo "Successful untar" \n' |
1031 |
< |
# txt += 'fi \n' |
1032 |
< |
# txt += '\n' |
1033 |
< |
# txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n' |
941 |
> |
txt += 'rm -r lib/ module/ \n' |
942 |
> |
txt += 'mv $RUNTIME_AREA/lib/ . \n' |
943 |
> |
txt += 'mv $RUNTIME_AREA/module/ . \n' |
944 |
> |
if self.dataExist == True: txt += 'mv $RUNTIME_AREA/src/ . \n' |
945 |
> |
if len(self.additional_inbox_files)>0: |
946 |
> |
for file in self.additional_inbox_files: |
947 |
> |
txt += 'mv $RUNTIME_AREA/'+file+' . \n' |
948 |
> |
txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n' |
949 |
> |
|
950 |
|
txt += 'if [ -z "$PYTHONPATH" ]; then\n' |
951 |
|
txt += ' export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n' |
952 |
|
txt += 'else\n' |
956 |
|
txt += '\n' |
957 |
|
|
958 |
|
return txt |
1043 |
– |
############################################################################ |
959 |
|
|
960 |
|
def modifySteeringCards(self, nj): |
961 |
|
""" |
985 |
|
raise CrabException(msg) |
986 |
|
|
987 |
|
ex_args = "" |
988 |
< |
|
988 |
> |
# FUTURE: This tests the CMSSW version. Can remove code as versions deprecated |
989 |
|
# Framework job report |
990 |
|
if major >= 1 and minor >= 5 : |
1076 |
– |
#ex_args += " -j " + self.fjrFileName |
1077 |
– |
### FEDE it could be improved!!! #### |
991 |
|
ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml" |
1079 |
– |
####################################### |
992 |
|
# Type of cfg file |
993 |
|
if major >= 2 : |
994 |
< |
ex_args += " -p pset.pycfg" |
994 |
> |
ex_args += " -p pset.py" |
995 |
|
else: |
996 |
|
ex_args += " -p pset.cfg" |
997 |
|
return ex_args |
1006 |
|
## code |
1007 |
|
if os.path.isfile(self.tgzNameWithPath): |
1008 |
|
inp_box.append(self.tgzNameWithPath) |
1097 |
– |
if os.path.isfile(self.MLtgzfile): |
1098 |
– |
inp_box.append(self.MLtgzfile) |
1099 |
– |
## config |
1100 |
– |
if not self.pset is None: |
1101 |
– |
inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename()) |
1102 |
– |
## additional input files |
1103 |
– |
tgz = self.additionalInputFileTgz() |
1104 |
– |
inp_box.append(tgz) |
1105 |
– |
## executable |
1009 |
|
wrapper = os.path.basename(str(common._db.queryTask('scriptName'))) |
1010 |
|
inp_box.append(common.work_space.pathForTgz() +'job/'+ wrapper) |
1011 |
|
return inp_box |
1039 |
|
txt += 'ls \n' |
1040 |
|
txt += '\n' |
1041 |
|
|
1139 |
– |
#txt += 'output_exit_status=0\n' |
1140 |
– |
|
1141 |
– |
### FEDE ####### |
1142 |
– |
#for fileWithSuffix in (self.output_file_sandbox): |
1143 |
– |
# output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
1144 |
– |
# txt += '\n' |
1145 |
– |
# txt += '# check output file\n' |
1146 |
– |
# txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n' |
1147 |
– |
# txt += ' mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
1148 |
– |
# txt += ' ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n' |
1149 |
– |
# txt += 'else\n' |
1150 |
– |
# txt += ' echo "WARNING: Output file '+fileWithSuffix+' not found"\n' |
1151 |
– |
# txt += ' job_exit_code=60302\n' |
1152 |
– |
# if common.scheduler.name().upper() == 'CONDOR_G': |
1153 |
– |
# txt += ' if [ $middleware == OSG ]; then \n' |
1154 |
– |
# txt += ' echo "prepare dummy output file"\n' |
1155 |
– |
# txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n' |
1156 |
– |
# txt += ' fi \n' |
1157 |
– |
# txt += 'fi\n' |
1158 |
– |
|
1042 |
|
for fileWithSuffix in (self.output_file): |
1043 |
|
output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
1044 |
|
txt += '\n' |
1051 |
|
txt += ' mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
1052 |
|
txt += ' ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n' |
1053 |
|
txt += 'else\n' |
1171 |
– |
#txt += ' exit_status=60302\n' |
1172 |
– |
#txt += ' echo "ERROR: Output file '+fileWithSuffix+' not found"\n' |
1173 |
– |
#txt += ' echo "JOB_EXIT_STATUS = $exit_status"\n' |
1174 |
– |
#txt += ' output_exit_status=$exit_status\n' |
1054 |
|
txt += ' job_exit_code=60302\n' |
1055 |
|
txt += ' echo "WARNING: Output file '+fileWithSuffix+' not found"\n' |
1056 |
|
if common.scheduler.name().upper() == 'CONDOR_G': |
1131 |
|
txt += ' # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n' |
1132 |
|
txt += ' source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n' |
1133 |
|
txt += ' else\n' |
1255 |
– |
#txt += ' echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1256 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
1257 |
– |
#txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
1258 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1134 |
|
txt += ' echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1135 |
|
txt += ' job_exit_code=10020\n' |
1261 |
– |
#txt += ' cd $RUNTIME_AREA\n' |
1262 |
– |
#txt += ' echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n' |
1263 |
– |
#txt += ' echo ">>> Remove working directory: $WORKING_DIR"\n' |
1264 |
– |
#txt += ' /bin/rm -rf $WORKING_DIR\n' |
1265 |
– |
#txt += ' if [ -d $WORKING_DIR ] ;then\n' |
1266 |
– |
#txt += ' echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1267 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10017"\n' |
1268 |
– |
#txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n' |
1269 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1270 |
– |
#txt += ' echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1271 |
– |
#txt += ' job_exit_code=10017\n' |
1272 |
– |
#txt += ' fi\n' |
1273 |
– |
txt += '\n' |
1274 |
– |
#txt += ' exit 1\n' |
1136 |
|
txt += ' func_exit\n' |
1137 |
|
txt += ' fi\n' |
1138 |
|
txt += '\n' |
1153 |
|
txt += ' export SCRAM_ARCH='+self.executable_arch+'\n' |
1154 |
|
txt += ' export BUILD_ARCH='+self.executable_arch+'\n' |
1155 |
|
txt += ' if [ ! $VO_CMS_SW_DIR ] ;then\n' |
1295 |
– |
#txt += ' echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n' |
1296 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10031" \n' |
1297 |
– |
#txt += ' echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n' |
1298 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1299 |
– |
#txt += ' exit 1\n' |
1156 |
|
txt += ' echo "ERROR ==> CMS software dir not found on WN `hostname`"\n' |
1157 |
|
txt += ' job_exit_code=10031\n' |
1158 |
|
txt += ' func_exit\n' |
1159 |
|
txt += ' else\n' |
1160 |
|
txt += ' echo "Sourcing environment... "\n' |
1161 |
|
txt += ' if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n' |
1306 |
– |
#txt += ' echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n' |
1307 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10020"\n' |
1308 |
– |
#txt += ' echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n' |
1309 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1310 |
– |
#txt += ' exit 1\n' |
1162 |
|
txt += ' echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n' |
1163 |
|
txt += ' job_exit_code=10020\n' |
1164 |
|
txt += ' func_exit\n' |
1167 |
|
txt += ' source $VO_CMS_SW_DIR/cmsset_default.sh\n' |
1168 |
|
txt += ' result=$?\n' |
1169 |
|
txt += ' if [ $result -ne 0 ]; then\n' |
1319 |
– |
#txt += ' echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n' |
1320 |
– |
#txt += ' echo "JOB_EXIT_STATUS = 10032"\n' |
1321 |
– |
#txt += ' echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n' |
1322 |
– |
#txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1323 |
– |
#txt += ' exit 1\n' |
1170 |
|
txt += ' echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n' |
1171 |
|
txt += ' job_exit_code=10032\n' |
1172 |
|
txt += ' func_exit\n' |
1183 |
|
""" |
1184 |
|
|
1185 |
|
txt = '\n#Written by cms_cmssw::modifyReport\n' |
1186 |
< |
try: |
1341 |
< |
publish_data = int(self.cfg_params['USER.publish_data']) |
1342 |
< |
except KeyError: |
1343 |
< |
publish_data = 0 |
1186 |
> |
publish_data = int(self.cfg_params.get('USER.publish_data',0)) |
1187 |
|
if (publish_data == 1): |
1345 |
– |
|
1346 |
– |
txt += 'if [ $copy_exit_status -eq 0 ]; then\n' |
1347 |
– |
txt += ' echo ">>> Modify Job Report:" \n' |
1348 |
– |
txt += ' chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n' |
1349 |
– |
#txt += ' if [ -z "$SE" ]; then\n' |
1350 |
– |
#txt += ' SE="" \n' |
1351 |
– |
#txt += ' fi \n' |
1352 |
– |
#txt += ' if [ -z "$SE_PATH" ]; then\n' |
1353 |
– |
#txt += ' SE_PATH="" \n' |
1354 |
– |
#txt += ' fi \n' |
1355 |
– |
txt += ' echo "SE = $SE"\n' |
1356 |
– |
txt += ' echo "SE_PATH = $SE_PATH"\n' |
1357 |
– |
|
1188 |
|
processedDataset = self.cfg_params['USER.publish_data_name'] |
1189 |
< |
txt += ' ProcessedDataset='+processedDataset+'\n' |
1360 |
< |
#txt += ' if [ "$SE_PATH" == "" ]; then\n' |
1361 |
< |
#txt += ' FOR_LFN=/copy_problems/ \n' |
1362 |
< |
#txt += ' else \n' |
1363 |
< |
#txt += ' tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n' |
1364 |
< |
#txt += ' FOR_LFN=/store$tmp \n' |
1365 |
< |
#txt += ' fi \n' |
1366 |
< |
txt += ' tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n' |
1367 |
< |
txt += ' FOR_LFN=/store$tmp \n' |
1368 |
< |
txt += ' echo "ProcessedDataset = $ProcessedDataset"\n' |
1369 |
< |
txt += ' echo "FOR_LFN = $FOR_LFN" \n' |
1370 |
< |
txt += ' echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n' |
1371 |
< |
#txt += ' echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1372 |
< |
#txt += ' $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1373 |
< |
### FEDE #### |
1374 |
< |
txt += ' echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1375 |
< |
txt += ' $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1376 |
< |
#################################### |
1377 |
< |
txt += ' modifyReport_result=$?\n' |
1378 |
< |
txt += ' if [ $modifyReport_result -ne 0 ]; then\n' |
1379 |
< |
txt += ' modifyReport_result=70500\n' |
1380 |
< |
txt += ' job_exit_code=$modifyReport_result\n' |
1381 |
< |
txt += ' echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n' |
1382 |
< |
txt += ' echo "WARNING: Problem with ModifyJobReport"\n' |
1383 |
< |
txt += ' else\n' |
1384 |
< |
### FEDE ##### |
1385 |
< |
#txt += ' mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n' |
1386 |
< |
####################### |
1387 |
< |
txt += ' mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n' |
1388 |
< |
txt += ' fi\n' |
1389 |
< |
txt += 'fi\n' |
1390 |
< |
return txt |
1189 |
> |
LFNBaseName = LFNBase(processedDataset) |
1190 |
|
|
1191 |
< |
def cleanEnv(self): |
1192 |
< |
txt = '\n#Written by cms_cmssw::cleanEnv\n' |
1193 |
< |
txt += 'if [ $middleware == OSG ]; then\n' |
1194 |
< |
txt += ' cd $RUNTIME_AREA\n' |
1195 |
< |
txt += ' echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n' |
1196 |
< |
txt += ' echo ">>> Remove working directory: $WORKING_DIR"\n' |
1197 |
< |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
1198 |
< |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
1199 |
< |
txt += ' echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n' |
1200 |
< |
txt += ' job_exit_code=10017\n' |
1201 |
< |
txt += ' func_exit\n' |
1202 |
< |
txt += ' fi\n' |
1203 |
< |
txt += 'fi\n' |
1204 |
< |
txt += '\n' |
1191 |
> |
txt += 'if [ $copy_exit_status -eq 0 ]; then\n' |
1192 |
> |
txt += ' FOR_LFN=%s_${PSETHASH}/\n'%(LFNBaseName) |
1193 |
> |
txt += 'else\n' |
1194 |
> |
txt += ' FOR_LFN=/copy_problems/ \n' |
1195 |
> |
txt += ' SE=""\n' |
1196 |
> |
txt += ' SE_PATH=""\n' |
1197 |
> |
txt += 'fi\n' |
1198 |
> |
|
1199 |
> |
txt += 'echo ">>> Modify Job Report:" \n' |
1200 |
> |
txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n' |
1201 |
> |
txt += 'ProcessedDataset='+processedDataset+'\n' |
1202 |
> |
txt += 'echo "ProcessedDataset = $ProcessedDataset"\n' |
1203 |
> |
txt += 'echo "SE = $SE"\n' |
1204 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
1205 |
> |
txt += 'echo "FOR_LFN = $FOR_LFN" \n' |
1206 |
> |
txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n' |
1207 |
> |
txt += 'echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1208 |
> |
txt += '$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1209 |
> |
txt += 'modifyReport_result=$?\n' |
1210 |
> |
txt += 'if [ $modifyReport_result -ne 0 ]; then\n' |
1211 |
> |
txt += ' modifyReport_result=70500\n' |
1212 |
> |
txt += ' job_exit_code=$modifyReport_result\n' |
1213 |
> |
txt += ' echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n' |
1214 |
> |
txt += ' echo "WARNING: Problem with ModifyJobReport"\n' |
1215 |
> |
txt += 'else\n' |
1216 |
> |
txt += ' mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n' |
1217 |
> |
txt += 'fi\n' |
1218 |
|
return txt |
1219 |
|
|
1220 |
|
def setParam_(self, param, value): |
1239 |
|
txt = '' |
1240 |
|
txt += 'echo ">>> list of expected files on output sandbox"\n' |
1241 |
|
listOutFiles = [] |
1242 |
< |
stdout = 'CMSSW_$NJob.stdout' |
1242 |
> |
stdout = 'CMSSW_$NJob.stdout' |
1243 |
|
stderr = 'CMSSW_$NJob.stderr' |
1244 |
|
if (self.return_data == 1): |
1245 |
|
for file in (self.output_file+self.output_file_sandbox): |
1254 |
|
txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n' |
1255 |
|
txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n' |
1256 |
|
txt += 'export filesToCheck\n' |
1257 |
< |
return txt |
1257 |
> |
return txt |