Пример #1
0
def sample(name,
           version=None,
           n_events = -1,
           format = ("ICF", 2),
           path="/vols/cms02/as1604/PhysicsUtils/SampleDB2/store",
	   node = "IC_DCACHE"
	):
    store = openStore(path)
    if not store.Exists(name+"/_sample_.json"):
        print "Sample '%s' not found" % name
        sys.exit(1)
    samp = store.Get(name+"/_sample_.json")
    vers = None
    if version is not None:
        if not store.Exists("%s/%s.json" % (name, version)):
            print "No version '%s' for sample '%s'" % (version,name)
            sys.exit(1)
        vers = store.Get("%s/%s.json" % (name, version))
    else:
        if not store.Exists("%s/%s.json" % (name, samp.latest)):
            print "Oops the sample specified latest version '%s' cannot be found" % samp.latest
        vers = store.Get("%s/%s.json" % (name, sampl.latest))
    ps = PSet(Format = format)
    if samp.cross_section == -1:
        ps._quiet_set("Weight", 1.0)
    else:
        ps._quiet_set("CrossSection", samp.cross_section)
    total_events = 0
    files = []
    for b in vers.blocks:
	if b["node"] != node:
	    continue
        try:
            for f in b["files"]:
                if f["events"] == -1:
                    continue
                files.append(str(se_path_to_url(f["path"], "dcap")))
                total_events += f["events"]
                if n_events != -1 and total_events >= n_events:
                    raise BreakMeOut
        except BreakMeOut:
            break
    ps._quiet_set("File", files)
    name = samp.name[1:].replace("/", "_")
    if version is not None:
	name += "_"+vers.name
    ps._quiet_set("Name", str(name))
    ps._quiet_set("Events", total_events)
    return ps
Пример #2
0
#!/usr/bin/env python
from store import openStore, JSONCancelError
from config import conf
from utils import prompt_retry, prompt_type, confirm_create, InvalidChoiceError
import readline

@prompt_retry
def prompt_sample_name(store):
    name = raw_input("Sample Name:")
    if not name.startswith("/"):
        print "Sample name should begin with /"
        raise InvalidChoiceError
    if store.Exists(name+"/_sample_.json"):
        print "Sample already exists"
        raise InvalidChoiceError
    return name

if __name__ == "__main__":
    store = openStore(conf["path"])
    name = prompt_sample_name(store)
    with store.Create(name + "/_sample_.json") as j:
        j.name = name
        j.dbs = prompt_type("DBS Path:", str, "")
        j.cross_section = prompt_type("Cross Section:", float, -1)
        j.events = prompt_type("Events:", int, -1)
        if not confirm_create(j):
            raise JSONCancelError


Пример #3
0
    if p.sel_idx == -1:
        raise InvalidChoiceError
    else:
        return rows[p.sel_idx]

@prompt_retry
def prompt_subjob(db_path, subjobs):
    p = Pager("Please choose a subjob", ["{0:<40}".format(s) for s in subjobs])
    if p.sel_idx == -1:
        raise InvalidChoiceEror
    else:
        return p.sel_idx


if __name__ == "__main__":
    store = openStore(conf["path"], lock=True)
    sample = prompt_sample(store)
    extend = prompt_version(store, sample)
    blocks = []
    while True:
        j = prompt_job(conf["db_path"])
        path = j[3]
        sub = 0
        if len(j[1].split(",")) > 1:
            sub = prompt_subjob(conf["db_path"], j[1].split(","))
            path = j[3] + '/' + string.replace(j[1][1:], '/', '.')
        print "Scan path '%s for files?" % path
        files = []
        file_counts = {}
        if raw_input() == "y":
            files.extend(utils.se_lcg_ls(utils.se_path_to_url(path)))