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.8 by gutsche, Wed Jun 14 20:52:32 2006 UTC vs.
Revision 1.32 by mkirn, Fri Jul 28 18:04:01 2006 UTC

# Line 2 | Line 2 | from JobType import JobType
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 + import math
6   import common
7   import PsetManipulator  
8  
# Line 40 | Line 41 | class Cmssw(JobType):
41  
42          ### collect Data cards
43          try:
44 <         #   self.owner = cfg_params['CMSSW.owner']
45 <         #   log.debug(6, "CMSSW::CMSSW(): owner = "+self.owner)
46 <         #   self.dataset = cfg_params['CMSSW.dataset']
47 <            self.datasetPath = cfg_params['CMSSW.datasetpath']
48 <            log.debug(6, "CMSSW::CMSSW(): datasetPath = "+self.datasetPath)
44 >            tmp =  cfg_params['CMSSW.datasetpath']
45 >            log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
46 >            if string.lower(tmp)=='none':
47 >                self.datasetPath = None
48 >                self.selectNoInput = 1
49 >            else:
50 >                self.datasetPath = tmp
51 >                self.selectNoInput = 0
52          except KeyError:
49        #    msg = "Error: owner and/or dataset not defined "
53              msg = "Error: datasetpath not defined "  
54              raise CrabException(msg)
55  
56          # ML monitoring
57          # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
58 <        datasetpath_split = self.datasetPath.split("/")
59 <        self.setParam_('dataset', datasetpath_split[1])
60 <        self.setParam_('owner', datasetpath_split[-1])
58 >        if not self.datasetPath:
59 >            self.setParam_('dataset', 'None')
60 >            self.setParam_('owner', 'None')
61 >        else:
62 >            datasetpath_split = self.datasetPath.split("/")
63 >            self.setParam_('dataset', datasetpath_split[1])
64 >            self.setParam_('owner', datasetpath_split[-1])
65 >
66          self.setTaskid_()
67          self.setParam_('taskId', self.cfg_params['taskId'])
68  
61
62
63
69          self.dataTiers = []
65 #       try:
66 #           tmpDataTiers = string.split(cfg_params['CMSSW.data_tier'],',')
67 #           for tmp in tmpDataTiers:
68 #               tmp=string.strip(tmp)
69 #               self.dataTiers.append(tmp)
70 #               pass
71 #           pass
72 #       except KeyError:
73 #           pass
74 #       log.debug(6, "Cmssw::Cmssw(): dataTiers = "+str(self.dataTiers))
70  
71          ## now the application
72          try:
# Line 117 | Line 112 | class Cmssw(JobType):
112  
113          # script_exe file as additional file in inputSandbox
114          try:
115 <           self.scriptExe = cfg_params['USER.script_exe']
116 <           self.additional_inbox_files.append(self.scriptExe)
115 >            self.scriptExe = cfg_params['USER.script_exe']
116 >            self.additional_inbox_files.append(self.scriptExe)
117 >            if self.scriptExe != '':
118 >               if not os.path.isfile(self.scriptExe):
119 >                  msg ="WARNING. file "+self.scriptExe+" not found"
120 >                  raise CrabException(msg)
121          except KeyError:
122             pass
124        if self.scriptExe != '':
125           if os.path.isfile(self.scriptExe):
126              pass
127           else:
128              log.message("WARNING. file "+self.scriptExe+" not found")
129              sys.exit()
123                    
124          ## additional input files
125          try:
126 <            tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',')
126 >            tmpAddFiles = string.split(cfg_params['USER.additional_input_files'],',')
127              for tmp in tmpAddFiles:
128                  if not os.path.exists(tmp):
129                      raise CrabException("Additional input file not found: "+tmp)
130 <                tmp=string.strip(tmp)
138 <                self.additional_inbox_files.append(tmp)
130 >                self.additional_inbox_files.append(string.strip(tmp))
131                  pass
132              pass
133          except KeyError:
134              pass
135  
136 +        # files per job
137          try:
138              self.filesPerJob = int(cfg_params['CMSSW.files_per_jobs']) #Daniele
139 +            self.selectFilesPerJob = 1
140          except KeyError:
141 <            self.filesPerJob = 1
141 >            self.filesPerJob = 0
142 >            self.selectFilesPerJob = 0
143  
144 <        ## Max event   will be total_number_of_events ???  Daniele
144 >        ## Events per job
145          try:
146 <            self.maxEv = cfg_params['CMSSW.event_per_job']
146 >            self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
147 >            self.selectEventsPerJob = 1
148          except KeyError:
149 <            self.maxEv = "-1"
150 <        ##  
149 >            self.eventsPerJob = -1
150 >            self.selectEventsPerJob = 0
151 >    
152 >        ## number of jobs
153 >        try:
154 >            self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
155 >            self.selectNumberOfJobs = 1
156 >        except KeyError:
157 >            self.theNumberOfJobs = 0
158 >            self.selectNumberOfJobs = 0
159 >
160 >        ## source seed for pythia
161 >        try:
162 >            self.sourceSeed = int(cfg_params['CMSSW.pythia_seed'])
163 >        except KeyError:
164 >            self.sourceSeed = None
165 >            common.logger.debug(5,"No seed given")
166 >
167 >        try:
168 >            self.sourceSeedVtx = int(cfg_params['CMSSW.vtx_seed'])
169 >        except KeyError:
170 >            self.sourceSeedVtx = None
171 >            common.logger.debug(5,"No vertex seed given")
172 >
173 >        if not (self.selectFilesPerJob + self.selectEventsPerJob + self.selectNumberOfJobs == 1 ):
174 >            msg = 'Must define either files_per_jobs or events_per_job or number_of_jobs'
175 >            raise CrabException(msg)
176 >
177          try:
178              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
179          except KeyError:
# Line 196 | Line 218 | class Cmssw(JobType):
218          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
219          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
220          ## Perform the data location and discovery (based on DBS/DLS)
221 <        self.DataDiscoveryAndLocation(cfg_params)
221 >        ## SL: Don't if NONE is specified as input (pythia use case)
222 >        common.analisys_common_info['sites']=None
223 >        if self.datasetPath:
224 >            self.DataDiscoveryAndLocation(cfg_params)
225          #DBSDLS-end          
226  
227          self.tgzNameWithPath = self.getTarBall(self.executable)
228 +    
229 +        ## Select Splitting
230 +        if self.selectNoInput: self.jobSplittingNoInput()
231 +        elif self.selectFilesPerJob or self.selectEventsPerJob or self.selectNumberOfJobs: self.jobSplittingPerFiles()
232 +        else:
233 +            msg = 'Don\'t know how to split...'
234 +            raise CrabException(msg)
235  
236 <        self.jobSplitting()  #Daniele job Splitting
237 <        self.PsetEdit.maxEvent(self.maxEv) #Daniele  
238 <        self.PsetEdit.inputModule("INPUT") #Daniele  
239 <        self.PsetEdit.psetWriter(self.configFilename())
240 <        
241 <
236 >        # modify Pset
237 >        try:
238 >            if (self.datasetPath): # standard job
239 >                #self.PsetEdit.maxEvent(self.eventsPerJob)
240 >                # always process all events in a file
241 >                self.PsetEdit.maxEvent("-1")
242 >                self.PsetEdit.inputModule("INPUT")
243 >
244 >            else:  # pythia like job
245 >                self.PsetEdit.maxEvent(self.eventsPerJob)
246 >                if (self.sourceSeed) :
247 >                    self.PsetEdit.pythiaSeed("INPUT")
248 >                    if (self.sourceSeedVtx) :
249 >                        self.PsetEdit.pythiaSeedVtx("INPUTVTX")
250 >            self.PsetEdit.psetWriter(self.configFilename())
251 >        except:
252 >            msg='Error while manipuliating ParameterSet: exiting...'
253 >            raise CrabException(msg)
254  
255      def DataDiscoveryAndLocation(self, cfg_params):
256  
257          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
258  
215        #datasetPath = "/"+self.owner+"/"+self.dataTiers[0]+"/"+self.dataset
216        
259          datasetPath=self.datasetPath
260  
261          ## TODO
# Line 241 | Line 283 | class Cmssw(JobType):
283          common.logger.message("Required data are :"+self.datasetPath)
284  
285          filesbyblock=self.pubdata.getFiles()
286 + #        print filesbyblock
287          self.AllInputFiles=filesbyblock.values()
288          self.files = self.AllInputFiles        
289  
247        ## TEMP
248    #    self.filesTmp = filesbyblock.values()
249    #    self.files = []
250    #    locPath='rfio:cmsbose2.bo.infn.it:/flatfiles/SE00/cms/fanfani/ProdTest/'
251    #    locPath=''
252    #    tmp = []
253    #    for file in self.filesTmp[0]:
254    #        tmp.append(locPath+file)
255    #    self.files.append(tmp)
256        ## END TEMP
257
290          ## get max number of events
291          #common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
292          self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
# Line 279 | Line 311 | class Cmssw(JobType):
311              msg = 'No sites hosting all the needed data! Exiting... '
312              raise CrabException(msg)
313  
314 <        common.logger.message("List of Sites hosting the data : "+str(sites))
314 >        common.logger.message("List of Sites ("+str(len(sites))+") hosting the data : "+str(sites))
315          common.logger.debug(6, "List of Sites: "+str(sites))
316          common.analisys_common_info['sites']=sites    ## used in SchedulerEdg.py in createSchScript
317          self.setParam_('TargetCE', ','.join(sites))
318          return
319      
320 <    def jobSplitting(self):
320 >    def jobSplittingPerFiles(self):
321          """
322 <        first implemntation for job splitting  
323 <        """    
324 <      #  print 'eventi totali '+str(self.maxEvents)
293 <      #  print 'eventi totali richiesti dallo user '+str(self.total_number_of_events)
294 <        #print 'files per job '+str(self.filesPerJob)
295 <        common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
322 >        Perform job splitting based on number of files to be accessed per job
323 >        """
324 >        common.logger.debug(5,'Splitting per input files')
325          common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
326 +        common.logger.message('Available '+str(self.maxEvents)+' events in total ')
327 +        common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
328 +        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
329 +        common.logger.message('Required '+str(self.eventsPerJob)+' events per job')
330 +
331 +        ## if asked to process all events, do it
332 +        if self.total_number_of_events == -1:
333 +            self.total_number_of_events=self.maxEvents
334 +        else:
335 +            if self.total_number_of_events>self.maxEvents:
336 +                common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.")
337 +                self.total_number_of_events=self.maxEvents
338 +            pass
339  
340          ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
341          n_tot_files = (len(self.files[0]))
342          ## SL: this is wrong if the files have different number of events
343          evPerFile = int(self.maxEvents)/n_tot_files
344 <        
344 >
345          common.logger.debug(5,'Events per File '+str(evPerFile))
346  
347 <        ## if asked to process all events, do it
348 <        if self.total_number_of_events == -1:
349 <            self.total_number_of_events=self.maxEvents
350 <            self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
351 <            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for all available events '+str(self.total_number_of_events)+' events')
347 >        ## compute job splitting parameters: filesPerJob, eventsPerJob and theNumberOfJobs
348 >        if self.selectFilesPerJob:
349 >            ## user define files per event.
350 >            filesPerJob = self.filesPerJob
351 >            eventsPerJob = filesPerJob*evPerFile
352 >            theNumberOfJobs = int(self.total_number_of_events*1./eventsPerJob)
353 >            check = int(self.total_number_of_events) - (theNumberOfJobs*eventsPerJob)
354 >            if check > 0:
355 >                theNumberOfJobs +=1
356 >                filesLastJob = int(check*1./evPerFile+0.5)
357 >                common.logger.message('Warning: last job will be created with '+str(check)+' files')
358 >            else:
359 >                filesLastJob = filesPerJob
360 >
361 >        elif self.selectNumberOfJobs:
362 >            ## User select the number of jobs: last might be bigger to match request of events
363 >            theNumberOfJobs =  self.theNumberOfJobs
364 >
365 >            eventsPerJob = self.total_number_of_events/theNumberOfJobs
366 >            filesPerJob = int(eventsPerJob/evPerFile)
367 >            if (filesPerJob==0) : filesPerJob=1
368 >            check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile)
369 >            if not check == 0:
370 >                if check<0:
371 >                    missingFiles = int(check/evPerFile)
372 >                    additionalJobs = int(missingFiles/filesPerJob)
373 >                    #print missingFiles, additionalJobs
374 >                    theNumberOfJobs+=additionalJobs
375 >                    common.logger.message('Warning: will create only '+str(theNumberOfJobs)+' jobs')
376 >                    check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile)
377 >                    
378 >                if check >0 :
379 >                    filesLastJob = filesPerJob+int(check*1./evPerFile+0.5)
380 >                    common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events')
381 >                else:
382 >                    filesLastJob = filesPerJob
383 >            else:
384 >                filesLastJob = filesPerJob
385 >        elif self.selectEventsPerJob:
386 >            # SL case if asked events per job
387 >            ## estimate the number of files per job to match the user requirement
388 >            filesPerJob = int(float(self.eventsPerJob)/float(evPerFile))
389 >            if filesPerJob==0: filesPerJob=1
390 >            common.logger.debug(5,"filesPerJob "+str(filesPerJob))
391 >            if (filesPerJob==0): filesPerJob=1
392 >            eventsPerJob=filesPerJob*evPerFile
393 >            theNumberOfJobs = int(self.total_number_of_events)/int(eventsPerJob)
394 >            check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob)
395 >            if not check == 0:
396 >                missingFiles = int(check/evPerFile)
397 >                additionalJobs = int(missingFiles/filesPerJob)
398 >                if ( additionalJobs>0) : theNumberOfJobs+=additionalJobs
399 >                check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob)
400 >                if not check == 0:
401 >                    if (check <0 ):
402 >                        filesLastJob = filesPerJob+int(check*1./evPerFile-0.5)
403 >                    else:
404 >                        theNumberOfJobs+=1
405 >                        filesLastJob = int(check*1./evPerFile+0.5)
406 >
407 >                    common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events')
408 >                else:
409 >                    filesLastJob = filesPerJob
410 >            else:
411 >                filesLastJob = filesPerJob
412          
413 <        else:
414 <            self.total_number_of_files = int(self.total_number_of_events/evPerFile)
415 <            ## SL: if ask for less event than what is computed to be available on a
416 <            ##     file, process the first file anyhow.
417 <            if self.total_number_of_files == 0:
418 <                self.total_number_of_files = self.total_number_of_files + 1
413 >        self.total_number_of_jobs = theNumberOfJobs
414 >
415 >        totalEventsToBeUsed=theNumberOfJobs*filesPerJob*evPerFile
416 >        if not check == 0:
417 >        #    print (theNumberOfJobs-1)*filesPerJob*evPerFile,filesLastJob*evPerFile
418 >            totalEventsToBeUsed=(theNumberOfJobs-1)*filesPerJob*evPerFile+filesLastJob*evPerFile
419 >
420 >        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(filesPerJob*evPerFile)+' events, for a total of '+str(totalEventsToBeUsed)+' events')
421  
422 <            common.logger.debug(5,'N files  '+str(self.total_number_of_files))
422 >        totalFilesToBeUsed=filesPerJob*(theNumberOfJobs-1)+filesLastJob
423  
424 <            check = 0
424 >        ## set job arguments (files)
425 >        list_of_lists = []
426 >        lastFile=0
427 >        for i in range(0, int(totalFilesToBeUsed), filesPerJob)[:-1]:
428 >            parString = "\\{"
429 >            
430 >            lastFile=i+filesPerJob
431 >            params = self.files[0][i: lastFile]
432 >            for i in range(len(params) - 1):
433 >                parString += '\\\"' + params[i] + '\\\"\,'
434              
435 <            ## Compute the number of jobs
436 <            #self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
437 <            self.total_number_of_jobs = int(self.total_number_of_files/self.filesPerJob)
325 <            common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
435 >            parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
436 >            list_of_lists.append([parString])
437 >            pass
438  
439 <            ## is there any remainder?
440 <            check = int(self.total_number_of_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
439 >        ## last job
440 >        parString = "\\{"
441 >        
442 >        params = self.files[0][lastFile: lastFile+filesLastJob]
443 >        for i in range(len(params) - 1):
444 >            parString += '\\\"' + params[i] + '\\\"\,'
445 >        
446 >        parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
447 >        list_of_lists.append([parString])
448 >        pass
449  
450 <            common.logger.debug(5,'Check  '+str(check))
450 >        self.list_of_args = list_of_lists
451 >        # print self.list_of_args[0]
452 >        return
453  
454 <            if check > 0:
455 <                self.total_number_of_jobs =  self.total_number_of_jobs + 1
456 <                common.logger.message('Warning: last job will be created with '+str(check)+' files')
454 >    def jobSplittingNoInput(self):
455 >        """
456 >        Perform job splitting based on number of event per job
457 >        """
458 >        common.logger.debug(5,'Splitting per events')
459 >        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
460 >        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
461 >        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
462  
463 <            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str((self.total_number_of_jobs-1)*self.filesPerJob*evPerFile + check*evPerFile)+' events')
464 <            pass
463 >        if (self.total_number_of_events < 0):
464 >            msg='Cannot split jobs per Events with "-1" as total number of events'
465 >            raise CrabException(msg)
466  
467 <        list_of_lists = []
468 <        for i in xrange(0, int(n_tot_files), self.filesPerJob):
469 <            list_of_lists.append(self.files[0][i: i+self.filesPerJob])
467 >        if (self.selectEventsPerJob):
468 >            self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
469 >        elif (self.selectNumberOfJobs) :
470 >            self.total_number_of_jobs = self.theNumberOfJobs
471 >            self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
472 >
473 >        common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
474 >
475 >        # is there any remainder?
476 >        check = int(self.total_number_of_events) - (int(self.total_number_of_jobs)*self.eventsPerJob)
477 >
478 >        common.logger.debug(5,'Check  '+str(check))
479 >
480 >        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(self.eventsPerJob)+' for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events')
481 >        if check > 0:
482 >            common.logger.message('Warning: asked '+str(self.total_number_of_events)+' but will do only '+str(int(self.total_number_of_jobs)*self.eventsPerJob))
483 >
484 >
485 >        # argument is seed number.$i
486 >        self.list_of_args = []
487 >        for i in range(self.total_number_of_jobs):
488 >            if (self.sourceSeed):
489 >                if (self.sourceSeedVtx):
490 >                    ## pythia + vtx random seed
491 >                    self.list_of_args.append([
492 >                                              str(self.sourceSeed)+str(i),
493 >                                              str(self.sourceSeedVtx)+str(i)
494 >                                              ])
495 >                else:
496 >                    ## only pythia random seed
497 >                    self.list_of_args.append([(str(self.sourceSeed)+str(i))])
498 >            else:
499 >                ## no random seed
500 >                self.list_of_args.append([str(i)])
501 >        #print self.list_of_args
502  
343        self.list_of_files = list_of_lists
344      
503          return
504  
505      def split(self, jobParams):
# Line 349 | Line 507 | class Cmssw(JobType):
507          common.jobDB.load()
508          #### Fabio
509          njobs = self.total_number_of_jobs
510 <        filelist = self.list_of_files
510 >        arglist = self.list_of_args
511          # create the empty structure
512          for i in range(njobs):
513              jobParams.append("")
514          
515          for job in range(njobs):
516 <            jobParams[job] = filelist[job]
516 >            jobParams[job] = arglist[job]
517 >            # print str(arglist[job])
518 >            # print jobParams[job]
519              common.jobDB.setArguments(job, jobParams[job])
520  
521          common.jobDB.save()
522          return
523      
524      def getJobTypeArguments(self, nj, sched):
525 <        params = common.jobDB.arguments(nj)
526 <        #print params
527 <        parString = "\\{"
528 <        
369 <        for i in range(len(params) - 1):
370 <            parString += '\\\"' + params[i] + '\\\"\,'
371 <        
372 <        parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
373 <        return parString
525 >        result = ''
526 >        for i in common.jobDB.arguments(nj):
527 >            result=result+str(i)+" "
528 >        return result
529    
530      def numberOfJobs(self):
531          # Fabio
377
532          return self.total_number_of_jobs
379
380
533  
534      def checkBlackList(self, allSites):
535          if len(self.reCEBlackList)==0: return allSites
# Line 517 | Line 669 | class Cmssw(JobType):
669          txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
670          txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
671          txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
672 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
673 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
674 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
675          txt += '        exit 1\n'
676          txt += '    fi\n'
677          txt += '\n'
# Line 536 | Line 691 | class Cmssw(JobType):
691          txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
692          txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
693          txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
694 +        txt += '   rm -f $RUNTIME_AREA/$repo \n'
695 +        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
696 +        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
697          ## OLI_Daniele
698          txt += '    if [ $middleware == OSG ]; then \n'
699          txt += '        echo "Remove working directory: $WORKING_DIR"\n'
# Line 546 | Line 704 | class Cmssw(JobType):
704          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
705          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
706          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
707 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
708 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
709 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
710          txt += '        fi\n'
711          txt += '    fi \n'
712          txt += '   exit 1 \n'
# Line 559 | Line 720 | class Cmssw(JobType):
720          txt += "\n"
721          txt += "## number of arguments (first argument always jobnumber)\n"
722          txt += "\n"
723 <        txt += "narg=$#\n"
724 <        txt += "if [ $narg -lt 2 ]\n"
723 > #        txt += "narg=$#\n"
724 > # Malina fix
725 >        txt += "if [ $nargs -lt 2 ]\n"
726          txt += "then\n"
727          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n"
728          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
729          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
730          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
731 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
732 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
733 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
734          ## OLI_Daniele
735          txt += '    if [ $middleware == OSG ]; then \n'
736          txt += '        echo "Remove working directory: $WORKING_DIR"\n'
# Line 576 | Line 741 | class Cmssw(JobType):
741          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
742          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
743          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
744 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
745 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
746 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
747          txt += '        fi\n'
748          txt += '    fi \n'
749          txt += "    exit 1\n"
# Line 586 | Line 754 | class Cmssw(JobType):
754          job = common.job_list[nj]
755          pset = os.path.basename(job.configFilename())
756          txt += '\n'
757 <        txt += 'InputFiles=$2\n'
758 <        txt += 'echo "<$InputFiles>"\n'
759 <        #txt += 'echo sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' \n'
760 <        txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
761 <        #txt += 'sed "s#{\'INPUT\'}#${InputFiles}#" $RUNTIME_AREA/'+pset+' > pset1.cfg\n'
757 >        if (self.datasetPath): # standard job
758 >            #txt += 'InputFiles=$2\n'
759 >            txt += 'InputFiles=${args[1]}\n'
760 >            txt += 'echo "Inputfiles:<$InputFiles>"\n'
761 >            txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
762 >        else:  # pythia like job
763 >            if (self.sourceSeed):
764 >                txt += 'Seed=$2\n'
765 >                txt += 'echo "Seed: <$Seed>"\n'
766 >                txt += 'sed "s#\<INPUT\>#$Seed#" $RUNTIME_AREA/'+pset+' > tmp.cfg\n'
767 >                if (self.sourceSeedVtx):
768 >                    txt += 'VtxSeed=$3\n'
769 >                    txt += 'echo "VtxSeed: <$VtxSeed>"\n'
770 >                    txt += 'sed "s#INPUTVTX#$VtxSeed#" tmp.cfg > pset.cfg\n'
771 >                else:
772 >                    txt += 'mv tmp.cfg pset.cfg\n'
773 >            else:
774 >                txt += '# Copy untouched pset\n'
775 >                txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n'
776 >
777  
778          if len(self.additional_inbox_files) > 0:
779              for file in self.additional_inbox_files:
780 <                txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
781 <                txt += '   cp $RUNTIME_AREA/'+file+' .\n'
782 <                txt += '   chmod +x '+file+'\n'
780 >                relFile = file.split("/")[-1]
781 >                txt += 'if [ -e $RUNTIME_AREA/'+relFile+' ] ; then\n'
782 >                txt += '   cp $RUNTIME_AREA/'+relFile+' .\n'
783 >                txt += '   chmod +x '+relFile+'\n'
784                  txt += 'fi\n'
785              pass
786  
# Line 633 | Line 817 | class Cmssw(JobType):
817              txt += '       cd $RUNTIME_AREA\n'
818              txt += '       /bin/rm -rf $WORKING_DIR\n'
819              txt += '       if [ -d $WORKING_DIR ] ;then\n'
820 <            txt += '        echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
821 <            txt += '        echo "JOB_EXIT_STATUS = 50999"\n'
822 <            txt += '        echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
823 <            txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
820 >            txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
821 >            txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
822 >            txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
823 >            txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
824 >            txt += '           rm -f $RUNTIME_AREA/$repo \n'
825 >            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
826 >            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
827              txt += '       fi\n'
828              txt += '   fi \n'
829              txt += '   \n'
# Line 714 | Line 901 | class Cmssw(JobType):
901              txt += '\n'
902              txt += '# check output file\n'
903              txt += 'ls '+fileWithSuffix+'\n'
904 <            txt += 'exe_result=$?\n'
905 <            txt += 'if [ $exe_result -ne 0 ] ; then\n'
906 <            txt += '   echo "ERROR: No output file to manage"\n'
907 <            txt += '   echo "JOB_EXIT_STATUS = $exe_result"\n'
908 <            txt += '   echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
909 <            txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
904 >            txt += 'ls_result=$?\n'
905 >            #txt += 'exe_result=$?\n'
906 >            txt += 'if [ $ls_result -ne 0 ] ; then\n'
907 >            txt += '   echo "ERROR: Problem with output file"\n'
908 >            #txt += '   echo "JOB_EXIT_STATUS = $exe_result"\n'
909 >            #txt += '   echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
910 >            #txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
911              ### OLI_DANIELE
912              if common.scheduler.boss_scheduler_name == 'condor_g':
913                  txt += '    if [ $middleware == OSG ]; then \n'
# Line 733 | Line 921 | class Cmssw(JobType):
921          txt += 'cd $RUNTIME_AREA\n'
922          file_list=file_list[:-1]
923          txt += 'file_list="'+file_list+'"\n'
924 +        txt += 'cd $RUNTIME_AREA\n'
925          ### OLI_DANIELE
926          txt += 'if [ $middleware == OSG ]; then\n'  
927          txt += '    cd $RUNTIME_AREA\n'
# Line 743 | Line 932 | class Cmssw(JobType):
932          txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
933          txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
934          txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
935 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
936 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
937 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
938          txt += '    fi\n'
939          txt += 'fi\n'
940          txt += '\n'
# Line 773 | Line 965 | class Cmssw(JobType):
965          return job requirements to add to jdl files
966          """
967          req = ''
968 +        if common.analisys_common_info['sw_version']:
969 +            req='Member("VO-cms-' + \
970 +                 common.analisys_common_info['sw_version'] + \
971 +                 '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
972          if common.analisys_common_info['sites']:
777            if common.analisys_common_info['sw_version']:
778                req='Member("VO-cms-' + \
779                     common.analisys_common_info['sw_version'] + \
780                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
973              if len(common.analisys_common_info['sites'])>0:
974                  req = req + ' && ('
975                  for i in range(len(common.analisys_common_info['sites'])):
# Line 812 | Line 1004 | class Cmssw(JobType):
1004          txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1005          txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1006          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1007 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1008 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1009 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1010          txt += '       exit 1\n'
1011          txt += '\n'
1012          txt += '       echo "Remove working directory: $WORKING_DIR"\n'
# Line 822 | Line 1017 | class Cmssw(JobType):
1017          txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1018          txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1019          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1020 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
1021 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1022 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1023          txt += '       fi\n'
1024          txt += '\n'
1025          txt += '       exit 1\n'
# Line 845 | Line 1043 | class Cmssw(JobType):
1043          txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1044          txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1045          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1046 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1047 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1048 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1049          txt += '       exit 1\n'
1050          txt += '   else\n'
1051          txt += '       echo "Sourcing environment... "\n'
# Line 853 | Line 1054 | class Cmssw(JobType):
1054          txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1055          txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1056          txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1057 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1058 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1059 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1060          txt += '           exit 1\n'
1061          txt += '       fi\n'
1062          txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
# Line 863 | Line 1067 | class Cmssw(JobType):
1067          txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1068          txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1069          txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1070 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1071 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1072 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1073          txt += '           exit 1\n'
1074          txt += '       fi\n'
1075          txt += '   fi\n'
# Line 879 | Line 1086 | class Cmssw(JobType):
1086          txt += '       echo "JOB_EXIT_STATUS = 10033"\n'
1087          txt += '       echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
1088          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1089 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1090 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1091 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1092          txt += '       exit 1\n'
1093          txt += '   fi\n'
1094          txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines