Example #1
0
def qstat(args):
    clusters, pending_jobs = build_cluster(args.options, args.user_pattern)
    pending_jobs = pending_jobs if args.pending_jobs else None

    if not (args.cluster_only or args.expand or args.full):
        print_status(clusters, pending_jobs, args.watch)

    elif args.required_memory:
        jobids = flatten(c.get_jobids() for c in clusters)
        if isinstance(args.required_memory, str):
            vmem_list = get_resource_option(jobids, args.required_memory)
        else:
            vmem_list = get_resource_option(jobids)

        for cluster in clusters:
            add_host_info(cluster.queues)
            cluster.set_host_info()
            cluster.set_vmem(vmem_list)
            cluster.set_queue_printlen()

    elif args.physical_memory or args.swapped_memory:
        for cluster in clusters:
            add_host_info(cluster.queues)
            cluster.set_host_info()
            cluster.set_queue_printlen()

    if args.cluster_only:
        print_cluster_status(clusters)
    elif args.expand or args.full:
        print_full_status(clusters, pending_jobs, not args.no_sort, args.full)
Example #2
0
def qstat(args):
    clusters, pending_jobs = build_cluster(args.options, args.user_pattern)
    pending_jobs = pending_jobs if args.pending_jobs else None

    if not (args.cluster_only or args.expand or args.full):
        print_status(clusters, pending_jobs, args.watch)

    elif args.required_memory:
        jobids = flatten(c.get_jobids() for c in clusters)
        if isinstance(args.required_memory, str):
            vmem_list = get_resource_option(jobids, args.required_memory)
        else:
            vmem_list = get_resource_option(jobids)

        for cluster in clusters:
            add_host_info(cluster.queues)
            cluster.set_host_info()
            cluster.set_vmem(vmem_list)
            cluster.set_queue_printlen()

    elif args.physical_memory or args.swapped_memory:
        for cluster in clusters:
            add_host_info(cluster.queues)
            cluster.set_host_info()
            cluster.set_queue_printlen()

    if args.cluster_only:
        print_cluster_status(clusters)
    elif args.expand or args.full:
        print_full_status(clusters, pending_jobs, not args.no_sort, args.full)
Example #3
0
def main():
    setup_html()
    print_status('Bot Framework SDK Github Report')
    print_status('===============================')
    g = Github(GIT_PERSONAL_TOKEN)

    # Filter out people associated with Microsoft
    microsoft_members = get_msorg_members(g) + MICROSFT_EMPLOYEES

    # Output for UI
    OUTPUT = OuputIssuesJson()

    for repo in REPOS:
        repo_name = repo if '/' in repo else f'microsoft/{repo}'
        repo = g.get_repo(repo_name)

        # Output for UI
        repository_output_element = OutputRepository(repo_name)
        OUTPUT.repositories.append(repository_output_element)

        # Set state='closed' to find closed issues that weren't tagged properly
        # Note: repo.get_issues() underlying library appears to have a bug where
        # `start` and `labels` don't seem to work properly, so we do it manually here.
        # Super inefficient on the wire!
        open_issues = [issue for issue in repo.get_issues(state='open')\
            if issue.created_at >= START_DATE and not filter_azure(repo_name, issue)]
        print_status(f'Repo: {repo.full_name}:')
        print_status(f'   Total open issues after {START_DATE} : {len(open_issues)}', 'tab1')

        # Filter out adaptive issues
        open_issues = [issue for issue in open_issues if not filter_adaptive_label(issue) and not filter_exempt_from_dri_label(issue)]
        user_filtered = True
        if repo.name in BYPASS_USERFILTER_REPOS:
            user_filtered_issues = [issue for issue in open_issues if not issue.pull_request]
            user_filtered = False
        else:
            user_filtered_issues = [issue for issue in open_issues if (not issue.user.login.strip().lower() in \
                microsoft_members and not issue.pull_request)]

        if repo_name.lower() != 'azure/azure-cli':
            no_bs_cr_label = [issue for issue in user_filtered_issues if not filter_bot_service_label(issue) or \
                not filter_customer_reported_label(issue)]

            if no_bs_cr_label:
                print_status(f'   No "Bot Services/Customer Reported": Count: {len(no_bs_cr_label)}', 'tab1')
                for issue in no_bs_cr_label:
                    if user_filtered or not filter_milestone_label(issue):
                        print_issue(issue)
                        repository_output_element.issues.append(OutputIssue("no_bot_services", issue))

            no_crt_label = [issue for issue in user_filtered_issues if not filter_customer_replied_label(issue)]
            if no_crt_label:
                print_status(f'   No "Customer Replied": Count: {len(no_crt_label)}', 'tab1')
                for issue in no_crt_label:
                    if user_filtered in microsoft_members or not filter_milestone_label(issue):
                        print_issue(issue)
                        repository_output_element.issues.append(OutputIssue("no_customer_reply", issue))

            # Start looking at stale (untouched with no comments) issues
            stale_days = 10
            stale_customer_issues = [add_last_comment(issue, stale_days) \
                for issue in user_filtered_issues if not filter_stale_customer_issues(issue, days_old=stale_days)]
            stale_no_nones = [i for i in stale_customer_issues if i]
            stale_descending = sorted(stale_no_nones, key=lambda issue: issue.last_comment, reverse=False)
            if stale_descending:
                print_status(f'   90-day stale : Customer issues not touched in more than {stale_days} days: Count: {len(stale_descending)}', 'tab1')
                print_status(f'      Last touched by {Fore.GREEN}CUSTOMER{Style.RESET_ALL}:', 'tab2')
                for issue in stale_descending:
                    if last_touched_by_microsoft(issue, microsoft_members):
                        print_stale_issue(issue)
                    repository_output_element.issues.append(OutputIssue("last_touch_customer", issue))
                print_status(f'      Last touched by {Fore.GREEN}MICROSOFT{Style.RESET_ALL}:', 'tab1')
                for issue in stale_descending:
                    if not last_touched_by_microsoft(issue, microsoft_members):
                        print_stale_issue(issue)
                    repository_output_element.issues.append(OutputIssue("last_touch_microsoft", issue))
        else:
            # azure/azure-cli just print active issues.
            for issue in user_filtered_issues:
                print_issue(issue)
                repository_output_element.issues.append(OutputIssue("azure_cli", issue))

    # Write JSON output for UI
    # OUTPUT.write_output()
    OUTPUT_FILE.write("</body></html>")
    OUTPUT_FILE.close()

    if sys.platform == 'win32':
        os.system('start "" "' + FILE_NAME + '"')
    else:
        os.system('open ' + FILE_NAME)
Example #4
0
def print_detail(args, settings):
    j = Job("12345", "0.0", "job12345", settings["username"], 'r', "01/01/2015", "12:34:56", "6")
    jo = Job("12344", "0.0", "job12344", "user01", 'r', "01/01/2015", "12:34:00", "4")
    jp = Job("12346", "0.0", "job12346", "user02", 'qw', "01/01/2015", "12:35:28", "10")
    ja = Job("12340", "0.0", "job12340", "user03", 'r', "01/01/2015", "12:30:11", "20")

    q = Queue("cluster01.q@host001", "BIP", "6/10/20", "4.71", "lx-amd64")
    qo = Queue("cluster01.q@host002", "BIP", "0/0/20", "0.03", "lx-amd64")
    q1 = Queue("cluster02.q@host003", "BIP", "0/20/20", "21.38", "lx-amd64", "a")
    q2 = Queue("cluster02.q@host004", "BIP", "0/0/20", "0.13", "lx-amd64", "d")

    c = Cluster("cluster01.q", "4.38", "10", "0", "40", "40", "0", "0")
    c2 = Cluster("cluster02.q", "4.38", "10", "0", "40", "40", "0", "0")

    q.set_job(j)
    q.set_job(jo)
    q1.set_job(ja)
    c.set_queue(q)
    c.set_queue(qo)
    c2.set_queue(q1)
    c2.set_queue(q2)

    for job in (j, jo, jp, ja):
        if args.user_pattern.match(job.user):
            job.visible()

    q.set_host_info("20", "2", "10", "20", "4.71", "64G", "21.2G", "7.9G", "108M")
    q1.set_host_info("20", "2", "10", "20", "21.38", "64G", "57.4G", "11.3G", "3.1G")
    q2.set_host_info("20", "2", "10", "20", "0.13", "64G", "461.4M", "3.1G", "51M")
    qo.set_host_info("20", "2", "10", "20", "0.03", "64G", "203.9M", "4.1G", "71M")

    c.set_host_info()
    c2.set_host_info()

    c.set_vmem({"12344": "3G", "12345": "4G"})
    c2.set_vmem({"12340": "3G"})

    c.set_queue_printlen()
    c2.set_queue_printlen()

    pj = [jp] if args.pending_jobs else []

    print "preview:"
    print
    print_status([c, c2], pj)
    print
    print
    print "full format preview (-e/-f):"
    print
    print "<cluster> used/total slot (rate)"
    print "\t<queuename> qtype resv/used/tot load_avg " + (("use/" if args.physical_memory else '') +
                                                           ("req/" if args.required_memory else '') +
                                                           ("tot mem" if args.required_memory or args.physical_memory else '') +
                                                           ("  use/tot swap" if args.swapped_memory else '') +
                                                           "  arch states")
    print
    print_full_status([c, c2], pj, not args.no_sort, True)
    print
    print
    print "cluster status preview (-c):"
    print
    print_cluster_status([c, c2])
    print
    print

    print "current default settings (edit ~/.cqstat_config.json to change these defaults):"
    l = max(map(len, settings))
    for k, v in sorted(settings.items()):
        print "  {}\t{}".format(k.ljust(l+4), repr(v))