Example #1
0
def create_charts(req_body):
    details = req_body['details']

    success = True
    response = ''

    if 'create_pie_chart' in details and details['create_pie_chart'] and details['pie_data']:
        pie_response = create_pie_chart(details['pie_data'], BASE_PRESENTATION)
        success = success and pie_response[0]
        response = "{pr}".format(response=response, pr=pie_response[1])

    if 'create_bar_chart' in details and details['create_bar_chart'] and details['bar_data']:
        bar_response = create_bar_chart(details['bar_data'], BASE_PRESENTATION)
        success = success and bar_response[0]
        response = "{response}. {br}".format(response=response, br=bar_response[1])

    if 'create_line_chart' in details and details['create_line_chart'] and details['line_data']:
        line_response = create_line_chart(details['line_data'], BASE_PRESENTATION)
        success = success and line_response[0]
        response = "{response}. {lr}".format(response=response, lr=line_response[1])

    if success:
        return True, response
    else:
        return False, response
Example #2
0
def main():
    logging.basicConfig(level=logging.INFO)
    labels = ["test1", "test2", "test3", "test4", "test5"]
    data1 = np.array([10, 11, 12, 13, 14])
    data2 = data1 * 2

    chart_data = {
        "MySQL": {
            "test1": 0.10,
            "test2": 0.20
        },
        "Postgres": {
            "test1": 0.20,
            "test2": 0.40
        },
    }

    create_bar_chart(chart_data, "Test Plot", "Time (sec)",
                     "figures/test_plot.png")
def create_charts(req_body):
    det = req_body['details']
    success = True
    response = ''

    for details in det:
        if 'create_pie_chart' in details and details['create_pie_chart'] and details['pie_data']:
            pie_response = create_pie_chart(details['pie_data'], BASE_PRESENTATION)
            success = success and pie_response[0]
            response = "{pr}".format(response=response, pr=pie_response[1])

        if 'create_bar_chart' in details and details['create_bar_chart'] and details['bar_data']:
            bar_response = create_bar_chart(details['bar_data'], BASE_PRESENTATION)
            success = success and bar_response[0]
            response = "{response}. {br}".format(response=response, br=bar_response[1])

        if 'create_line_chart' in details and details['create_line_chart'] and details['line_data']:
            line_response = create_line_chart(details['line_data'], BASE_PRESENTATION)
            success = success and line_response[0]
            response = "{response}. {lr}".format(response=response, lr=line_response[1])

        if 'create_gantt_chart' in details and details['create_gantt_chart'] and details['gantt_data']:
            gantt_response = create_gantt_chart(details['gantt_data'], BASE_PRESENTATION)
            success = success and gantt_response[0]
            response = "{response}. {gr}".format(response=response, gr=gantt_response[1])
        
        if 'create_mekko_chart' in details and details['create_mekko_chart'] and details['mekko_data']:
            mekko_response = create_mekko_chart(details['mekko_data'], BASE_PRESENTATION)
            success = success and mekko_response[0]
            response = "{response}. {mk}".format(response=response, mk=mekko_response[1])
        
        if 'create_stacked_bar_chart' in details and details['stacked_bar_chart'] and details['stacked_bar_chart_data']:
            st_bar_response = create_stacked_bar_chart(details['stacked_bar_chart'], BASE_PRESENTATION)
            success = success and st_bar_response[0]
            response = "{response}. {st}".format(response=response, st=st_bar_response[1])

        if 'create_scatter_bubble_chart' in details and details['scatter_bubble_data'] and details['scatter_bubble_data']:
            sc_bar_response = create_scatter_bubble_chart(details['scatter_bubble_data'], BASE_PRESENTATION)
            success = success and sc_bar_response[0]
            response = "{response}. {sc}".format(response=response, sc=sc_bar_response[1])
        
    if success:
        return True, response
    else:
        return False, response
Example #4
0
import argparse
import json
import logging
from bar_chart import create_bar_chart

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)

    output_file = "data_insertion_benchmark"
    data_files = [f"data_insertion_benchmark_pg_index_GIST.json",
                  f"data_insertion_benchmark_no_mysql_index_pg_index_NONE.json"]

    benchmark_data = {}
    for data_file in data_files:
        with open(f"results/{data_file}", 'r') as file:
            benchmark_data.update(json.loads(file.read()))

    logger.info(benchmark_data)

    create_bar_chart(benchmark_data, "Time to Insert 1000 Rows",
                     "Seconds", f"figures/{output_file}.png", yscale='log')
Example #5
0
    for data_file in data_files:
        with open(f"results/{data_file}", 'r') as file:
            benchmark_data.update(json.loads(file.read()))

    logger.info(benchmark_data)

    if args.mode == "analysis":
        benchmark_data_keys = [
            "MySQL", "MySQL (No Index)", "Postgis (GIST Index)",
            "Postgis (No Index)"
        ]
        benchmark_subset = dict(
            (k, benchmark_data[k]) for k in benchmark_data_keys)
        create_bar_chart(benchmark_subset,
                         "Time to Run Query With and Without Spatial Index",
                         "Seconds",
                         f"figures/{output_file}_pg_mysql.png",
                         yscale='log',
                         fig_size=(15, 5))
        benchmark_data_keys = [
            "Postgis (GIST Index)", "Postgis (SPGIST Index)",
            "Postgis (BRIN Index)", "Postgis (No Index)"
        ]
        benchmark_subset = dict(
            (k, benchmark_data[k]) for k in benchmark_data_keys)
        create_bar_chart(benchmark_subset,
                         "Time to Run Query With and Without Spatial Index",
                         "Seconds",
                         f"figures/{output_file}_pg_only.png",
                         yscale='log',
                         fig_size=(15, 5))
    elif args.mode == "join":
def ppt_request_handle():
    print("in ppt_request_handle")
    req = request.json
    print(req)
    if req["req"] == "create_ppt" and req["source"].lower() == "wikipedia":
        result = create_ppt(req["title"])
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1]
            }
            return jsonify(response), 200

    elif req["req"] == "create_ppt_count" and req["source"].lower() == "wikipedia":
        result = create_ppt_with_count(req["title"], req["count"])
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1],
                "count": result[2],
            }
            return jsonify(response), 200

    elif req["req"] == "create_ppt_count" and req["source"].lower() == "nytimes":
        result = create_ppt_ny(req["title"], int(req["count"]))
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1],
                "count": result[2],
            }
            return jsonify(response), 200

    elif req["req"] == "create_team_slide":
        result = create_team_slide(req["people"])
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_pie_chart":
        result = create_pie_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_bar_chart":
        result = create_bar_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_line_chart":
        result = create_line_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400
    
    elif req['req'] ==  "create_gantt_chart":

        result = create_gantt_chart(req["details"], BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400
    
    elif req['req'] ==  "create_mekko_chart":
        result = create_mekko_chart(req["details"], BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400
        
    elif req['req'] == "create_stacked_bar_chart":
        result = create_stacked_bar_chart(req["details"], BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req['req'] == "create_scatter_bubble_chart":
        result = create_scatter_bubble_chart(req["details"], BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_chart" or req["req"] == "create_charts":
        result = create_charts(req)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_org_chart":
        result = True, 'Got the request'
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400
        

    return f"Cannot process request", 400
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('mode',
                        metavar='M',
                        type=str,
                        choices=['join', 'analysis'],
                        help='Constrains which benchmarks are run')
    args = parser.parse_args()

    output_file = f"{args.mode}_parallel_execution_benchmark"
    data_files = [
        f"{args.mode}_benchmark_pg_index_GIST.json",
        f"{args.mode}_benchmark_pg_index_GIST_parallel.json"
    ]

    benchmark_data = {}
    for data_file in data_files:
        with open(f"results/{data_file}", 'r') as file:
            benchmark_data.update(json.loads(file.read()))

    logger.info(benchmark_data)

    fig_size = (10, 5)
    if args.mode == 'analysis':
        fig_size = (15, 5)
    create_bar_chart(benchmark_data,
                     "Time to Run Query",
                     "Seconds",
                     f"figures/{output_file}.png",
                     yscale='log',
                     fig_size=fig_size)
Example #8
0
import argparse
import json
import logging
from bar_chart import create_bar_chart

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('mode', metavar='M', type=str,
                        choices=['join', 'analysis'],
                        help='Constrains which benchmarks are run')
    args = parser.parse_args()

    output_file = f"{args.mode}_crs_benchmark"
    data_files = [f"{args.mode}_benchmark_pg_index_GIST.json",
                  f"{args.mode}_benchmark_pg_index_GIST_gcs.json"]

    benchmark_data = {}
    for data_file in data_files:
        with open(f"results/{data_file}", 'r') as file:
            benchmark_data.update(json.loads(file.read()))

    logger.info(benchmark_data)

    create_bar_chart(benchmark_data, "Time to Run Query With PCS and GCS",
                     "Seconds", f"figures/{output_file}.png", yscale='log', fig_size=(15, 5))
Example #9
0
import argparse
import json
import logging
from bar_chart import create_bar_chart

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)

    output_file = "data_loading_benchmark"
    data_file = "data_loading_benchmark.json"

    benchmark_data = {}
    with open(f"results/{data_file}", 'r') as file:
        benchmark_data.update(json.loads(file.read()))

    logger.info(benchmark_data)

    create_bar_chart(benchmark_data, "Time to Load Dataset",
                     "Seconds", f"figures/{output_file}.png", yscale='log')
Example #10
0
def ppt_request_handle():
    print("in ppt_request_handle")
    req = request.json
    print(req)

    with open("req_sample.json", "w") as outfile:
        json.dump(req, outfile)

    if req["req"] == "create_ppt" and req["source"].lower() == "wikipedia":
        result = create_ppt(req["title"])
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1]
            }
            return jsonify(response), 200

    elif req["req"] == "create_ppt_count" and req["source"].lower() == "wikipedia":
        result = create_ppt_with_count(req["title"], req["count"])
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1],
                "count": result[2],
            }
            return jsonify(response), 200

    elif req["req"] == "create_ppt_count" and req["source"].lower() == "nytimes":
        result = create_ppt_ny(req["title"], req["count"])
        if result[0]:
            response = {
                "message": "Request successful",
                "title": result[1],
                "count": result[2],
            }
            return jsonify(response), 200

    elif req["req"] == "create_team_slide":
        result = create_team_slide(req["people"])
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_pie_chart":
        result = create_pie_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_bar_chart":
        result = create_bar_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_line_chart":
        result = create_line_chart(req, BASE_PRESENTATION)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_chart" or req["req"] == "create_charts":
        result = create_charts(req)
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    elif req["req"] == "create_org_chart":
        result = True, 'Got the request'
        response = {
            "message": result[1]
        }
        if result[0]:
            return jsonify(response), 200
        else:
            return jsonify(response), 400

    return f"Cannot process request", 400