2 |
|
from crab_logger import Logger |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
+ |
from BlackWhiteListParser import BlackWhiteListParser |
6 |
|
import common |
7 |
|
import Scram |
8 |
|
|
9 |
< |
import os, string, re, shutil, glob |
9 |
> |
import os, string, glob |
10 |
|
|
11 |
|
class Cmssw(JobType): |
12 |
|
def __init__(self, cfg_params, ncjobs): |
13 |
|
JobType.__init__(self, 'CMSSW') |
14 |
|
common.logger.debug(3,'CMSSW::__init__') |
15 |
|
|
15 |
– |
# Marco. |
16 |
|
self._params = {} |
17 |
|
self.cfg_params = cfg_params |
18 |
|
|
19 |
+ |
# init BlackWhiteListParser |
20 |
+ |
self.blackWhiteListParser = BlackWhiteListParser(cfg_params) |
21 |
+ |
|
22 |
|
try: |
23 |
|
self.MaxTarBallSize = float(self.cfg_params['EDG.maxtarballsize']) |
24 |
|
except KeyError: |
35 |
|
self.executable = '' |
36 |
|
self.executable_arch = self.scram.getArch() |
37 |
|
self.tgz_name = 'default.tgz' |
38 |
+ |
self.additional_tgz_name = 'additional.tgz' |
39 |
|
self.scriptName = 'CMSSW.sh' |
40 |
|
self.pset = '' #scrip use case Da |
41 |
|
self.datasetPath = '' #scrip use case Da |
44 |
|
self.fjrFileName = 'crab_fjr.xml' |
45 |
|
|
46 |
|
self.version = self.scram.getSWVersion() |
47 |
+ |
|
48 |
+ |
# |
49 |
+ |
# Try to block creation in case of arch/version mismatch |
50 |
+ |
# |
51 |
+ |
|
52 |
+ |
a = string.split(self.version, "_") |
53 |
+ |
|
54 |
+ |
if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0): |
55 |
+ |
msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch) |
56 |
+ |
raise CrabException(msg) |
57 |
+ |
if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0): |
58 |
+ |
msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch) |
59 |
+ |
raise CrabException(msg) |
60 |
+ |
|
61 |
|
common.taskDB.setDict('codeVersion',self.version) |
62 |
|
self.setParam_('application', self.version) |
63 |
|
|
191 |
|
if not os.path.exists(file): |
192 |
|
raise CrabException("Additional input file not found: "+file) |
193 |
|
pass |
194 |
< |
fname = string.split(file, '/')[-1] |
195 |
< |
storedFile = common.work_space.pathForTgz()+'share/'+fname |
196 |
< |
shutil.copyfile(file, storedFile) |
197 |
< |
self.additional_inbox_files.append(string.strip(storedFile)) |
194 |
> |
# fname = string.split(file, '/')[-1] |
195 |
> |
# storedFile = common.work_space.pathForTgz()+'share/'+fname |
196 |
> |
# shutil.copyfile(file, storedFile) |
197 |
> |
self.additional_inbox_files.append(string.strip(file)) |
198 |
|
pass |
199 |
|
pass |
200 |
|
common.logger.debug(5,"Additional input files: "+str(self.additional_inbox_files)) |
271 |
|
self.firstRun = None |
272 |
|
common.logger.debug(5,"No first run given") |
273 |
|
if self.pset != None: #CarlosDaniele |
274 |
< |
import PsetManipulator |
275 |
< |
PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset |
274 |
> |
ver = string.split(self.version,"_") |
275 |
> |
if (int(ver[1])>=1 and int(ver[2])>=5): |
276 |
> |
import PsetManipulator150 as pp |
277 |
> |
else: |
278 |
> |
import PsetManipulator as pp |
279 |
> |
PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset |
280 |
|
|
281 |
|
#DBSDLS-start |
282 |
|
## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code |
462 |
|
while ( (eventsRemaining > 0) and (blockCount < numBlocksInDataset) and (jobCount < totalNumberOfJobs)): |
463 |
|
block = blocks[blockCount] |
464 |
|
blockCount += 1 |
465 |
+ |
if block not in jobsOfBlock.keys() : |
466 |
+ |
jobsOfBlock[block] = [] |
467 |
|
|
468 |
|
if self.eventsbyblock.has_key(block) : |
469 |
|
numEventsInBlock = self.eventsbyblock[block] |
514 |
|
self.jobDestination.append(blockSites[block]) |
515 |
|
common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount])) |
516 |
|
# fill jobs of block dictionary |
517 |
< |
if block in jobsOfBlock.keys() : |
494 |
< |
jobsOfBlock[block].append(jobCount+1) |
495 |
< |
else: |
496 |
< |
jobsOfBlock[block] = [jobCount+1] |
517 |
> |
jobsOfBlock[block].append(jobCount+1) |
518 |
|
# reset counter |
519 |
|
jobCount = jobCount + 1 |
520 |
|
totalEventCount = totalEventCount + filesEventCount - jobSkipEventCount |
538 |
|
common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.") |
539 |
|
self.jobDestination.append(blockSites[block]) |
540 |
|
common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount])) |
541 |
< |
if block in jobsOfBlock.keys() : |
521 |
< |
jobsOfBlock[block].append(jobCount+1) |
522 |
< |
else: |
523 |
< |
jobsOfBlock[block] = [jobCount+1] |
541 |
> |
jobsOfBlock[block].append(jobCount+1) |
542 |
|
# reset counter |
543 |
|
jobCount = jobCount + 1 |
544 |
|
totalEventCount = totalEventCount + eventsPerJobRequested |
559 |
|
common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.") |
560 |
|
self.jobDestination.append(blockSites[block]) |
561 |
|
common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount])) |
562 |
< |
if block in jobsOfBlock.keys() : |
545 |
< |
jobsOfBlock[block].append(jobCount+1) |
546 |
< |
else: |
547 |
< |
jobsOfBlock[block] = [jobCount+1] |
562 |
> |
jobsOfBlock[block].append(jobCount+1) |
563 |
|
# increase counter |
564 |
|
jobCount = jobCount + 1 |
565 |
|
totalEventCount = totalEventCount + eventsPerJobRequested |
583 |
|
screenOutput = "List of jobs and available destination sites:\n\n" |
584 |
|
|
585 |
|
blockCounter = 0 |
586 |
< |
for block in jobsOfBlock.keys(): |
587 |
< |
blockCounter += 1 |
588 |
< |
screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(blockSites[block])) |
586 |
> |
for block in blocks: |
587 |
> |
if block in jobsOfBlock.keys() : |
588 |
> |
blockCounter += 1 |
589 |
> |
screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block))) |
590 |
|
|
591 |
|
common.logger.message(screenOutput) |
592 |
|
|
833 |
|
|
834 |
|
return |
835 |
|
|
836 |
+ |
def additionalInputFileTgz(self): |
837 |
+ |
""" |
838 |
+ |
Put all additional files into a tar ball and return its name |
839 |
+ |
""" |
840 |
+ |
import tarfile |
841 |
+ |
tarName= common.work_space.pathForTgz()+'share/'+self.additional_tgz_name |
842 |
+ |
tar = tarfile.open(tarName, "w:gz") |
843 |
+ |
for file in self.additional_inbox_files: |
844 |
+ |
tar.add(file,string.split(file,'/')[-1]) |
845 |
+ |
common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames())) |
846 |
+ |
tar.close() |
847 |
+ |
return tarName |
848 |
+ |
|
849 |
|
def wsSetupEnvironment(self, nj): |
850 |
|
""" |
851 |
|
Returns part of a job script which prepares |
857 |
|
## OLI_Daniele at this level middleware already known |
858 |
|
|
859 |
|
txt += 'if [ $middleware == LCG ]; then \n' |
860 |
+ |
txt += ' echo "### First set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n' |
861 |
+ |
txt += ' export SCRAM_ARCH='+self.executable_arch+'\n' |
862 |
+ |
txt += ' export BUILD_ARCH='+self.executable_arch+'\n' |
863 |
|
txt += self.wsSetupCMSLCGEnvironment_() |
864 |
|
txt += 'elif [ $middleware == OSG ]; then\n' |
865 |
|
txt += ' WORKING_DIR=`/bin/mktemp -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n' |
878 |
|
txt += ' echo "Change to working directory: $WORKING_DIR"\n' |
879 |
|
txt += ' cd $WORKING_DIR\n' |
880 |
|
txt += self.wsSetupCMSOSGEnvironment_() |
881 |
+ |
txt += ' echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n' |
882 |
+ |
txt += ' export SCRAM_ARCH='+self.executable_arch+'\n' |
883 |
|
txt += 'fi\n' |
884 |
|
|
885 |
|
# Prepare JobType-specific part |
886 |
|
scram = self.scram.commandName() |
887 |
|
txt += '\n\n' |
888 |
|
txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n' |
855 |
– |
txt += 'echo "Setting SCRAM_ARCH='+self.executable_arch+'"\n' |
856 |
– |
txt += 'export SCRAM_ARCH='+self.executable_arch+'\n' |
889 |
|
txt += scram+' project CMSSW '+self.version+'\n' |
890 |
|
txt += 'status=$?\n' |
891 |
|
txt += 'if [ $status != 0 ] ; then\n' |
902 |
|
txt += ' cd $RUNTIME_AREA\n' |
903 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
904 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
905 |
< |
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' |
906 |
< |
txt += ' echo "JOB_EXIT_STATUS = 10018"\n' |
907 |
< |
txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n' |
908 |
< |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
905 |
> |
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' |
906 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10018"\n' |
907 |
> |
txt += ' echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n' |
908 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
909 |
|
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
910 |
|
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
911 |
|
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
915 |
|
txt += 'fi \n' |
916 |
|
txt += 'echo "CMSSW_VERSION = '+self.version+'"\n' |
917 |
|
txt += 'cd '+self.version+'\n' |
918 |
+ |
########## FEDE FOR DBS2 ###################### |
919 |
+ |
txt += 'SOFTWARE_DIR=`pwd`\n' |
920 |
+ |
txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n' |
921 |
+ |
############################################### |
922 |
|
### needed grep for bug in scramv1 ### |
923 |
|
txt += scram+' runtime -sh\n' |
924 |
|
txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n' |
944 |
|
txt += ' cd $RUNTIME_AREA\n' |
945 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
946 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
947 |
< |
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' |
948 |
< |
txt += ' echo "JOB_EXIT_STATUS = 50114"\n' |
949 |
< |
txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n' |
950 |
< |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
947 |
> |
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' |
948 |
> |
txt += ' echo "JOB_EXIT_STATUS = 50114"\n' |
949 |
> |
txt += ' echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n' |
950 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
951 |
|
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
952 |
|
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
953 |
|
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
968 |
|
|
969 |
|
txt += 'PrimaryDataset='+datasetpath_split[1]+'\n' |
970 |
|
txt += 'DataTier='+datasetpath_split[2]+'\n' |
971 |
< |
txt += 'ProcessedDataset='+datasetpath_split[3]+'\n' |
972 |
< |
txt += 'ApplicationFamily=Online\n' |
971 |
> |
#txt += 'ProcessedDataset='+datasetpath_split[3]+'\n' |
972 |
> |
txt += 'ApplicationFamily=cmsRun\n' |
973 |
|
|
974 |
|
else: |
975 |
|
txt += 'DatasetPath=MCDataTier\n' |
976 |
|
txt += 'PrimaryDataset=null\n' |
977 |
|
txt += 'DataTier=null\n' |
978 |
< |
txt += 'ProcessedDataset=null\n' |
978 |
> |
#txt += 'ProcessedDataset=null\n' |
979 |
|
txt += 'ApplicationFamily=MCDataTier\n' |
944 |
– |
################## |
980 |
|
if self.pset != None: #CarlosDaniele |
981 |
|
pset = os.path.basename(job.configFilename()) |
982 |
|
txt += '\n' |
983 |
+ |
txt += 'cp $RUNTIME_AREA/'+pset+' .\n' |
984 |
|
if (self.datasetPath): # standard job |
985 |
|
#txt += 'InputFiles=$2\n' |
986 |
|
txt += 'InputFiles=${args[1]}\n' |
1025 |
|
txt += 'mv -f '+pset+' pset.cfg\n' |
1026 |
|
|
1027 |
|
if len(self.additional_inbox_files) > 0: |
1028 |
< |
for file in self.additional_inbox_files: |
1029 |
< |
relFile = file.split("/")[-1] |
1030 |
< |
txt += 'if [ -e $RUNTIME_AREA/'+relFile+' ] ; then\n' |
995 |
< |
txt += ' cp $RUNTIME_AREA/'+relFile+' .\n' |
996 |
< |
txt += ' chmod +x '+relFile+'\n' |
997 |
< |
txt += 'fi\n' |
1028 |
> |
txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n' |
1029 |
> |
txt += ' tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n' |
1030 |
> |
txt += 'fi\n' |
1031 |
|
pass |
1032 |
|
|
1033 |
|
if self.pset != None: #CarlosDaniele |
1039 |
|
txt += 'echo "****** end pset.cfg ********"\n' |
1040 |
|
txt += '\n' |
1041 |
|
### FEDE FOR DBS OUTPUT PUBLICATION |
1042 |
< |
txt += 'PSETHASH=`EdmConfigHash < pset.cfg`' |
1042 |
> |
txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n' |
1043 |
> |
txt += 'echo "PSETHASH = $PSETHASH" \n' |
1044 |
|
############## |
1045 |
|
txt += '\n' |
1046 |
|
# txt += 'echo "***** cat pset1.cfg *********"\n' |
1087 |
|
txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n' |
1088 |
|
txt += 'if [ -z "$PYTHONPATH" ]; then\n' |
1089 |
|
#### FEDE FOR DBS OUTPUT PUBLICATION |
1090 |
< |
txt += ' export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n' |
1090 |
> |
txt += ' export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n' |
1091 |
> |
#txt += ' export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n' |
1092 |
|
#txt += ' export PYTHONPATH=ProdAgentApi\n' |
1093 |
|
txt += 'else\n' |
1094 |
< |
txt += ' export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n' |
1094 |
> |
txt += ' export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n' |
1095 |
> |
#txt += ' export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n' |
1096 |
|
#txt += ' export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n' |
1097 |
|
txt += 'echo "PYTHONPATH=$PYTHONPATH"\n' |
1098 |
|
################### |
1118 |
|
def executableArgs(self): |
1119 |
|
if self.scriptExe:#CarlosDaniele |
1120 |
|
return self.scriptExe + " $NJob" |
1121 |
< |
else: |
1122 |
< |
return " -p pset.cfg" |
1121 |
> |
else: |
1122 |
> |
# if >= CMSSW_1_5_X, add -e |
1123 |
> |
version_array = self.scram.getSWVersion().split('_') |
1124 |
> |
major = 0 |
1125 |
> |
minor = 0 |
1126 |
> |
try: |
1127 |
> |
major = int(version_array[1]) |
1128 |
> |
minor = int(version_array[2]) |
1129 |
> |
except: |
1130 |
> |
msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!" |
1131 |
> |
raise CrabException(msg) |
1132 |
> |
if major >= 1 and minor >= 5 : |
1133 |
> |
return " -e -p pset.cfg" |
1134 |
> |
else: |
1135 |
> |
return " -p pset.cfg" |
1136 |
|
|
1137 |
|
def inputSandbox(self, nj): |
1138 |
|
""" |
1150 |
|
if not self.pset is None: |
1151 |
|
inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename()) |
1152 |
|
## additional input files |
1153 |
< |
for file in self.additional_inbox_files: |
1154 |
< |
inp_box.append(file) |
1153 |
> |
tgz = self.additionalInputFileTgz() |
1154 |
> |
inp_box.append(tgz) |
1155 |
|
return inp_box |
1156 |
|
|
1157 |
|
def outputSandbox(self, nj): |
1185 |
|
output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
1186 |
|
txt += '\n' |
1187 |
|
txt += '# check output file\n' |
1188 |
< |
txt += 'ls '+fileWithSuffix+'\n' |
1189 |
< |
txt += 'ls_result=$?\n' |
1190 |
< |
txt += 'if [ $ls_result -ne 0 ] ; then\n' |
1191 |
< |
txt += ' exit_status=60302\n' |
1192 |
< |
txt += ' echo "ERROR: Problem with output file"\n' |
1188 |
> |
# txt += 'ls '+fileWithSuffix+'\n' |
1189 |
> |
# txt += 'ls_result=$?\n' |
1190 |
> |
txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n' |
1191 |
> |
###### FEDE FOR OUTPUT DATA PUBLICATION ######## |
1192 |
> |
txt += ' mv '+fileWithSuffix+' $RUNTIME_AREA\n' |
1193 |
> |
txt += ' cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
1194 |
> |
################################################ |
1195 |
> |
txt += 'else\n' |
1196 |
> |
txt += ' exit_status=60302\n' |
1197 |
> |
txt += ' echo "ERROR: Problem with output file '+fileWithSuffix+'"\n' |
1198 |
> |
############# FEDE ADDED CHECK FOR OUTPUT ############# |
1199 |
> |
if fileWithSuffix in self.output_file: |
1200 |
> |
txt += ' echo "JOB_EXIT_STATUS = $exit_status"\n' |
1201 |
> |
txt += ' exit $exit_status\n' |
1202 |
> |
####################################################### |
1203 |
|
if common.scheduler.boss_scheduler_name == 'condor_g': |
1204 |
|
txt += ' if [ $middleware == OSG ]; then \n' |
1205 |
|
txt += ' echo "prepare dummy output file"\n' |
1206 |
|
txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n' |
1207 |
|
txt += ' fi \n' |
1149 |
– |
txt += 'else\n' |
1150 |
– |
### FEDE FOR DBS OUTPUT PUBLICATION |
1151 |
– |
txt += ' mv '+fileWithSuffix+' $RUNTIME_AREA\n' |
1152 |
– |
txt += ' cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n' |
1153 |
– |
################################# |
1208 |
|
txt += 'fi\n' |
1209 |
< |
|
1209 |
> |
file_list = [] |
1210 |
> |
for fileWithSuffix in (self.output_file): |
1211 |
> |
file_list.append(self.numberFile_(fileWithSuffix, '$NJob')) |
1212 |
> |
|
1213 |
> |
txt += 'file_list="'+string.join(file_list,' ')+'"\n' |
1214 |
|
txt += 'cd $RUNTIME_AREA\n' |
1157 |
– |
### OLI_DANIELE |
1158 |
– |
txt += 'if [ $middleware == OSG ]; then\n' |
1159 |
– |
txt += ' cd $RUNTIME_AREA\n' |
1160 |
– |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
1161 |
– |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
1162 |
– |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
1163 |
– |
txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n' |
1164 |
– |
txt += ' echo "JOB_EXIT_STATUS = 60999"\n' |
1165 |
– |
txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n' |
1166 |
– |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1167 |
– |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1168 |
– |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1169 |
– |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1170 |
– |
txt += ' fi\n' |
1171 |
– |
txt += 'fi\n' |
1172 |
– |
txt += '\n' |
1173 |
– |
|
1174 |
– |
file_list = '' |
1175 |
– |
## Add to filelist only files to be possibly copied to SE |
1176 |
– |
for fileWithSuffix in self.output_file: |
1177 |
– |
output_file_num = self.numberFile_(fileWithSuffix, '$NJob') |
1178 |
– |
file_list=file_list+output_file_num+' ' |
1179 |
– |
file_list=file_list[:-1] |
1180 |
– |
txt += 'file_list="'+file_list+'"\n' |
1181 |
– |
|
1215 |
|
return txt |
1216 |
|
|
1217 |
|
def numberFile_(self, file, txt): |
1241 |
|
req='Member("VO-cms-' + \ |
1242 |
|
self.version + \ |
1243 |
|
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
1244 |
< |
# if self.executable_arch: |
1245 |
< |
# req='Member("VO-cms-' + \ |
1246 |
< |
# self.executable_arch + \ |
1247 |
< |
# '", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
1244 |
> |
## SL add requirement for OS version only if SL4 |
1245 |
> |
#reSL4 = re.compile( r'slc4' ) |
1246 |
> |
if self.executable_arch: # and reSL4.search(self.executable_arch): |
1247 |
> |
req+=' && Member("VO-cms-' + \ |
1248 |
> |
self.executable_arch + \ |
1249 |
> |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
1250 |
|
|
1251 |
|
req = req + ' && (other.GlueHostNetworkAdapterOutboundIP)' |
1252 |
|
|
1286 |
|
txt += ' cd $RUNTIME_AREA\n' |
1287 |
|
txt += ' /bin/rm -rf $WORKING_DIR\n' |
1288 |
|
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
1289 |
< |
txt += ' echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1290 |
< |
txt += ' echo "JOB_EXIT_STATUS = 10017"\n' |
1291 |
< |
txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n' |
1292 |
< |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1293 |
< |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1294 |
< |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1295 |
< |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1289 |
> |
txt += ' echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n' |
1290 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10017"\n' |
1291 |
> |
txt += ' echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n' |
1292 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1293 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1294 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1295 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1296 |
|
txt += ' fi\n' |
1297 |
|
txt += '\n' |
1298 |
|
txt += ' exit 1\n' |
1356 |
|
""" |
1357 |
|
insert the part of the script that modifies the FrameworkJob Report |
1358 |
|
""" |
1359 |
< |
|
1359 |
> |
|
1360 |
|
txt = '' |
1361 |
|
txt += 'echo "Modify Job Report" \n' |
1362 |
< |
txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n' |
1362 |
> |
#txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n' |
1363 |
> |
################ FEDE FOR DBS2 ############################################# |
1364 |
> |
txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n' |
1365 |
> |
############################################################################# |
1366 |
> |
try: |
1367 |
> |
publish_data = int(self.cfg_params['USER.publish_data']) |
1368 |
> |
except KeyError: |
1369 |
> |
publish_data = 0 |
1370 |
> |
|
1371 |
|
txt += 'if [ -z "$SE" ]; then\n' |
1372 |
|
txt += ' SE="" \n' |
1373 |
|
txt += 'fi \n' |
1376 |
|
txt += 'fi \n' |
1377 |
|
txt += 'echo "SE = $SE"\n' |
1378 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
1379 |
< |
txt += 'FOR_LFN=$DatasetPath/$MonitorID\n' |
1380 |
< |
txt += 'echo "FOR_LFN = $FOR_LFN"\n' |
1381 |
< |
txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n' |
1382 |
< |
txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1383 |
< |
txt += '$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1384 |
< |
txt += 'modifyReport_result=$?\n' |
1385 |
< |
txt += 'echo modifyReport_result = $modifyReport_result\n' |
1386 |
< |
txt += 'if [ $modify_result -ne 0 ]; then\n' |
1387 |
< |
txt += ' exit_status=1\n' |
1388 |
< |
txt += ' echo "ERROR: Problem with ModifyJobReport"\n' |
1389 |
< |
txt += 'else\n' |
1390 |
< |
txt += ' mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n' |
1379 |
> |
|
1380 |
> |
if (publish_data == 1): |
1381 |
> |
#processedDataset = self.cfg_params['USER.processed_datasetname'] |
1382 |
> |
processedDataset = self.cfg_params['USER.publish_data_name'] |
1383 |
> |
txt += 'ProcessedDataset='+processedDataset+'\n' |
1384 |
> |
#### LFN=/store/user/<user>/processedDataset_PSETHASH |
1385 |
> |
txt += 'if [ "$SE_PATH" == "" ]; then\n' |
1386 |
> |
#### FEDE: added slash in LFN ############## |
1387 |
> |
txt += ' FOR_LFN=/copy_problems/ \n' |
1388 |
> |
txt += 'else \n' |
1389 |
> |
txt += ' tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n' |
1390 |
> |
##### FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ######## |
1391 |
> |
txt += ' FOR_LFN=/store$tmp \n' |
1392 |
> |
txt += 'fi \n' |
1393 |
> |
txt += 'echo "ProcessedDataset = $ProcessedDataset"\n' |
1394 |
> |
txt += 'echo "FOR_LFN = $FOR_LFN" \n' |
1395 |
> |
txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n' |
1396 |
> |
#txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1397 |
> |
txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n' |
1398 |
> |
txt += '$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1399 |
> |
#txt += '$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n' |
1400 |
> |
|
1401 |
> |
txt += 'modifyReport_result=$?\n' |
1402 |
> |
txt += 'echo modifyReport_result = $modifyReport_result\n' |
1403 |
> |
txt += 'if [ $modifyReport_result -ne 0 ]; then\n' |
1404 |
> |
txt += ' exit_status=1\n' |
1405 |
> |
txt += ' echo "ERROR: Problem with ModifyJobReport"\n' |
1406 |
> |
txt += 'else\n' |
1407 |
> |
txt += ' mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n' |
1408 |
> |
txt += 'fi\n' |
1409 |
> |
else: |
1410 |
> |
txt += 'ProcessedDataset=no_data_to_publish \n' |
1411 |
> |
#### FEDE: added slash in LFN ############## |
1412 |
> |
txt += 'FOR_LFN=/local/ \n' |
1413 |
> |
txt += 'echo "ProcessedDataset = $ProcessedDataset"\n' |
1414 |
> |
txt += 'echo "FOR_LFN = $FOR_LFN" \n' |
1415 |
> |
return txt |
1416 |
> |
|
1417 |
> |
def cleanEnv(self): |
1418 |
> |
### OLI_DANIELE |
1419 |
> |
txt = '' |
1420 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
1421 |
> |
txt += ' cd $RUNTIME_AREA\n' |
1422 |
> |
txt += ' echo "Remove working directory: $WORKING_DIR"\n' |
1423 |
> |
txt += ' /bin/rm -rf $WORKING_DIR\n' |
1424 |
> |
txt += ' if [ -d $WORKING_DIR ] ;then\n' |
1425 |
> |
txt += ' echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n' |
1426 |
> |
txt += ' echo "JOB_EXIT_STATUS = 60999"\n' |
1427 |
> |
txt += ' echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n' |
1428 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
1429 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
1430 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
1431 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
1432 |
> |
txt += ' fi\n' |
1433 |
|
txt += 'fi\n' |
1434 |
+ |
txt += '\n' |
1435 |
|
return txt |
1350 |
– |
################# |
1436 |
|
|
1437 |
|
def setParam_(self, param, value): |
1438 |
|
self._params[param] = value |
1446 |
|
def getTaskid(self): |
1447 |
|
return self._taskId |
1448 |
|
|
1364 |
– |
####################################################################### |
1449 |
|
def uniquelist(self, old): |
1450 |
|
""" |
1451 |
|
remove duplicates from a list |