ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_cmssw.py
(Generate patch)

Comparing COMP/CRAB/python/cms_cmssw.py (file contents):
Revision 1.116 by gutsche, Tue Aug 14 15:44:19 2007 UTC vs.
Revision 1.116.2.8 by fanzago, Wed Oct 17 13:25:00 2007 UTC

# Line 91 | Line 91 | class Cmssw(JobType):
91              try:
92                  datasetpath_split = self.datasetPath.split("/")
93                  # standard style
94 +                self.setParam_('datasetFull', self.datasetPath)
95                  if self.use_dbs_1 == 1 :
96                      self.setParam_('dataset', datasetpath_split[1])
97                      self.setParam_('owner', datasetpath_split[-1])
# Line 318 | Line 319 | class Cmssw(JobType):
319                          if (self.sourceSeedVtx) :
320                              PsetEdit.vtxSeed("INPUTVTX")
321                          if (self.sourceSeedG4) :
322 <                            self.PsetEdit.g4Seed("INPUTG4")
322 >                            PsetEdit.g4Seed("INPUTG4")
323                          if (self.sourceSeedMix) :
324 <                            self.PsetEdit.mixSeed("INPUTMIX")
324 >                            PsetEdit.mixSeed("INPUTMIX")
325                  # add FrameworkJobReport to parameter-set
326                  PsetEdit.addCrabFJR(self.fjrFileName)
327                  PsetEdit.psetWriter(self.configFilename())
# Line 582 | Line 583 | class Cmssw(JobType):
583          # screen output
584          screenOutput = "List of jobs and available destination sites:\n\n"
585  
586 +        # keep trace of block with no sites to print a warning at the end
587 +        noSiteBlock = []
588 +        bloskNoSite = []
589 +
590          blockCounter = 0
591          for block in blocks:
592              if block in jobsOfBlock.keys() :
593                  blockCounter += 1
594                  screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
595 <
595 >                if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
596 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
597 >                    bloskNoSite.append( blockCounter )
598 >        
599          common.logger.message(screenOutput)
600 +        if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
601 +            msg = 'WARNING: No sites are hosting any part of data for block:\n                '
602 +            virgola = ""
603 +            if len(bloskNoSite) > 1:
604 +                virgola = ","
605 +            for block in bloskNoSite:
606 +                msg += ' ' + str(block) + virgola
607 +            msg += '\n               Related jobs:\n                 '
608 +            virgola = ""
609 +            if len(noSiteBlock) > 1:
610 +                virgola = ","
611 +            for range_jobs in noSiteBlock:
612 +                msg += str(range_jobs) + virgola
613 +            msg += '\n               will not be submitted and this block of data can not be analyzed!\n'
614 +            common.logger.message(msg)
615  
616          self.list_of_args = list_of_lists
617          return
# Line 598 | Line 621 | class Cmssw(JobType):
621          Perform job splitting based on number of event per job
622          """
623          common.logger.debug(5,'Splitting per events')
624 <        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
625 <        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
626 <        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
624 >        
625 >        if (self.selectEventsPerJob):
626 >            common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
627 >        if (self.selectNumberOfJobs):
628 >            common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
629 >        if (self.selectTotalNumberEvents):
630 >            common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
631  
632          if (self.total_number_of_events < 0):
633              msg='Cannot split jobs per Events with "-1" as total number of events'
# Line 767 | Line 794 | class Cmssw(JobType):
794                      # distinguish case when script is in user project area or given by full path somewhere else
795                      if exeWithPath.find(path) >= 0 :
796                          exe = string.replace(exeWithPath, path,'')
797 <                        tar.add(path+exe,os.path.basename(executable))
797 >                        tar.add(path+exe,exe)
798                      else :
799                          tar.add(exeWithPath,os.path.basename(executable))
800                      pass
# Line 1181 | Line 1208 | class Cmssw(JobType):
1208          txt += '# directory content\n'
1209          txt += 'ls \n'
1210  
1211 <        for fileWithSuffix in (self.output_file+self.output_file_sandbox):
1211 >        txt += 'output_exit_status=0\n'
1212 >        
1213 >        for fileWithSuffix in (self.output_file_sandbox):
1214 >            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1215 >            txt += '\n'
1216 >            txt += '# check output file\n'
1217 >            txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1218 >            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1219 >            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1220 >            txt += 'else\n'
1221 >            txt += '    exit_status=60302\n'
1222 >            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1223 >            if common.scheduler.boss_scheduler_name == 'condor_g':
1224 >                txt += '    if [ $middleware == OSG ]; then \n'
1225 >                txt += '        echo "prepare dummy output file"\n'
1226 >                txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1227 >                txt += '    fi \n'
1228 >            txt += 'fi\n'
1229 >        
1230 >        for fileWithSuffix in (self.output_file):
1231              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1232              txt += '\n'
1233              txt += '# check output file\n'
1188            # txt += 'ls '+fileWithSuffix+'\n'
1189            # txt += 'ls_result=$?\n'
1234              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1235 <            ###### FEDE 14444 - 08 - 2007 ########
1236 <            txt += '   mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1193 <            txt += '   cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1194 <            ###################################
1235 >            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1236 >            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1237              txt += 'else\n'
1238 <            txt += '   exit_status=60302\n'
1239 <            txt += '   echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1238 >            txt += '    exit_status=60302\n'
1239 >            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1240 >            txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1241 >            txt += '    output_exit_status=$exit_status\n'
1242              if common.scheduler.boss_scheduler_name == 'condor_g':
1243                  txt += '    if [ $middleware == OSG ]; then \n'
1244                  txt += '        echo "prepare dummy output file"\n'
# Line 1204 | Line 1248 | class Cmssw(JobType):
1248          file_list = []
1249          for fileWithSuffix in (self.output_file):
1250               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1251 +            
1252          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1208      
1253          txt += 'cd $RUNTIME_AREA\n'
1210        #### FEDE this is the cleanEnv function
1211        ### OLI_DANIELE
1212        #txt += 'if [ $middleware == OSG ]; then\n'  
1213        #txt += '    cd $RUNTIME_AREA\n'
1214        #txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1215        #txt += '    /bin/rm -rf $WORKING_DIR\n'
1216        #txt += '    if [ -d $WORKING_DIR ] ;then\n'
1217        #txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1218        #txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1219        #txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1220        #txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1221        #txt += '        rm -f $RUNTIME_AREA/$repo \n'
1222        #txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1223        #txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1224        #txt += '    fi\n'
1225        #txt += 'fi\n'
1226        #txt += '\n'
1227
1228
1254          return txt
1255  
1256      def numberFile_(self, file, txt):
# Line 1372 | Line 1397 | class Cmssw(JobType):
1397          """
1398  
1399          txt = ''
1375        txt += 'echo "Modify Job Report" \n'
1376        #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1377        ################ FEDE FOR DBS2 #############################################
1378        txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1379        #############################################################################
1400          try:
1401              publish_data = int(self.cfg_params['USER.publish_data'])          
1402          except KeyError:
1403              publish_data = 0
1404 +        if (publish_data == 1):  
1405 +            txt += 'echo "Modify Job Report" \n'
1406 +            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1407 +            ################ FEDE FOR DBS2 #############################################
1408 +            txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1409 +            #############################################################################
1410 +            #try:
1411 +            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1412 +            #except KeyError:
1413 +            #    publish_data = 0
1414  
1415 <        txt += 'if [ -z "$SE" ]; then\n'
1416 <        txt += '    SE="" \n'
1417 <        txt += 'fi \n'
1418 <        txt += 'if [ -z "$SE_PATH" ]; then\n'
1419 <        txt += '    SE_PATH="" \n'
1420 <        txt += 'fi \n'
1421 <        txt += 'echo "SE = $SE"\n'
1422 <        txt += 'echo "SE_PATH = $SE_PATH"\n'
1415 >            txt += 'if [ -z "$SE" ]; then\n'
1416 >            txt += '    SE="" \n'
1417 >            txt += 'fi \n'
1418 >            txt += 'if [ -z "$SE_PATH" ]; then\n'
1419 >            txt += '    SE_PATH="" \n'
1420 >            txt += 'fi \n'
1421 >            txt += 'echo "SE = $SE"\n'
1422 >            txt += 'echo "SE_PATH = $SE_PATH"\n'
1423  
1424 <        if (publish_data == 1):  
1424 >        #if (publish_data == 1):  
1425              #processedDataset = self.cfg_params['USER.processed_datasetname']
1426              processedDataset = self.cfg_params['USER.publish_data_name']
1427              txt += 'ProcessedDataset='+processedDataset+'\n'
# Line 1421 | Line 1451 | class Cmssw(JobType):
1451              txt += '    mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1452              txt += 'fi\n'
1453          else:
1454 <            txt += 'ProcessedDataset=no_data_to_publish \n'
1454 >            txt += 'echo "no data publication required"\n'
1455 >            #txt += 'ProcessedDataset=no_data_to_publish \n'
1456              #### FEDE: added slash in LFN ##############
1457 <            txt += 'FOR_LFN=/local/ \n'
1458 <            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1459 <            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1457 >            #txt += 'FOR_LFN=/local/ \n'
1458 >            #txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1459 >            #txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1460          return txt
1461  
1462      def cleanEnv(self):
# Line 1468 | Line 1499 | class Cmssw(JobType):
1499          for e in old:
1500              nd[e]=0
1501          return nd.keys()
1502 +
1503 +
1504 +    def checkOut(self, limit):
1505 +        """
1506 +        check the dimension of the output files
1507 +        """
1508 +        txt = 'echo "*****************************************"\n'
1509 +        txt += 'echo "** Starting output sandbox limit check **"\n'
1510 +        txt += 'echo "*****************************************"\n'
1511 +        allOutFiles = ""
1512 +        listOutFiles = []
1513 +        for fileOut in (self.output_file+self.output_file_sandbox):
1514 +             if fileOut.find('crab_fjr') == -1:
1515 +                 allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob')
1516 +                 listOutFiles.append(self.numberFile_(fileOut, '$NJob'))
1517 +        txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1518 +        txt += 'ls -gGhrta;\n'
1519 +        txt += 'sum=0;\n'
1520 +        txt += 'for file in '+str(allOutFiles)+' ; do\n'
1521 +        txt += '    if [ -e $file ]; then\n'
1522 +        txt += '        tt=`ls -gGrta $file | awk \'{ print $3 }\'`\n'
1523 +        txt += '        sum=`expr $sum + $tt`\n'
1524 +        txt += '    else\n'
1525 +        txt += '        echo "WARNING: output file $file not found!"\n'
1526 +        txt += '    fi\n'
1527 +        txt += 'done\n'
1528 +        txt += 'echo "Total Output dimension: $sum";\n'
1529 +        txt += 'limit='+str(limit)+';\n'
1530 +        txt += 'echo "OUTPUT FILES LIMIT SET TO: $limit";\n'
1531 +        txt += 'if [ $limit -lt $sum ]; then\n'
1532 +        txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1533 +        txt += '    echo "         checking the output file sizes..."\n'
1534 +        """
1535 +        txt += '    dim=0;\n'
1536 +        txt += '    exclude=0;\n'
1537 +        txt += '    for files in '+str(allOutFiles)+' ; do\n'
1538 +        txt += '        sumTemp=0;\n'
1539 +        txt += '        for file2 in '+str(allOutFiles)+' ; do\n'
1540 +        txt += '            if [ $file != $file2 ]; then\n'
1541 +        txt += '                tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1542 +        txt += '                sumTemp=`expr $sumTemp + $tt`;\n'
1543 +        txt += '            fi\n'
1544 +        txt += '        done\n'
1545 +        txt += '        if [ $sumTemp -lt $limit ]; then\n'
1546 +        txt += '            if [ $dim -lt $sumTemp ]; then\n'
1547 +        txt += '                dim=$sumTemp;\n'
1548 +        txt += '                exclude=$file;\n'
1549 +        txt += '            fi\n'
1550 +        txt += '        fi\n'
1551 +        txt += '    done\n'
1552 +        txt += '    echo "Dimension calculated: $dim"; echo "File to exclude: $exclude";\n'
1553 +        """
1554 +        txt += '    tot=0;\n'
1555 +        txt += '    for file2 in '+str(allOutFiles)+' ; do\n'
1556 +        txt += '        tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1557 +        txt += '        tot=`expr $tot + $tt`;\n'
1558 +        txt += '        if [ $limit -lt $tot ]; then\n'
1559 +        txt += '            tot=`expr $tot - $tt`;\n'
1560 +        txt += '            fileLast=$file;\n'
1561 +        txt += '            break;\n'
1562 +        txt += '        fi\n'
1563 +        txt += '    done\n'
1564 +        txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1565 +        txt += '    flag=0;\n'    
1566 +        txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1567 +        txt += '        if [ $fileLast = $filess ]; then\n'
1568 +        txt += '            flag=1;\n'
1569 +        txt += '        fi\n'
1570 +        txt += '        if [ $flag -eq 1 ]; then\n'
1571 +        txt += '            rm -f $filess;\n'
1572 +        txt += '        fi\n'
1573 +        txt += '    done\n'
1574 +        txt += '    ls -agGhrt;\n'
1575 +        txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1576 +        txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
1577 +        txt += '    exit_status=70000;\n'
1578 +        txt += 'else'
1579 +        txt += '    echo "Total Output dimension $sum is fine.";\n'
1580 +        txt += 'fi\n'
1581 +        txt += 'echo "*****************************************"\n'
1582 +        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1583 +        txt += 'echo "*****************************************"\n'
1584 +        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines