def main():

    if args.submitter == 'condor':
        from Firefighter.ffConfig.condorConfigBuilder import configBuilder
        from Firefighter.piedpiper.utils import get_voms_certificate

        os.system(
            "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf `basename ${CMSSW_BASE}`.tar.gz -C ${CMSSW_BASE}/.. `basename ${CMSSW_BASE}`"
        )
        get_voms_certificate()
    elif args.submitter == 'crab':
        from Firefighter.ffConfig.crabConfigBuilder import configBuilder

    for ds in tosubd_:
        tosubdff = yaml.load(open(join(os.getenv('CMSSW_BASE'), ds)),
                             Loader=yaml.Loader)

        eventRegion_ = 'control'
        if 'sigmc' in ds or 'bkgmc' in ds:
            eventRegion_ = 'all'
        cb = configBuilder(tosubdff,
                           eventRegion=eventRegion_,
                           ffConfigName="ffNtupleFromAOD_cfg.py",
                           outbase="/store/group/lpcmetx/SIDM/ffNtuple/")
        for c in cb.build():
            configBuilder.submit(c)
Example #2
0
def main():

    if args.submitter == 'condor':
        from Firefighter.ffConfig.condorConfigBuilder import configBuilder
        from Firefighter.piedpiper.utils import get_voms_certificate

        os.system(
            "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf `basename ${CMSSW_BASE}`.tar.gz -C ${CMSSW_BASE}/.. `basename ${CMSSW_BASE}`"
        )
        get_voms_certificate()
    elif args.submitter == 'crab':
        from Firefighter.ffConfig.crabConfigBuilder import configBuilder

    ## customize kwargs for configBuilder
    customize = dict(
        eventRegion='all',
        ffConfigName='ffNtupleFromAOD_trigger_cfg.py',
        outbase="/store/group/lpcmetx/SIDM/ffNtuple4trigger/",
        denomTriggerPaths=['HLT_Mu17', 'HLT_IsoMu24'],
    )

    for ds in tosubd_:
        tosubdff = yaml.load(open(join(os.getenv("CMSSW_BASE"), ds)),
                             Loader=yaml.Loader)

        cb = configBuilder(tosubdff, **customize)
        for c in cb.build():
            configBuilder.submit(c)
def test_condor_submit():
    from Firefighter.ffConfig.condorConfigBuilder import configBuilder
    from Firefighter.piedpiper.utils import get_voms_certificate

    # test_dataset = ffds_sigmc[0]
    # test_dataset = ffds_bkgmc[0]
    # test_dataset = ffds_data[2]

    test_dataset["maxEvents"] = 100
    cb = configBuilder(test_dataset,
                       outbase="/store/user/wsi/SIDM/ffNtuple/test/",
                       eventRegion="all")
    print("\n### test condor submit ###")

    os.system(
        "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf `basename ${CMSSW_BASE}`.tar.gz -C ${CMSSW_BASE}/.. `basename ${CMSSW_BASE}`"
    )
    get_voms_certificate()

    for c in cb.build():
        print(open(c).read())
        configBuilder.submit(c)
def buildCommonBaseArgs(args):

    if args.submitter == 'condor':
        from Firefighter.ffConfig.condorConfigBuilder import configBuilder
        from Firefighter.piedpiper.utils import get_voms_certificate

        os.system("cd $CMSSW_BASE/src/Firefighter && scram b -j12 && cd -")
        os.system(
            "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf `basename ${CMSSW_BASE}`.tar.gz -C ${CMSSW_BASE}/.. `basename ${CMSSW_BASE}`"
        )
        os.system("cd $CMSSW_BASE/src/Firefighter && scram b -j12 && cd -"
                  )  # ensure tarball is copied to $CMSSW_base/python
        get_voms_certificate()
    elif args.submitter == 'crab':
        from Firefighter.ffConfig.crabConfigBuilder import configBuilder

    ## set event region
    eventRegion_ = args.eventregion

    ## base submitter config settings
    cbkwargs = dict(
        eventRegion=eventRegion_,
        ffConfigName='ffNtupleFromAOD_v2_cfg.py',
        outbase='/store/group/lpcmetx/SIDM/ffNtupleV2/',
        unitsPerJob=args.unitsperjob,
    )
    ## update CMSSW config file and outputbase for **skim** jobs
    if args.jobtype == 'skim':
        cbkwargs.update(
            dict(
                ffConfigName='ffFullSkimFromAOD_cfg.py',
                outbase='/store/group/lpcmetx/SIDM/Skim/',
            ))
    ## update unitsPerJob for ntuple jobs with skimmed files as source
    if args.jobtype == 'ntuplefromskim':
        cbkwargs['unitsPerJob'] = 50
        cbkwargs['outbase'] = '/store/group/lpcmetx/SIDM/ffNtupleV2/Skim/'

    if args.submitter == 'crab' and args.ignorelocality == False:
        cbkwargs['ignoreLocality'] = False

    if eventRegion_ in ['proxy', 'muonType']:
        cbkwargs['outbase'] += '{}/'.format(eventRegion_)

    ## **dummy** jobs
    if args.jobtype == 'dummy':
        cbkwargs = dict(
            ffConfigName='ffNtupleDummy_cfg.py',
            maxMemory=2000,
            workArea=join(
                os.getenv("CMSSW_BASE"),
                "src/Firefighter/ffConfig/crabGarage/dummyjobs",
                time.strftime("%y%m%d"),
            ),
            outbase="/store/group/lpcmetx/SIDM/dummy/",
        )

    ## **triggerStudy** jobs
    if args.jobtype == 'triggerStudy':
        cbkwargs.update(
            dict(
                ffConfigName='ffNtupleFromAOD_trigger_v2_cfg.py',
                outbase='/store/group/lpcmetx/SIDM/TriggerStudy/',
            ))

    return cbkwargs
def submit(dkind, submitter="condor", jobtype="ntuple"):

    ## common kwargs for config builders
    commonCBkwargs = dict(
        ffConfigName='ffNtupleFromAOD_v2_cfg.py',
        outbase='/store/group/lpcmetx/SIDM/ffNtupleV2/',
    )
    if jobtype == 'skim':
        commonCBkwargs = dict(
            ffConfigName='ffFullSkimFromAOD_cfg.py',
            outbase='/store/group/lpcmetx/SIDM/Skim/',
        )
    if jobtype == 'ntuplefromskim':
        commonCBkwargs['unitsPerJob'] = 50
        commonCBkwargs[
            'outbase'] = '/store/group/lpcmetx/SIDM/ffNtupleV2/Skim/'
    if args.submitter == 'crab' and args.ignorelocality == False:
        commonCBkwargs['ignoreLocality'] = False

    _eventregion = args.eventregion  #"all"
    if _eventregion in ['proxy', 'muonType']:
        commonCBkwargs['outbase'] += '{}/'.format(_eventregion)

    print('*** common config builder kwargs ***')
    for k, v in commonCBkwargs.items():
        print('{:20}{}'.format(k, v))
    print('*** **************************** ***')

    if not query_yes_no('Is args set correctly?'):
        sys.exit('No? Okay, exiting..')

    ## split by submitter
    if submitter == "crab":
        from Firefighter.ffConfig.crabConfigBuilder import configBuilder as CrabCB

        coremsg = "submit {} jobs for {} to crab".format(jobtype, dkind)
        print(buildbanner(coremsg))

        for i, ds in enumerate(ffds[dkind]):
            print("----> submitting {0}/{1}".format(i + 1, len(ffds[dkind])))
            cb = CrabCB(ds, eventRegion=_eventregion, **commonCBkwargs)
            for c in cb.build():
                CrabCB.submit(c)

    elif submitter == "condor":
        # submit with condor, for those not available on disk, submit to crab
        # to trigger transfer, dump those dataset as a text file
        from Firefighter.ffConfig.condorConfigBuilder import configBuilder as CondorCB
        from Firefighter.ffConfig.crabConfigBuilder import configBuilder as CrabCB
        from Firefighter.ffConfig.datasetUtils import get_storageSites
        from Firefighter.piedpiper.utils import get_voms_certificate

        coremsg = "submit {} jobs for {} to condor(crab)".format(
            jobtype, dkind)
        print(buildbanner(coremsg))

        os.system("cd $CMSSW_BASE/src/Firefighter && scram b -j12 && cd -")
        os.system(
            "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf `basename ${CMSSW_BASE}`.tar.gz -C ${CMSSW_BASE}/.. `basename ${CMSSW_BASE}`"
        )
        os.system("cd $CMSSW_BASE/src/Firefighter && scram b -j12 && cd -"
                  )  # ensure tarball is copied to $CMSSW_base/python
        get_voms_certificate()

        if dkind == "bkgmc":  # only background mc has dataset not on disk
            diskGhosts = []
            for i, ds in enumerate(ffds[dkind]):
                print("----> submitting {0}/{1}".format(
                    i + 1, len(ffds[dkind])))
                if args.jobtype == 'ntuplefromskim' or any(
                        map(lambda d: get_storageSites(d),
                            ds["datasetNames"])):  # condor, this way
                    cb = CondorCB(ds,
                                  eventRegion=_eventregion,
                                  **commonCBkwargs)
                    for c in cb.build():
                        CondorCB.submit(c)
                else:  # crab, this way
                    diskGhosts.append(BKGMC_L[i])
                    cb = CrabCB(ds, eventRegion=_eventregion, **commonCBkwargs)
                    for c in cb.build():
                        CrabCB.submit(c)
            if diskGhosts:
                print(
                    "@@@ {0} bkgmc ffDataSets not available on disk, thus submitted to CRAB."
                    .format(len(diskGhosts)))
                for ffd in diskGhosts:
                    print("@", ffd)
                logfn = "diskGhosts_{}.log".format(time.strftime("%y%m%d"))
                with open(logfn, "w") as outf:
                    outf.write(json.dumps(diskGhosts, indent=4))
                print("@@@ saved at {}.".format(logfn))
        else:
            for i, ds in enumerate(ffds[dkind]):
                print("----> submitting {0}/{1}".format(
                    i + 1, len(ffds[dkind])))
                cb = CondorCB(ds, eventRegion=_eventregion, **commonCBkwargs)
                for c in cb.build():
                    CondorCB.submit(c)
    else:
        # you should not step into this darkness gently
        sys.exit("submitter *{}* unknown. exit!".format(submitter))
Example #6
0
                              .replace('FFSUPERCONFIGDIR', jobpath)\
                              .replace('JOBIDLIST', str(tuple(jobids)) )
    # print(resubjdl_)
    with open(resubjdlfile, 'w') as outf:
        outf.write(resubjdl_)
    return resubjdlfile


if __name__ == "__main__":

    JOBDIR = '/uscms/home/wsi/nobackup/lpcdm/CMSSW_10_2_14/src/Firefighter/ffConfig/condorGarage/190703/TTJets_TuneCP5_13TeV-madgraphMLM-pythia8/RunIIAutumn18DRPremix-102X_upgrade2018_realistic_v15-v1'
    # JOBDIR = '/uscms/home/wsi/nobackup/lpcdm/CMSSW_10_2_14/src/Firefighter/ffConfig/condorGarage/190701/DoubleMuon/Run2018A-17Sep2018-v2'

    ## get error job ids
    errorjobids = getErrorJobId(JOBDIR)

    ## rename ffSuperConfig (temporately)
    # renameSuperconfigByIds(JOBDIR, errorjobids)

    # ## write resubmit exec file and condor jdl
    rebuildExecFile(JOBDIR)
    resubjdl = rebuildCondorJdl(JOBDIR, errorjobids)

    # ## resubmit!
    os.system(
        "tar -X EXCLUDEPATTERNS --exclude-vcs -zcf ${CMSSW_VERSION}.tar.gz -C ${CMSSW_BASE}/.. ${CMSSW_VERSION}"
    )
    get_voms_certificate()
    print("$condor_submit", resubjdl)
    os.system("condor_submit {0}".format(resubjdl))