Beispiel #1
0
def setup(job, jobSite, thisExperiment):
    """ prepare the setup and get the run command list """

    # start setup time counter
    t0 = time.time()

    ec = 0
    runCommandList = []

    # split up the job parameters to be able to loop over the tasks
    jobParameterList = job.jobPars.split("\n")
    jobHomePackageList = job.homePackage.split("\n")
    jobTrfList = job.trf.split("\n")
    jobAtlasRelease = getAtlasRelease(job.atlasRelease)

    tolog("Number of transformations to process: %s" % len(jobParameterList))
    if len(jobParameterList) > 1:
        multi_trf = True
    else:
        multi_trf = False

    # verify that the multi-trf job is setup properly
    ec, job.pilotErrorDiag, jobAtlasRelease = RunJobUtilities.verifyMultiTrf(jobParameterList, jobHomePackageList, jobTrfList, jobAtlasRelease)
    if ec > 0:
        return ec, runCommandList, job, multi_trf
            
    os.chdir(jobSite.workdir)
    tolog("Current job workdir is %s" % os.getcwd())
    
    # setup the trf(s)
    _i = 0
    _stdout = job.stdout
    _stderr = job.stderr
    _first = True
    for (_jobPars, _homepackage, _trf, _swRelease) in map(None, jobParameterList, jobHomePackageList, jobTrfList, jobAtlasRelease):
        tolog("Preparing setup %d/%d" % (_i + 1, len(jobParameterList)))

        # reset variables
        job.jobPars = _jobPars
        job.homePackage = _homepackage
        job.trf = _trf
        job.atlasRelease = _swRelease
        if multi_trf:
            job.stdout = _stdout.replace(".txt", "_%d.txt" % (_i + 1))
            job.stderr = _stderr.replace(".txt", "_%d.txt" % (_i + 1))

        # post process copysetup variable in case of directIn/useFileStager
        _copysetup = readpar('copysetup')
        _copysetupin = readpar('copysetupin')
        if "--directIn" in job.jobPars or "--useFileStager" in job.jobPars or _copysetup.count('^') == 5 or _copysetupin.count('^') == 5:
            # only need to update the queuedata file once
            if _first:
                RunJobUtilities.updateCopysetups(job.jobPars)
                _first = False

        # setup the trf
        ec, job.pilotErrorDiag, cmd, job.spsetup, job.JEM, job.cmtconfig = thisExperiment.getJobExecutionCommand(job, jobSite, pilot_initdir)
        if ec > 0:
            # setup failed
            break

        # add the setup command to the command list
        runCommandList.append(cmd)
        _i += 1

    job.stdout = _stdout
    job.stderr = _stderr
    job.timeSetup = int(time.time() - t0)
    tolog("Total setup time: %d s" % (job.timeSetup))

    return ec, runCommandList, job, multi_trf