コード例 #1
0
    def copy(self):
        """
        1) local copy: it is the default. The output will be copied under crab_working_dir/res dir
        2) copy to a remote SE specifying -dest_se (official CMS remote SE)
           or -dest_endpoint (not official, needed the complete endpoint)
        """

        to_copy = {}
        results = {}
        tmp = ''

        lfn, to_copy = self.checkAvailableList()

        if (self.copy_local == 1):
            outputDir = self.cfg_params.get('USER.outputdir',
                                            common.work_space.resDir())
            common.logger.info("Copy file locally.\n\tOutput dir: %s" %
                               outputDir)
            dest = {"destinationDir": outputDir}
        else:
            if (self.dest_se != 'local'):
                from PhEDExDatasvcInfo import PhEDExDatasvcInfo
                phedexCfg = {'storage_element': self.dest_se}
                stageout = PhEDExDatasvcInfo(config=phedexCfg)
                self.endpoint = stageout.getStageoutPFN()

                if (str(lfn).find("/store/temp/") == 0):
                    tmp = lfn.replace("/store/temp/", "/", 1)
                elif (str(lfn).find("/store/") == 0):
                    tmp = lfn.replace("/store/", "/", 1)
                else:
                    tmp = lfn

                common.logger.debug("Source LFN = %s" % lfn)
                common.logger.debug("tmp LFN = %s" % tmp)
                self.endpoint = self.endpoint + tmp
            else:
                self.endpoint = self.dest_endpoint

            common.logger.info("Copy file to remote SE.\n\tEndpoint: %s" %
                               self.endpoint)

            dest = {"destination": self.endpoint}

        for key in to_copy.keys():
            cmscpConfig = {
                "source": key,
                "inputFileList": to_copy[key],
                "protocol": self.protocol,
                #"debug":'1'
            }
            cmscpConfig.update(dest)

            common.logger.debug("Source = %s" % key)
            common.logger.debug("Files = %s" % to_copy[key])
            common.logger.debug("CmscpConfig = %s" % str(cmscpConfig))

            results.update(self.performCopy(cmscpConfig))
        return results
コード例 #2
0
ファイル: CopyData.py プロジェクト: PerilousApricot/CRAB2
    def copy(self):
        """
        1) local copy: it is the default. The output will be copied under crab_working_dir/res dir
        2) copy to a remote SE specifying -dest_se (official CMS remote SE)
           or -dest_endpoint (not official, needed the complete endpoint)
        """

        to_copy = {}
        results = {}
        tmp = ""

        lfn, to_copy = self.checkAvailableList()

        if self.copy_local == 1:
            outputDir = self.cfg_params.get("USER.outputdir", common.work_space.resDir())
            common.logger.info("Copy file locally.\n\tOutput dir: %s" % outputDir)
            dest = {"destinationDir": outputDir}
        else:
            if self.dest_se != "local":
                from PhEDExDatasvcInfo import PhEDExDatasvcInfo

                phedexCfg = {"storage_element": self.dest_se}
                stageout = PhEDExDatasvcInfo(config=phedexCfg)
                self.endpoint = stageout.getStageoutPFN()

                if str(lfn).find("/store/temp/") == 0:
                    tmp = lfn.replace("/store/temp/", "/", 1)
                elif str(lfn).find("/store/") == 0:
                    tmp = lfn.replace("/store/", "/", 1)
                else:
                    tmp = lfn

                common.logger.debug("Source LFN = %s" % lfn)
                common.logger.debug("tmp LFN = %s" % tmp)
                self.endpoint = self.endpoint + tmp
            else:
                self.endpoint = self.dest_endpoint

            common.logger.info("Copy file to remote SE.\n\tEndpoint: %s" % self.endpoint)

            dest = {"destination": self.endpoint}

        for key in to_copy.keys():
            cmscpConfig = {
                "source": key,
                "inputFileList": to_copy[key],
                "protocol": self.protocol,
                # "debug":'1'
            }
            cmscpConfig.update(dest)

            common.logger.debug("Source = %s" % key)
            common.logger.debug("Files = %s" % to_copy[key])
            common.logger.debug("CmscpConfig = %s" % str(cmscpConfig))

            results.update(self.performCopy(cmscpConfig))
        return results
コード例 #3
0
    def wsCopyOutput(self):
        """
        Write a CopyResults part of a job script, e.g.
        to copy produced output into a storage element.
        """
        index = int(common._db.nJobs())
        job = common.job_list[index-1]
        jbt = job.type()

        txt = '\n'

        txt += '#\n'
        txt += '# COPY OUTPUT FILE TO SE\n'
        txt += '#\n\n'

        if int(self.copy_data) == 1:
            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            if self.check_RemoteDir == 1 :
                self.checkRemoteDir(endpoint,jbt.outList('list') )
            txt += 'export SE='+SE+'\n'
            txt += 'echo "SE = $SE"\n'
            txt += 'export SE_PATH='+SE_PATH+'\n'
            txt += 'echo "SE_PATH = $SE_PATH"\n'
            txt += 'export LFNBaseName='+lfn+'\n'
            txt += 'echo "LFNBaseName = $LFNBaseName"\n'
            txt += 'export USER='******'\n'
            txt += 'echo "USER = $USER"\n'
            txt += 'export endpoint='+endpoint+'\n'
            txt += 'echo "endpoint = $endpoint"\n'

            txt += 'echo ">>> Copy output files from WN = `hostname` to $SE_PATH :"\n'
            txt += 'export TIME_STAGEOUT_INI=`date +%s` \n'
            txt += 'copy_exit_status=0\n'
            cmscp_args = ' --destination $endpoint --inputFileList $file_list'
            ### FEDE FOR MULTI ### 
            #cmscp_args +=' --middleware $middleware --lfn $LFNBaseName %s %s '%(self.loc_stage_out,self.debugWrap)
            cmscp_args +=' --middleware $middleware --se_name $SE --for_lfn $LFNBaseName %s %s '%(self.loc_stage_out,self.debugWrap)
            if self.space_token:
                cmscp_args +=' --option space_token=%s'%str(self.space_token)
            txt += 'echo "python cmscp.py %s "\n'%cmscp_args
            txt += 'python cmscp.py %s \n'%cmscp_args
            if self.debug_wrapper==1:
                txt += 'echo "which lcg-ls"\n'
                txt += 'which lcg-ls\n'
                txt += 'echo "########### details of SE interaction"\n'
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    cat .SEinteraction.log\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
                txt += 'echo "#####################################"\n'
            
            txt += 'if [ -f $RUNTIME_AREA/resultCopyFile ] ;then\n'
            txt += '    cat $RUNTIME_AREA/resultCopyFile\n'
            txt += '    pwd\n'
            txt += 'else\n'
            ### FEDE to avoid some 70500 error ....
            txt += '    echo "ERROR ==> $RUNTIME_AREA/resultCopyFile file not found. Problem during the stageout"\n'
            txt += '    echo "RUNTIME_AREA content: " \n'
            txt += '    ls $RUNTIME_AREA \n'
            txt += '    job_exit_code=60318\n'
            txt += '    func_exit \n'
            txt += 'fi\n'
            ################################

            txt += 'if [ -f cmscpReport.sh ] ;then\n'
            txt += '    cat cmscpReport.sh\n'
            txt += '    source cmscpReport.sh\n'
            txt += '    source_result=$? \n'
            txt += '    if [ $source_result -ne 0 ]; then\n'
            txt += '        echo "problem with the source of cmscpReport.sh file"\n'
            txt += '        StageOutExitStatus=60307\n'
            txt += '    fi\n'
            txt += 'else\n'
            txt += '    echo "cmscpReport.sh file not found"\n'
            txt += '    StageOutExitStatus=60307\n'
            txt += 'fi\n'
            txt += 'if [ $StageOutExitStatus -ne 0 ]; then\n'
            txt += '    echo "Problem copying file to $SE $SE_PATH"\n'
            txt += '    copy_exit_status=$StageOutExitStatus \n'
            if not self.debug_wrapper==1:
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    echo "########## contents of SE interaction"\n'
                txt += '    cat .SEinteraction.log\n'
                txt += '    echo "#####################################"\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
            txt += '    job_exit_code=$StageOutExitStatus\n'
            txt += 'fi\n'
            txt += 'export TIME_STAGEOUT_END=`date +%s` \n'
            txt += 'let "TIME_STAGEOUT = TIME_STAGEOUT_END - TIME_STAGEOUT_INI" \n'
        else:
            # set stageout timing to a fake value
            txt += 'export TIME_STAGEOUT=-1 \n'
        return txt
コード例 #4
0
ファイル: Reporter.py プロジェクト: ericvaandering/CRAB2
    def run(self):
        """
        The main method of the class: report status of a task
        """
        common.logger.debug("Reporter::run() called")
        task = common._db.getTask()

        msg = "--------------------\n"
        msg += "Dataset: %s\n" % str(task['dataset'])
        if self.cfg_params.has_key('USER.copy_data') and int(
                self.cfg_params['USER.copy_data']) == 1:
            msg += "Remote output :\n"
            ## TODO: SL should come from jobDB!
            from PhEDExDatasvcInfo import PhEDExDatasvcInfo

            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            #print endpoint, lfn, SE, SE_PATH, user

            msg += "SE: %s %s  srmPath: %s\n" % (
                self.cfg_params['USER.storage_element'], SE, endpoint)

        else:
            msg += "Local output: %s\n" % task['outputDirectory']
        #print task
        possible_status = [
            'Created', 'Undefined', 'Submitting', 'Submitted', 'NotSubmitted',
            'Waiting', 'Ready', 'Scheduled', 'Running', 'Done', 'Killing',
            'Killed', 'Aborted', 'Unknown', 'Done (Failed)', 'Cleared',
            'Retrieved'
        ]
        eventsRead = 0
        eventsRequired = 0
        filesRead = 0
        filesRequired = 0
        lumis = []
        for job in task.getJobs():
            if (job.runningJob['applicationReturnCode'] != 0
                    or job.runningJob['wrapperReturnCode'] != 0):
                continue
            # get FJR filename
            fjr = self.fjrDirectory + job['outputFiles'][-1]

            jobReport = readJobReport(fjr)
            if len(jobReport) > 0:
                inputFiles = jobReport[0].inputFiles
                for inputFile in inputFiles:
                    # Accumulate the list of lum sections run over
                    for run in inputFile.runs.keys():
                        for lumi in inputFile.runs[run]:
                            lumis.append((run, lumi))
                    filesRead += 1
                    eventsRead += int(inputFile['EventsRead'])
                #print jobReport[0].inputFiles,'\n'
            else:
                pass
                #print 'no FJR avaialble for job #%s'%job['jobId']
            #print "--------------------------"

        # Compact and write the list of successful lumis

        lumiList = LumiList(lumis=lumis)
        compactList = lumiList.getCompactList()

        lumiFilename = task['outputDirectory'] + 'lumiSummary.json'
        lumiSummary = open(lumiFilename, 'w')
        json.dump(compactList, lumiSummary)
        lumiSummary.write('\n')
        lumiSummary.close()

        msg += "Total Events read: %s\n" % eventsRead
        msg += "Total Files read: %s\n" % filesRead
        msg += "Total Jobs : %s\n" % len(task.getJobs())
        msg += "Luminosity section summary file: %s\n" % lumiFilename
        list_ID = {}

        # TEMPORARY by Fabio, to be removed
        # avoid clashes between glite_slc5 and glite schedulers when a server is used
        # otherwise, -report with a server requires a local scheduler
        if self.cfg_params.get('CRAB.server_name', None) is None:
            common.logger.debug("Reporter updating task status")
            task = common.scheduler.queryEverything(task['id'])

        for st in possible_status:
            list_ID = common._db.queryAttrRunJob({'statusScheduler': st},
                                                 'jobId')
            if (len(list_ID) > 0):
                msg += "   # Jobs: %s:%s\n" % (str(st), len(list_ID))
            pass
        msg += "\n----------------------------\n"
        common.logger.info(msg)

        file = common.work_space.shareDir() + 'arguments.xml'
        #print "file = ", file

        ### starting from the arguments.xml file, a json file containing the run:lumi
        ### that should be analyzed with the task
        inputRunLumiFileName = self.getInputRunLumi(file)

        ### missing lumi to analyze: starting from lumimask or from argument file
        ### calculate the difference with report.json
        ### if a lumimask is used in the crab.cfg
        if (self.cfg_params.get('CMSSW.lumi_mask')):
            lumimask = self.cfg_params.get('CMSSW.lumi_mask')
            #print "lumimask = ", lumimask
            self.compareJsonFile(lumimask)
        ### without lumimask
        elif (inputRunLumiFileName):
            self.compareJsonFile(inputRunLumiFileName)
        else:
            common.logger.info("No json file to compare")
        return
コード例 #5
0
    def checkRemoteDir(self,task):

        if self.copy_data==1: 
            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            common.scheduler.checkRemoteDir(endpoint,eval(task['outfileBasename']))
コード例 #6
0
    def wsCopyOutput_comm(self, pool=None):
        """
        Write a CopyResults part of a job script, e.g.
        to copy produced output into a storage element.
        """
        index = int(common._db.nJobs())
        job = common.job_list[index-1]
        jbt = job.type()
        txt = '\n'
        if int(self.copy_data) == 1:

            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            print "endpoint = ", endpoint

            ########################################################
            ##################### FEDE FOR CAF #####################
            cmscp_args = '' 
            if  common.scheduler.name().upper() == 'CAF':
                    if endpoint.find('root:') != -1:
                        SE_PATH = '/' + endpoint.split('//')[2]
                        caf_protocol = 'xrootd'
                        cmscp_args += '--protocol %s '%caf_protocol
                    elif endpoint.find('rfio:') != -1:
                        if endpoint.find('path=') != -1:
                            SE_PATH = endpoint.split('path=')[1]
                        else:
                            SE_PATH = endpoint
                        caf_protocol = 'rfio'
                        cmscp_args += '--protocol %s '%caf_protocol
            ########################################################            
            ########################################################            

            if self.check_RemoteDir == 1 :
                self.checkRemoteDir(endpoint,jbt.outList('list') )

            txt += '#\n'
            txt += '# COPY OUTPUT FILE TO '+SE_PATH+ '\n'
            txt += '#\n\n'

            txt += 'export SE='+SE+'\n'
            txt += 'echo "SE = $SE"\n'
            txt += 'export SE_PATH='+SE_PATH+'\n'
            txt += 'echo "SE_PATH = $SE_PATH"\n'
            txt += 'export LFNBaseName='+lfn+'\n'
            txt += 'echo "LFNBaseName = $LFNBaseName"\n'
            txt += 'export USER='******'\n'
            txt += 'echo "USER = $USER"\n'
            #txt += 'export endpoint='+"'"+endpoint+"'"+'\n'
            txt += 'export endpoint='+endpoint+'\n'
            txt += 'echo "endpoint = $endpoint"\n'
            
            if (pool) and (pool != 'None'):
                txt += 'export STAGE_SVCCLASS='+str(pool)+'\n'

            txt += 'echo ">>> Copy output files from WN = `hostname` to $SE_PATH :"\n'
            txt += 'export TIME_STAGEOUT_INI=`date +%s` \n'
            txt += 'copy_exit_status=0\n'
            #### FEDE added += ######### 
            cmscp_args += ' --destination $endpoint --inputFileList $file_list'
            #######################################################
            #######################################################
            cmscp_args +=' --middleware $middleware --se_name $SE --for_lfn $LFNBaseName %s %s '%(self.loc_stage_out,self.debugWrap)
            txt += 'echo "python cmscp.py %s "\n'%cmscp_args
            txt += 'python cmscp.py %s \n'%cmscp_args
            if self.debug_wrapper==1:
                txt += 'echo "########### details of SE interaction"\n'
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    cat .SEinteraction.log\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
                txt += 'echo "#####################################"\n'
            txt += 'if [ -f $RUNTIME_AREA/resultCopyFile ] ;then\n'
            txt += '    cat $RUNTIME_AREA/resultCopyFile\n'
            txt += '    pwd\n'
            txt += 'else\n'
            ### to avoid some 70500 error ....
            txt += '    echo "ERROR ==> $RUNTIME_AREA/resultCopyFile file not found. Problem during the stageout"\n'
            txt += '    echo "RUNTIME_AREA content: "\n'
            txt += '    ls $RUNTIME_AREA \n'
            txt += '    job_exit_code=60318\n'
            txt += '    func_exit \n'
            txt += 'fi\n'
            ##########################################

            txt += 'if [ -f ${RUNTIME_AREA}/cmscpReport.sh ] ;then\n'
            txt += '    echo "-------- cat ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    cat ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    echo "-------- end of ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    source ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    source_result=$? \n'
            txt += '    if [ $source_result -ne 0 ]; then\n'
            txt += '        echo "problem with the source of cmscpReport.sh file"\n'
            txt += '        StageOutExitStatus=60307\n'
            txt += '    fi\n'
            txt += 'else\n'
            txt += '    echo "cmscpReport.sh file not found"\n'
            txt += '    StageOutExitStatus=60307\n'
            txt += 'fi\n'
            txt += 'if [ $StageOutExitStatus -ne 0 ]; then\n'
            txt += '    echo "Problem copying file to $SE $SE_PATH"\n'
            txt += '    copy_exit_status=$StageOutExitStatus \n'
            if not self.debug_wrapper==1:
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    echo "########## contents of SE interaction"\n'
                txt += '    cat .SEinteraction.log\n'
                txt += '    echo "#####################################"\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
            txt += '    job_exit_code=$StageOutExitStatus\n'
            txt += 'fi\n'
            txt += 'export TIME_STAGEOUT_END=`date +%s` \n'
            txt += 'let "TIME_STAGEOUT = TIME_STAGEOUT_END - TIME_STAGEOUT_INI" \n'
        else:
            txt += 'export TIME_STAGEOUT=-1 \n'
        return txt
コード例 #7
0
    def checkRemoteDir(self,task):

        if self.copy_data==1: 
            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, PNN, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            common.scheduler.checkRemoteDir(endpoint,eval(task['outfileBasename']))
コード例 #8
0
    def wsCopyOutput(self):
        """
        Write a CopyResults part of a job script, e.g.
        to copy produced output into a storage element.
        """
        index = int(common._db.nJobs())
        job = common.job_list[index - 1]
        jbt = job.type()

        txt = '\n'

        txt += '#\n'
        txt += '# COPY OUTPUT FILE TO SE\n'
        txt += '#\n\n'

        if int(self.copy_data) == 1:
            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, PNN, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            if self.check_RemoteDir == 1:
                self.checkRemoteDir(endpoint, jbt.outList('list'))
            txt += 'export PNN=' + PNN + '\n'
            txt += 'echo "PNN = $PNN"\n'
            txt += 'export SE=' + SE + '\n'
            txt += 'echo "SE = $SE"\n'
            txt += 'export SE_PATH=' + SE_PATH + '\n'
            txt += 'echo "SE_PATH = $SE_PATH"\n'
            txt += 'export LFNBaseName=' + lfn + '\n'
            txt += 'echo "LFNBaseName = $LFNBaseName"\n'
            txt += 'export USER='******'\n'
            txt += 'echo "USER = $USER"\n'
            txt += 'export endpoint=' + endpoint + '\n'
            txt += 'echo "endpoint = $endpoint"\n'

            txt += 'echo ">>> Copy output files from WN = `hostname` to $SE_PATH :"\n'
            txt += 'export TIME_STAGEOUT_INI=`date +%s` \n'
            txt += 'copy_exit_status=0\n'
            cmscp_args = ' --destination $endpoint --inputFileList $file_list'
            ### FEDE FOR MULTI ###
            #cmscp_args +=' --middleware $middleware --lfn $LFNBaseName %s %s '%(self.loc_stage_out,self.debugWrap)
            cmscp_args += ' --middleware $middleware --PNN $PNN --se_name $SE --for_lfn $LFNBaseName %s %s ' % (
                self.loc_stage_out, self.debugWrap)
            if self.space_token:
                cmscp_args += ' --option space_token=%s' % str(
                    self.space_token)
            txt += 'echo "python cmscp.py %s "\n' % cmscp_args
            txt += 'python cmscp.py %s \n' % cmscp_args
            if self.debug_wrapper == 1:
                txt += 'echo "which lcg-ls"\n'
                txt += 'which lcg-ls\n'
                txt += 'echo "########### details of SE interaction"\n'
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    cat .SEinteraction.log\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
                txt += 'echo "#####################################"\n'

            txt += 'if [ -f $RUNTIME_AREA/resultCopyFile ] ;then\n'
            txt += '    cat $RUNTIME_AREA/resultCopyFile\n'
            txt += '    pwd\n'
            txt += 'else\n'
            ### FEDE to avoid some 70500 error ....
            txt += '    echo "ERROR ==> $RUNTIME_AREA/resultCopyFile file not found. Problem during the stageout"\n'
            txt += '    echo "RUNTIME_AREA content: " \n'
            txt += '    ls $RUNTIME_AREA \n'
            txt += '    job_exit_code=60318\n'
            txt += '    func_exit \n'
            txt += 'fi\n'
            ################################

            txt += 'if [ -f ${RUNTIME_AREA}/cmscpReport.sh ] ;then\n'
            txt += '    echo "-------- cat ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    cat ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    echo "-------- end of ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    source ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    source_result=$? \n'
            txt += '    if [ $source_result -ne 0 ]; then\n'
            txt += '        echo "problem with the source of cmscpReport.sh file"\n'
            txt += '        StageOutExitStatus=60307\n'
            txt += '    fi\n'
            txt += 'else\n'
            txt += '    echo "cmscpReport.sh file not found"\n'
            txt += '    StageOutExitStatus=60307\n'
            txt += 'fi\n'
            txt += 'if [ $StageOutExitStatus -ne 0 ]; then\n'
            txt += '    echo "Problem copying file to $SE $SE_PATH"\n'
            txt += '    copy_exit_status=$StageOutExitStatus \n'
            if not self.debug_wrapper == 1:
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    echo "########## contents of SE interaction"\n'
                txt += '    cat .SEinteraction.log\n'
                txt += '    echo "#####################################"\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
            txt += '    job_exit_code=$StageOutExitStatus\n'
            txt += 'fi\n'
            txt += 'export TIME_STAGEOUT_END=`date +%s` \n'
            txt += 'let "TIME_STAGEOUT = TIME_STAGEOUT_END - TIME_STAGEOUT_INI" \n'
        else:
            # set stageout timing to a fake value
            txt += 'export TIME_STAGEOUT=-1 \n'
        return txt
コード例 #9
0
ファイル: Reporter.py プロジェクト: bbockelm/CRAB
    def run(self):
        """
        The main method of the class: report status of a task
        """
        common.logger.debug( "Reporter::run() called")
        task = common._db.getTask()

        msg= "--------------------\n"
        msg +=  "Dataset: %s\n"%str(task['dataset'])
        if self.cfg_params.has_key('USER.copy_data') and int(self.cfg_params['USER.copy_data'])==1:
            msg+=  "Remote output :\n"
            ## TODO: SL should come from jobDB!
            from PhEDExDatasvcInfo import PhEDExDatasvcInfo

            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            #print endpoint, lfn, SE, SE_PATH, user

            msg+=  "SE: %s %s  srmPath: %s\n"%(self.cfg_params['USER.storage_element'],SE,endpoint)

        else:
            msg += "Local output: %s\n" % task['outputDirectory']
        #print task
        possible_status = [ 'Created',
                            'Undefined',
                            'Submitting',
                            'Submitted',
                            'NotSubmitted',
                            'Waiting',
                            'Ready',
                            'Scheduled',
                            'Running',
                            'Done',
                            'Killing',
                            'Killed',
                            'Aborted',
                            'Unknown',
                            'Done (Failed)',
                            'Cleared',
                            'Retrieved'
                            ]
        eventsRead=0
        eventsRequired=0
        filesRead=0
        filesRequired=0
        lumis = []
        for job in task.getJobs():
            if (job.runningJob['applicationReturnCode']!=0 or job.runningJob['wrapperReturnCode']!=0): continue
            # get FJR filename
            fjr = self.fjrDirectory + job['outputFiles'][-1]

            jobReport = readJobReport(fjr)
            if len(jobReport) > 0:
                inputFiles = jobReport[0].inputFiles
                for inputFile in inputFiles:
                    # Accumulate the list of lum sections run over
                    for run in inputFile.runs.keys():
                        for lumi in inputFile.runs[run]:
                            lumis.append((run, lumi))
                    filesRead+=1
                    eventsRead+=int(inputFile['EventsRead'])
                #print jobReport[0].inputFiles,'\n'
            else:
                pass
                #print 'no FJR avaialble for job #%s'%job['jobId']
            #print "--------------------------"

        # Compact and write the list of successful lumis

        lumiList = LumiList(lumis = lumis)
        compactList = lumiList.getCompactList()

        lumiFilename = task['outputDirectory'] + 'lumiSummary.json'
        lumiSummary = open(lumiFilename, 'w')
        json.dump(compactList, lumiSummary)
        lumiSummary.write('\n')
        lumiSummary.close()

        msg += "Total Events read: %s\n" % eventsRead
        msg += "Total Files read: %s\n" % filesRead
        msg += "Total Jobs : %s\n" % len(task.getJobs())
        msg += "Luminosity section summary file: %s\n" % lumiFilename
        list_ID={}

        # TEMPORARY by Fabio, to be removed
        # avoid clashes between glite_slc5 and glite schedulers when a server is used
        # otherwise, -report with a server requires a local scheduler
        if self.cfg_params.get('CRAB.server_name', None) is None:
            common.logger.debug( "Reporter updating task status")
            task = common.scheduler.queryEverything(task['id'])

        for st in possible_status:
            list_ID = common._db.queryAttrRunJob({'statusScheduler':st},'jobId')
            if (len(list_ID)>0):
                msg+=  "   # Jobs: %s:%s\n"%(str(st),len(list_ID))
            pass
        msg+=  "\n----------------------------\n"
        common.logger.info(msg)


        file = common.work_space.shareDir() + 'arguments.xml'
        #print "file = ", file
        
        ### starting from the arguments.xml file, a json file containing the run:lumi
        ### that should be analyzed with the task
        inputRunLumiFileName = self.getInputRunLumi(file)

        
        ### missing lumi to analyze: starting from lumimask or from argument file
        ### calculate the difference with report.json
        ### if a lumimask is used in the crab.cfg
        if (self.cfg_params.get('CMSSW.lumi_mask')): 
            lumimask=self.cfg_params.get('CMSSW.lumi_mask')
            #print "lumimask = ", lumimask 
            self.compareJsonFile(lumimask)
        ### without lumimask    
        elif (inputRunLumiFileName):
            self.compareJsonFile(inputRunLumiFileName)
        else:
            common.logger.info("No json file to compare")
        return
コード例 #10
0
    def wsCopyOutput_comm(self, pool=None):
        """
        Write a CopyResults part of a job script, e.g.
        to copy produced output into a storage element.
        """
        index = int(common._db.nJobs())
        job = common.job_list[index - 1]
        jbt = job.type()
        txt = '\n'
        if int(self.copy_data) == 1:

            stageout = PhEDExDatasvcInfo(self.cfg_params)
            endpoint, PNN, lfn, SE, SE_PATH, user = stageout.getEndpoint()
            print "endpoint = ", endpoint

            ########################################################
            ##################### FEDE FOR CAF #####################
            cmscp_args = ''
            if common.scheduler.name().upper() == 'CAF':
                if endpoint.find('root:') != -1:
                    SE_PATH = '/' + endpoint.split('//')[2]
                    caf_protocol = 'xrootd'
                    cmscp_args += '--protocol %s ' % caf_protocol
                elif endpoint.find('rfio:') != -1:
                    if endpoint.find('path=') != -1:
                        SE_PATH = endpoint.split('path=')[1]
                    else:
                        SE_PATH = endpoint
                    caf_protocol = 'rfio'
                    cmscp_args += '--protocol %s ' % caf_protocol
            ########################################################
            ########################################################

            if self.check_RemoteDir == 1:
                self.checkRemoteDir(endpoint, jbt.outList('list'))

            txt += '#\n'
            txt += '# COPY OUTPUT FILE TO ' + SE_PATH + '\n'
            txt += '#\n\n'

            txt += 'export PNN=' + PNN + '\n'
            txt += 'echo "PNN = $PNN"\n'
            txt += 'export SE=' + SE + '\n'
            txt += 'echo "SE = $SE"\n'
            txt += 'export SE_PATH=' + SE_PATH + '\n'
            txt += 'echo "SE_PATH = $SE_PATH"\n'
            txt += 'export LFNBaseName=' + lfn + '\n'
            txt += 'echo "LFNBaseName = $LFNBaseName"\n'
            txt += 'export USER='******'\n'
            txt += 'echo "USER = $USER"\n'
            #txt += 'export endpoint='+"'"+endpoint+"'"+'\n'
            txt += 'export endpoint=' + endpoint + '\n'
            txt += 'echo "endpoint = $endpoint"\n'

            if (pool) and (pool != 'None'):
                txt += 'export STAGE_SVCCLASS=' + str(pool) + '\n'

            txt += 'echo ">>> Copy output files from WN = `hostname` to $SE_PATH :"\n'
            txt += 'export TIME_STAGEOUT_INI=`date +%s` \n'
            txt += 'copy_exit_status=0\n'
            #### FEDE added += #########
            cmscp_args += ' --destination $endpoint --inputFileList $file_list'
            #######################################################
            #######################################################
            cmscp_args += ' --middleware $middleware --PNN $PNN --se_name $SE --for_lfn $LFNBaseName %s %s ' % (
                self.loc_stage_out, self.debugWrap)
            txt += 'echo "python cmscp.py %s "\n' % cmscp_args
            txt += 'python cmscp.py %s \n' % cmscp_args
            if self.debug_wrapper == 1:
                txt += 'echo "########### details of SE interaction"\n'
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    cat .SEinteraction.log\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
                txt += 'echo "#####################################"\n'
            txt += 'if [ -f $RUNTIME_AREA/resultCopyFile ] ;then\n'
            txt += '    cat $RUNTIME_AREA/resultCopyFile\n'
            txt += '    pwd\n'
            txt += 'else\n'
            ### to avoid some 70500 error ....
            txt += '    echo "ERROR ==> $RUNTIME_AREA/resultCopyFile file not found. Problem during the stageout"\n'
            txt += '    echo "RUNTIME_AREA content: "\n'
            txt += '    ls $RUNTIME_AREA \n'
            txt += '    job_exit_code=60318\n'
            txt += '    func_exit \n'
            txt += 'fi\n'
            ##########################################

            txt += 'if [ -f ${RUNTIME_AREA}/cmscpReport.sh ] ;then\n'
            txt += '    echo "-------- cat ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    cat ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    echo "-------- end of ${RUNTIME_AREA}/cmscpReport.sh "\n'
            txt += '    source ${RUNTIME_AREA}/cmscpReport.sh\n'
            txt += '    source_result=$? \n'
            txt += '    if [ $source_result -ne 0 ]; then\n'
            txt += '        echo "problem with the source of cmscpReport.sh file"\n'
            txt += '        StageOutExitStatus=60307\n'
            txt += '    fi\n'
            txt += 'else\n'
            txt += '    echo "cmscpReport.sh file not found"\n'
            txt += '    StageOutExitStatus=60307\n'
            txt += 'fi\n'
            txt += 'if [ $StageOutExitStatus -ne 0 ]; then\n'
            txt += '    echo "Problem copying file to $SE $SE_PATH"\n'
            txt += '    copy_exit_status=$StageOutExitStatus \n'
            if not self.debug_wrapper == 1:
                txt += 'if [ -f .SEinteraction.log ] ;then\n'
                txt += '    echo "########## contents of SE interaction"\n'
                txt += '    cat .SEinteraction.log\n'
                txt += '    echo "#####################################"\n'
                txt += 'else\n'
                txt += '    echo ".SEinteraction.log file not found"\n'
                txt += 'fi\n'
            txt += '    job_exit_code=$StageOutExitStatus\n'
            txt += 'fi\n'
            txt += 'export TIME_STAGEOUT_END=`date +%s` \n'
            txt += 'let "TIME_STAGEOUT = TIME_STAGEOUT_END - TIME_STAGEOUT_INI" \n'
        else:
            txt += 'export TIME_STAGEOUT=-1 \n'
        return txt