91 |
|
try: |
92 |
|
datasetpath_split = self.datasetPath.split("/") |
93 |
|
# standard style |
94 |
– |
self.setParam_('datasetFull', self.datasetPath) |
94 |
|
if self.use_dbs_1 == 1 : |
95 |
|
self.setParam_('dataset', datasetpath_split[1]) |
96 |
|
self.setParam_('owner', datasetpath_split[-1]) |
318 |
|
if (self.sourceSeedVtx) : |
319 |
|
PsetEdit.vtxSeed("INPUTVTX") |
320 |
|
if (self.sourceSeedG4) : |
321 |
< |
PsetEdit.g4Seed("INPUTG4") |
321 |
> |
self.PsetEdit.g4Seed("INPUTG4") |
322 |
|
if (self.sourceSeedMix) : |
323 |
< |
PsetEdit.mixSeed("INPUTMIX") |
323 |
> |
self.PsetEdit.mixSeed("INPUTMIX") |
324 |
|
# add FrameworkJobReport to parameter-set |
325 |
|
PsetEdit.addCrabFJR(self.fjrFileName) |
326 |
|
PsetEdit.psetWriter(self.configFilename()) |
582 |
|
# screen output |
583 |
|
screenOutput = "List of jobs and available destination sites:\n\n" |
584 |
|
|
586 |
– |
# keep trace of block with no sites to print a warning at the end |
587 |
– |
noSiteBlock = [] |
588 |
– |
bloskNoSite = [] |
589 |
– |
|
585 |
|
blockCounter = 0 |
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 |
< |
if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0: |
596 |
< |
noSiteBlock.append( spanRanges(jobsOfBlock[block]) ) |
597 |
< |
bloskNoSite.append( blockCounter ) |
598 |
< |
|
590 |
> |
|
591 |
|
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) |
592 |
|
|
593 |
|
self.list_of_args = list_of_lists |
594 |
|
return |
598 |
|
Perform job splitting based on number of event per job |
599 |
|
""" |
600 |
|
common.logger.debug(5,'Splitting per events') |
601 |
< |
|
602 |
< |
if (self.selectEventsPerJob): |
603 |
< |
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 ') |
601 |
> |
common.logger.message('Required '+str(self.eventsPerJob)+' events per job ') |
602 |
> |
common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ') |
603 |
> |
common.logger.message('Required '+str(self.total_number_of_events)+' events in total ') |
604 |
|
|
605 |
|
if (self.total_number_of_events < 0): |
606 |
|
msg='Cannot split jobs per Events with "-1" as total number of events' |
767 |
|
# distinguish case when script is in user project area or given by full path somewhere else |
768 |
|
if exeWithPath.find(path) >= 0 : |
769 |
|
exe = string.replace(exeWithPath, path,'') |
770 |
< |
tar.add(path+exe,exe) |
770 |
> |
tar.add(path+exe,os.path.basename(executable)) |
771 |
|
else : |
772 |
|
tar.add(exeWithPath,os.path.basename(executable)) |
773 |
|
pass |
1181 |
|
txt += '# directory content\n' |
1182 |
|
txt += 'ls \n' |
1183 |
|
|
1184 |
< |
txt += 'output_exit_status=0\n' |
1212 |
< |
|
1213 |
< |
for fileWithSuffix in (self.output_file_sandbox): |
1184 |
> |
for fileWithSuffix in (self.output_file+self.output_file_sandbox): |
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 [ -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 |
< |
if common.scheduler.boss_scheduler_name == 'condor_g': |
1199 |
< |
txt += ' if [ $middleware == OSG ]; then \n' |
1200 |
< |
txt += ' echo "prepare dummy output file"\n' |
1201 |
< |
txt += ' echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n' |
1202 |
< |
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' |
1234 |
< |
txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n' |
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' |
1240 |
< |
txt += ' echo "JOB_EXIT_STATUS = $exit_status"\n' |
1241 |
< |
txt += ' output_exit_status=$exit_status\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' |
1358 |
|
""" |
1359 |
|
|
1360 |
|
txt = '' |
1361 |
+ |
txt += 'echo "Modify Job Report" \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 |
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 |
1370 |
|
|
1371 |
< |
txt += 'if [ -z "$SE" ]; then\n' |
1372 |
< |
txt += ' SE="" \n' |
1373 |
< |
txt += 'fi \n' |
1374 |
< |
txt += 'if [ -z "$SE_PATH" ]; then\n' |
1375 |
< |
txt += ' SE_PATH="" \n' |
1376 |
< |
txt += 'fi \n' |
1377 |
< |
txt += 'echo "SE = $SE"\n' |
1378 |
< |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
1371 |
> |
txt += 'if [ -z "$SE" ]; then\n' |
1372 |
> |
txt += ' SE="" \n' |
1373 |
> |
txt += 'fi \n' |
1374 |
> |
txt += 'if [ -z "$SE_PATH" ]; then\n' |
1375 |
> |
txt += ' SE_PATH="" \n' |
1376 |
> |
txt += 'fi \n' |
1377 |
> |
txt += 'echo "SE = $SE"\n' |
1378 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
1379 |
|
|
1380 |
< |
#if (publish_data == 1): |
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' |
1407 |
|
txt += ' mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n' |
1408 |
|
txt += 'fi\n' |
1409 |
|
else: |
1410 |
< |
txt += 'echo "no data publication required"\n' |
1455 |
< |
#txt += 'ProcessedDataset=no_data_to_publish \n' |
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' |
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): |
1454 |
|
for e in old: |
1455 |
|
nd[e]=0 |
1456 |
|
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 |