Exemplo n.º 1
0
def ehosts(args, bhostsargs):
    r = ""
    select = []
    # get selects from -R
    if args.R:
        match = re.search("select\[(.*?)\]", args.R)
        if match:
            select += match.groups()
        r = re.sub("select\[.*\]", "", args.R)

    # add selects
    if args.aices:
        select += ("aices",)
    if args.model:
        select += ("model==" + args.model,)

    if len(select):
        select = " && ".join("(" + s + ")" for s in select)
        r = (r + " select[" + select + "]").strip()

    if len(r):
        bhostsargs += ["-R", r]

    if sys.stdout.isatty():
        print("Reading host list from LSF ...", end="\r")
    sys.stdout.flush()
    hostlist = Hostlist(bhostsargs)
    if sys.stdout.isatty():
        print("                              ", end="\r")
    hostlist.sort()
    hostlist.display(wide=args.wide, parallel=not args.nopar)
Exemplo n.º 2
0
def ehosts(args, bhostsargs):
    r = ""
    select = []
    # get selects from -R
    if args.R:
        match = re.search("select\[(.*?)\]", args.R)
        if match:
            select += match.groups()
        r = re.sub("select\[.*\]", "", args.R)

    # add selects
    if args.aices:
        select += ("aices", )
    if args.model:
        select += ("model==" + args.model, )

    if len(select):
        select = " && ".join("(" + s + ")" for s in select)
        r = (r + " select[" + select + "]").strip()

    if len(r):
        bhostsargs += ["-R", r]

    if sys.stdout.isatty():
        print("Reading host list from LSF ...", end="\r")
    sys.stdout.flush()
    hostlist = Hostlist(bhostsargs)
    if sys.stdout.isatty():
        print("                              ", end="\r")
    hostlist.sort()
    hostlist.display(wide=args.wide, parallel=not args.nopar)
Exemplo n.º 3
0
def ejobs(args, bjobsargs):
    if args.pending:
        args.group = "PENDING REASONS"
    if args.aices:
        bjobsargs = ["-G", "p_aices"] + bjobsargs

    if sys.stdout.isatty():
        print("Reading job list from LSF ...", end="\r")
    sys.stdout.flush()
    joblist = Joblist(bjobsargs)
    if sys.stdout.isatty():
        print("                             ", end="\r")
    if args.pending:
        joblists = joblist.groupby("Status")
        if "PEND" in joblists:
            joblist = joblists["PEND"]
        else:
            joblist = Joblist()
    joblists = joblist.groupby(args.group)

    if not args.pending:
        for group, joblist in joblists.items():
            if group:
                groupn = group
                if args.group == "User":
                    groupn = joblist[0]["Userstr"]
                title = "{} = {} [{}]".format(args.group, groupn, len(joblist))
            else:
                title = None
            joblist.display(args.long, args.wide, title,
                            parallel=not args.nopar)
        return
    for reasons in sorted(joblists.keys(), key=len):
        pendjobs = joblists[reasons]
        if len(reasons) == 1 and reasons[0][1] is True:
            if reasons[0][0] in (
                "New job is waiting for scheduling",
                "Dependency condition invalid or never satisfied",
                "The schedule of the job is postponed for a while",
            ):
                title = "{} [{}]".format(reasons[0][0], len(pendjobs))
                pendjobs.display(args.long, args.wide, title,
                                 parallel=not args.nopar)
                continue
        lists = {}
        resgrouped = pendjobs.groupby("Requested Resources")
        for res, rlist in resgrouped.iteritems():
            hostgrouped = rlist.groupby("Specified Hosts")
            for hosts, hlist in hostgrouped.iteritems():
                lists[res, hosts] = hlist
        for case, casejobs in lists.iteritems():
            title = "[{}]".format(len(casejobs))
            casejobs.display(args.long, args.wide, title,
                             parallel=not args.nopar)
            print()
            print("Pending reasons:")
            cs = {
                "Running an exclusive job": "y",
                "Job's requirement for exclusive execution not satisfied": "y",
                "An exclusive job has reserved the host": "y",
                "Job slot limit reached": "y",
                "Not enough processors to meet the job's spanning requirement":
                "y",
                "Not enough slots or resources for whole duration of the job":
                "r",
                "Not enough hosts to meet the job's spanning requirement": "r",
            }
            for reason, count in reasons:
                s = reason
                if reason in cs:
                    s = color(reason, cs[reason])
                if count is True:
                    print("           " + s)
                else:
                    print("    {:>4}  ".format(count) + s)
            if case[1]:
                req = [case[1]]
            else:
                req = case[0]
                req = re.sub(" && \(hostok\)", "", req)
                req = re.sub(" && \(mem>\d+\)", "", req)
                req = ["-R", req]
            print("Potential hosts:")
            if sys.stdout.isatty():
                print("Reading host list from LSF ...", end="\r")
            sys.stdout.flush()
            hl = Hostlist(req)
            hl.sort()
            hl.display(wide=args.wide, indent="    ", parallel=not args.nopar)
            hl = {h["HOST"]: h for h in Hostlist(req)}
Exemplo n.º 4
0
def ejobs(args, bjobsargs):
    if args.pending:
        args.group = "PENDING REASONS"
    if args.aices:
        bjobsargs = ["-G", "p_aices"] + bjobsargs

    if sys.stdout.isatty():
        print("Reading job list from LSF ...", end="\r")
    sys.stdout.flush()
    joblist = Joblist(bjobsargs)
    if sys.stdout.isatty():
        print("                             ", end="\r")
    if args.pending:
        joblists = joblist.groupby("Status")
        if "PEND" in joblists:
            joblist = joblists["PEND"]
        else:
            joblist = Joblist()
    joblists = joblist.groupby(args.group)

    if not args.pending:
        for group, joblist in joblists.items():
            if group:
                groupn = group
                if args.group == "User":
                    groupn = joblist[0]["Userstr"]
                title = "{} = {} [{}]".format(args.group, groupn, len(joblist))
            else:
                title = None
            joblist.display(args.long, args.wide, title, parallel=not args.nopar)
        return
    for reasons in sorted(joblists.keys(), key=len):
        pendjobs = joblists[reasons]
        if len(reasons) == 1 and reasons[0][1] is True:
            if reasons[0][0] in (
                "New job is waiting for scheduling",
                "Dependency condition invalid or never satisfied",
                "The schedule of the job is postponed for a while",
            ):
                title = "{} [{}]".format(reasons[0][0], len(pendjobs))
                pendjobs.display(args.long, args.wide, title, parallel=not args.nopar)
                continue
        lists = {}
        resgrouped = pendjobs.groupby("Requested Resources")
        for res, rlist in resgrouped.iteritems():
            hostgrouped = rlist.groupby("Specified Hosts")
            for hosts, hlist in hostgrouped.iteritems():
                lists[res, hosts] = hlist
        for case, casejobs in lists.iteritems():
            title = "[{}]".format(len(casejobs))
            casejobs.display(args.long, args.wide, title, parallel=not args.nopar)
            print()
            print("Pending reasons:")
            cs = {
                "Running an exclusive job": "y",
                "Job's requirement for exclusive execution not satisfied": "y",
                "An exclusive job has reserved the host": "y",
                "Job slot limit reached": "y",
                "Not enough processors to meet the job's spanning requirement": "y",
                "Not enough slots or resources for whole duration of the job": "r",
                "Not enough hosts to meet the job's spanning requirement": "r",
            }
            for reason, count in reasons:
                s = reason
                if reason in cs:
                    s = color(reason, cs[reason])
                if count is True:
                    print("           " + s)
                else:
                    print("    {:>4}  ".format(count) + s)
            if case[1]:
                req = [case[1]]
            else:
                req = case[0]
                req = re.sub(" && \(hostok\)", "", req)
                req = re.sub(" && \(mem>\d+\)", "", req)
                req = ["-R", req]
            print("Potential hosts:")
            if sys.stdout.isatty():
                print("Reading host list from LSF ...", end="\r")
            sys.stdout.flush()
            hl = Hostlist(req)
            hl.sort()
            hl.display(wide=args.wide, indent="    ", parallel=not args.nopar)
            hl = {h["HOST"]: h for h in Hostlist(req)}