-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
46 lines (40 loc) · 1.55 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import time
import os
import sys
from pipeline_module.gpt import GPT
from pipeline_module.pipeline import GenRewrite
import logging
if __name__ == "__main__":
print(
f"-----------------------------------------------------------------\n"
f"Start initializing configuration...\n"
)
try:
gpt = GPT()
print("GPT connection test ...\n Prompt: What is the capital of France?")
prompt = "What is the capital of France?"
response = gpt.get_GPT_response(prompt)
print(f" {response}\n")
print("GPT connection sucessfully!")
except Exception as e:
logging.error(f"An error occurred: {e}", exc_info=True)
print(
f"-----------------------------------------------------------------\n"
)
hints = """
Pre-calculate aggregates in subqueries
Remove unnecessary UNION ALL operation
Avoid using arithmetic operations in WHERE clause
Replace implicit JOINs with explicit JOINs
"""
json_path = "./data/reportory.json"
# def __init__(self, queries, budget, min_speedup,reportory_path):
candidate_queries = ["SELECT * FROM table WHERE column = value"]
pipline = GenRewrite(queries = candidate_queries, budget = 10, min_speedup = 0.2, reportory_path = json_path)
res = pipline.run(hints)
print(
f"-----------------------------------------------------------------\n"
f"End of the program.\n"
f"-----------------------------------------------------------------\n"
)
print(f"Result: {res}")