Example #1
0
def process_3():
    for item in files:
        issue_data = read.get_issues(item)
        users = [
            max(issue_data[issue], key=lambda item: item['when'])["user"]
            for issue in issue_data.keys()
        ]
        users = Counter(users)
        graph.pie_chart(users, "Project " + item)
Example #2
0
def process_1():
	issues = {}
	for item in files:
		time_diff = []
		issue_data = read.get_issues(item)
		for issue in issue_data.keys():
			single_list = [x["when"] for x in issue_data[issue]]
			t = (max(single_list) - min(single_list)) / (60*60*24)
			if t == 0:
				continue
			time_diff.append(t)
		issues[item] = time_diff
		data = {"Less than a day": sum([1 for x in time_diff if x>=0 and x<1]),
				"2 to 5 days": sum([1 for x in time_diff if x>=1 and x<5]),
				"5 to 10 days": sum([1 for x in time_diff if x>=5 and x<10]),
				"10 days": sum([1 for x in time_diff if x>=10])
		}
		graph.pie_chart(data, "Issue open time of project "+item)
	graph.multiple_lines([issues[x] for x in issues.keys()])
Example #3
0
def process_1():
    issues = {}
    for item in files:
        time_diff = []
        issue_data = read.get_issues(item)
        for issue in issue_data.keys():
            single_list = [x["when"] for x in issue_data[issue]]
            t = (max(single_list) - min(single_list)) / (60 * 60 * 24)
            if t == 0:
                continue
            time_diff.append(t)
        issues[item] = time_diff
        data = {
            "Less than a day": sum([1 for x in time_diff if x >= 0 and x < 1]),
            "2 to 5 days": sum([1 for x in time_diff if x >= 1 and x < 5]),
            "5 to 10 days": sum([1 for x in time_diff if x >= 5 and x < 10]),
            "10 days": sum([1 for x in time_diff if x >= 10])
        }
        graph.pie_chart(data, "Issue open time of project " + item)
    graph.multiple_lines([issues[x] for x in issues.keys()])
Example #4
0
def process_2():
	neg_full = {}
	for item in files:
		milestones = read.get_milestones(item)
		milestones = {x["name"]:x["closed_at"] for x in milestones if x["closed_at"] }
		issue_data = read.get_issues(item)
		issue_diffs = []
		for issue in issue_data.keys():
			ist = max(issue_data[issue], key=lambda item:item['when'])
			if ist["milestone"] in milestones.keys():
				issue_diffs.append((milestones[ist["milestone"]] - ist["when"]) / (60*60))
		pos_diff = [x for x in issue_diffs if x>0]
		data = {"Less than an hour": sum([1 for x in pos_diff if x>=0 and x<1]),
				"2 to 5 hours": sum([1 for x in pos_diff if x>=1 and x<5]),
				"5 to 10 hours": sum([1 for x in pos_diff if x>=5 and x<10]),
				"10 hours": sum([1 for x in pos_diff if x>=10])
		}
		pos_diff_per = len(pos_diff)*100/len(issue_diffs)
		graph.pie_chart(data, str(pos_diff_per)+"\% for project "+item)
		neg_diff = [-x for x in issue_diffs if x<0]
		data = {"Less than an hour": sum([1 for x in neg_diff if x>=0 and x<1]),
				"2 to 5 hours": sum([1 for x in neg_diff if x>=1 and x<5]),
				"5 to 10 hours": sum([1 for x in neg_diff if x>=5 and x<10]),
				"10 hours": sum([1 for x in neg_diff if x>=10])
		}
		neg_diff_per = len(neg_diff)*100/len(issue_diffs)
		graph.pie_chart(data, str(neg_diff_per)+"\% for project "+item)
		neg_full["Project "+item] = neg_diff_per
	graph.pie_chart(neg_full, "Closed after milestone")
Example #5
0
def process_2():
    neg_full = {}
    for item in files:
        milestones = read.get_milestones(item)
        milestones = {
            x["name"]: x["closed_at"]
            for x in milestones if x["closed_at"]
        }
        issue_data = read.get_issues(item)
        issue_diffs = []
        for issue in issue_data.keys():
            ist = max(issue_data[issue], key=lambda item: item['when'])
            if ist["milestone"] in milestones.keys():
                issue_diffs.append(
                    (milestones[ist["milestone"]] - ist["when"]) / (60 * 60))
        pos_diff = [x for x in issue_diffs if x > 0]
        data = {
            "Less than an hour":
            sum([1 for x in pos_diff if x >= 0 and x < 1]),
            "2 to 5 hours": sum([1 for x in pos_diff if x >= 1 and x < 5]),
            "5 to 10 hours": sum([1 for x in pos_diff if x >= 5 and x < 10]),
            "10 hours": sum([1 for x in pos_diff if x >= 10])
        }
        pos_diff_per = len(pos_diff) * 100 / len(issue_diffs)
        graph.pie_chart(data, str(pos_diff_per) + "\% for project " + item)
        neg_diff = [-x for x in issue_diffs if x < 0]
        data = {
            "Less than an hour":
            sum([1 for x in neg_diff if x >= 0 and x < 1]),
            "2 to 5 hours": sum([1 for x in neg_diff if x >= 1 and x < 5]),
            "5 to 10 hours": sum([1 for x in neg_diff if x >= 5 and x < 10]),
            "10 hours": sum([1 for x in neg_diff if x >= 10])
        }
        neg_diff_per = len(neg_diff) * 100 / len(issue_diffs)
        graph.pie_chart(data, str(neg_diff_per) + "\% for project " + item)
        neg_full["Project " + item] = neg_diff_per
    graph.pie_chart(neg_full, "Closed after milestone")
Example #6
0
def process_7():
    for item in files:
        commits = read.get_commits(item)
        users = [x["user"] for x in commits]
        users = Counter(users)
        graph.pie_chart(users, "Project " + item)
Example #7
0
def process_5():
	for item in files:
		comments = read.get_comments(item)
		users = [x["user"] for x in comments]
		users = Counter(users)
		graph.pie_chart(users, "Project "+item)
Example #8
0
def process_3():
	for item in files:
		issue_data = read.get_issues(item)
		users = [max(issue_data[issue], key=lambda item:item['when'])["user"] for issue in issue_data.keys()]
		users = Counter(users)
		graph.pie_chart(users, "Project "+item)
Example #9
0
def evaluate(user_func, *args, pdf=False, png = False, timeseries=False, powerLoss=0.8, energyOutput=False, \
locations=["Mongolia", "Iceland", "Switzerland"], year="2016", printToScreen = True):
    """ Calculates effective emissions of the function

        Parameters:
            user_func: user's function + associated args
            pdf (bool): whether a PDF report should be generated
            powerLoss (float): PSU efficiency rating
            energyOutput (bool): return value also includes information about energy usage, not just function's return
            locations (list of strings): list of locations to be compared
            year (str): year of dataset to be used
            printToScreen (bool): get information in the command line

    """
    try:
        utils.setGlobal(printToScreen)
        if (utils.valid_cpu() or utils.valid_gpu()):
            result, return_value, watt_averages, files, total_time, time_baseline, reading_baseline_wattage, time_process, reading_process_wattage = energy(user_func, *args, powerLoss = powerLoss, year = year, \
                                                                            printToScreen = printToScreen, timeseries = timeseries)
            location, default_location, comparison_values, default_emissions = get_comparison_data(result, locations, year, printToScreen)
            breakdown = energy_mix(location, year = year)
            emission, state_emission = emissions(result, breakdown, location, year, printToScreen)
            if printToScreen:
                utils.log("Assumed Carbon Equivalencies")
            if printToScreen:
                utils.log("Process Energy", result)
            func_info = [user_func.__name__, *args]
            kwh_and_emissions = [result, emission, state_emission]
            if pdf:
                #pass
                report.generate(location, watt_averages, breakdown, kwh_and_emissions, \
                            func_info, comparison_values, default_emissions, default_location)
            if png:
                # generate energy mix pie chart
                energy_dict = {"Coal" : breakdown[0], "Petroleum"  : breakdown[1], "Natural Gas" : breakdown[2], "Low Carbon" : breakdown[3]}
                figtitle = "Location: " + location
                location_split = location.split()
                filename = location_split[0]
                for i in range(1, len(location_split)):
                    filename += "_" + location_split[i]
                    filename += ".png"
                if locate.in_US(location):
                    energy_dict["Oil"] = energy_dict.pop("Petroleum")
                    figtitle = figtitle + ", USA"
                graph.pie_chart(energy_dict, figtitle, filename)
                # generate emissions comparison bar charts
                png_bar_chart(location, emission, default_emissions)
            if timeseries:
                graph.timeseries(time_baseline, reading_baseline_wattage, "Baseline Wattage Timeseries")
                graph.timeseries(time_process, reading_process_wattage, "Process Wattage Timeseries")
            if energyOutput:
                return (total_time, result, return_value)
            else:
                return return_value

        else:
            utils.log("The energy-usage package only works on Linux kernels "
                      "with Intel processors that support the RAPL interface and/or machines with"
        " an Nvidia GPU. Please try again on a different machine.")
    except Exception as e:
        print("\n" + str(e))