Spaces:
Running
Running
Prediction, Tables samples (#12)
Browse files- Prediction, Tables samples (32429f83624047758c1fd8c13691150eb9aaefc3)
Co-authored-by: Francesco Giannuzzo <[email protected]>
- app.py +27 -25
- tables_dict.csv +300 -0
- tables_dict.pkl +3 -0
- utilities.py +7 -2
app.py
CHANGED
@@ -1,6 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# # https://discuss.huggingface.co/t/issues-with-sadtalker-zerogpu-spaces-inquiry-about-community-grant/110625/10
|
5 |
# if os.environ.get("SPACES_ZERO_GPU") is not None:
|
6 |
# import spaces
|
@@ -11,23 +28,6 @@ import os
|
|
11 |
# def wrapper(*args, **kwargs):
|
12 |
# return func(*args, **kwargs)
|
13 |
# return wrapper
|
14 |
-
import sys
|
15 |
-
from qatch.connectors.sqlite_connector import SqliteConnector
|
16 |
-
from qatch.generate_dataset.orchestrator_generator import OrchestratorGenerator
|
17 |
-
from qatch.evaluate_dataset.orchestrator_evaluator import OrchestratorEvaluator
|
18 |
-
from prediction import ModelPrediction
|
19 |
-
import utils_get_db_tables_info
|
20 |
-
import utilities as us
|
21 |
-
import time
|
22 |
-
import plotly.express as px
|
23 |
-
import plotly.graph_objects as go
|
24 |
-
import plotly.colors as pc
|
25 |
-
import re
|
26 |
-
import csv
|
27 |
-
import numpy as np
|
28 |
-
# @spaces.GPU
|
29 |
-
# def model_prediction():
|
30 |
-
# pass
|
31 |
pnp_path = os.path.join(".", "evaluation_p_np_metrics.csv")
|
32 |
|
33 |
js_func = """
|
@@ -50,8 +50,8 @@ df_default = pd.DataFrame({
|
|
50 |
'Age': [25, 30, 35],
|
51 |
'City': ['New York', 'Los Angeles', 'Chicago']
|
52 |
})
|
53 |
-
|
54 |
-
models_path = "./models.csv"
|
55 |
|
56 |
# Variabile globale per tenere traccia dei dati correnti
|
57 |
df_current = df_default.copy()
|
@@ -176,7 +176,7 @@ with gr.Blocks(theme='shivi/calm_seafoam', css_paths='style.css', js=js_func) as
|
|
176 |
with gr.Row():
|
177 |
with gr.Column(scale=1):
|
178 |
gr.Image(
|
179 |
-
value="
|
180 |
show_label=False,
|
181 |
container=False,
|
182 |
interactive=False,
|
@@ -652,10 +652,12 @@ with gr.Blocks(theme='shivi/calm_seafoam', css_paths='style.css', js=js_func) as
|
|
652 |
samples = us.generate_some_samples(input_data['data']['db'], row["tbl_name"])
|
653 |
prompt_to_send = us.prepare_prompt(input_data["prompt"], question, schema_text, samples)
|
654 |
#PREDICTION SQL
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
|
|
|
|
659 |
|
660 |
end_time = time.time()
|
661 |
display_prediction = f"""<div class='loading' style='font-size: 1.7rem; font-family: 'Inter', sans-serif;'>>Predicted SQL:</div>
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import time
|
4 |
+
import re
|
5 |
+
import csv
|
6 |
import gradio as gr
|
7 |
import pandas as pd
|
8 |
+
import numpy as np
|
9 |
+
import plotly.express as px
|
10 |
+
import plotly.graph_objects as go
|
11 |
+
import plotly.colors as pc
|
12 |
+
from qatch.connectors.sqlite_connector import SqliteConnector
|
13 |
+
from qatch.generate_dataset.orchestrator_generator import OrchestratorGenerator
|
14 |
+
from qatch.evaluate_dataset.orchestrator_evaluator import OrchestratorEvaluator
|
15 |
+
from prediction import ModelPrediction
|
16 |
+
import utils_get_db_tables_info
|
17 |
+
import utilities as us
|
18 |
+
# @spaces.GPU
|
19 |
+
# def model_prediction():
|
20 |
+
# pass
|
21 |
# # https://discuss.huggingface.co/t/issues-with-sadtalker-zerogpu-spaces-inquiry-about-community-grant/110625/10
|
22 |
# if os.environ.get("SPACES_ZERO_GPU") is not None:
|
23 |
# import spaces
|
|
|
28 |
# def wrapper(*args, **kwargs):
|
29 |
# return func(*args, **kwargs)
|
30 |
# return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
pnp_path = os.path.join(".", "evaluation_p_np_metrics.csv")
|
32 |
|
33 |
js_func = """
|
|
|
50 |
'Age': [25, 30, 35],
|
51 |
'City': ['New York', 'Los Angeles', 'Chicago']
|
52 |
})
|
53 |
+
models_path = os.path.join(".", "models.csv")
|
54 |
+
#models_path = "./models.csv"
|
55 |
|
56 |
# Variabile globale per tenere traccia dei dati correnti
|
57 |
df_current = df_default.copy()
|
|
|
176 |
with gr.Row():
|
177 |
with gr.Column(scale=1):
|
178 |
gr.Image(
|
179 |
+
value=os.path.join(".", "qatch_logo.png"),
|
180 |
show_label=False,
|
181 |
container=False,
|
182 |
interactive=False,
|
|
|
652 |
samples = us.generate_some_samples(input_data['data']['db'], row["tbl_name"])
|
653 |
prompt_to_send = us.prepare_prompt(input_data["prompt"], question, schema_text, samples)
|
654 |
#PREDICTION SQL
|
655 |
+
if prompt_to_send == prompt_default:
|
656 |
+
prompt_to_send = None
|
657 |
+
response = predictor.make_prediction(question=question, db_schema=schema_text, model_name=model, prompt=f"{prompt_to_send}")
|
658 |
+
prediction = response['response_parsed']
|
659 |
+
price = response['cost']
|
660 |
+
answer = response['response']
|
661 |
|
662 |
end_time = time.time()
|
663 |
display_prediction = f"""<div class='loading' style='font-size: 1.7rem; font-family: 'Inter', sans-serif;'>>Predicted SQL:</div>
|
tables_dict.csv
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Table: accountFraud
|
2 |
+
hasothercards,housingstatus,dateofbirthdistinctemails4w,income,paymenttype,employmentstatus,creditriskscore,sessionlengthminutes,deviceos,emailisfree
|
3 |
+
False,BD,3,0.5,AB,CC,230,5.07759998143027,linux,Paid
|
4 |
+
False,BC,15,0.1,AD,CB,-40,4.0223824396911,other,Paid
|
5 |
+
True,BC,7,0.9,AC,CA,215,3.749706225590873,windows,Paid
|
6 |
+
False,BC,2,0.4,AC,CD,51,4.886676763177824,other,Paid
|
7 |
+
False,BC,6,0.4,AB,CA,108,1.7508864007811145,other,Free
|
8 |
+
|
9 |
+
Table: shop
|
10 |
+
Shop_ID,Name,Location,District,Number_products,Manager_name
|
11 |
+
1,FC Haka,Valkeakoski,Tehtaan kenttä,3516,Olli Huttunen
|
12 |
+
2,HJK,Helsinki,Finnair Stadium,10770,Antti Muurinen
|
13 |
+
3,FC Honka,Espoo,Tapiolan Urheilupuisto,6000,Mika Lehkosuo
|
14 |
+
4,FC Inter,Turku,Veritas Stadion,10000,Job Dragtsma
|
15 |
+
5,FF Jaro,Jakobstad,Jakobstads Centralplan,5000,Mika Laurikainen
|
16 |
+
|
17 |
+
Table: airlines
|
18 |
+
uid,Airline,Abbreviation,Country
|
19 |
+
1,United Airlines,UAL,USA
|
20 |
+
2,US Airways,USAir,USA
|
21 |
+
3,Delta Airlines,Delta,USA
|
22 |
+
4,Southwest Airlines,Southwest,USA
|
23 |
+
5,American Airlines,American,USA
|
24 |
+
|
25 |
+
Table: fitnessTrackers
|
26 |
+
brandname,devicetype,modelname,color,sellingprice,originalprice,display,rating,strapmaterial,averagebatterylife
|
27 |
+
huami,Smartwatch,Amazfit Bip S,White ,4999.0,5999.0,AMOLED Display,4.0,Thermoplastic polyurethane,15
|
28 |
+
GARMIN ,Smartwatch,Approach S62,"White, Black",46990.0,51990.0,OLED Display,4.1,Silicone,12
|
29 |
+
SAMSUNG ,Smartwatch,Galaxy Classic 4,Black,32959.0,37999.0,AMOLED Display,4.6,Elastomer,14
|
30 |
+
SAMSUNG ,Smartwatch,Galaxy Watch 4 LTE,Black,31999.0,34999.0,AMOLED Display,4.6,Elastomer,14
|
31 |
+
APPLE,Smartwatch,Series 6 GPS + Cellular 40 mm Red Aluminium Case,Red,45690.0,49900.0,OLED Retina Display,4.5,Aluminium,1
|
32 |
+
|
33 |
+
Table: Ref_Template_Types
|
34 |
+
Template_Type_Code,Template_Type_Description
|
35 |
+
PPT,Presentation
|
36 |
+
CV,CV
|
37 |
+
AD,Advertisement
|
38 |
+
PP,Paper
|
39 |
+
BK,Book
|
40 |
+
|
41 |
+
Table: stadium
|
42 |
+
Stadium_ID,Location,Name,Capacity,Highest,Lowest,Average
|
43 |
+
1,Raith Rovers,Stark's Park,10104,4812,1294,2106
|
44 |
+
2,Ayr United,Somerset Park,11998,2363,1057,1477
|
45 |
+
3,East Fife,Bayview Stadium,2000,1980,533,864
|
46 |
+
4,Queen's Park,Hampden Park,52500,1763,466,730
|
47 |
+
5,Stirling Albion,Forthbank Stadium,3808,1125,404,642
|
48 |
+
|
49 |
+
Table: Student
|
50 |
+
StuID,LName,Fname,Age,Sex,Major,Advisor,city_code
|
51 |
+
1001,Smith,Linda,18,F,600,1121,BAL
|
52 |
+
1002,Kim,Tracy,19,F,600,7712,HKG
|
53 |
+
1003,Jones,Shiela,21,F,600,7792,WAS
|
54 |
+
1004,Kumar,Dinesh,20,M,600,8423,CHI
|
55 |
+
1005,Gompers,Paul,26,M,600,1121,YYZ
|
56 |
+
|
57 |
+
Table: Templates
|
58 |
+
Template_ID,Version_Number,Template_Type_Code,Date_Effective_From,Date_Effective_To,Template_Details
|
59 |
+
0,5,PP,2005-11-12 07:09:48,2008-01-05 14:19:28,
|
60 |
+
1,9,PP,2010-09-24 01:15:11,1999-07-08 03:31:04,
|
61 |
+
4,4,BK,2002-03-02 14:39:49,2001-04-18 09:29:52,
|
62 |
+
6,2,PPT,1975-05-20 22:51:19,1992-05-02 20:06:11,
|
63 |
+
7,8,PPT,1993-10-07 02:33:04,1975-07-16 04:52:10,
|
64 |
+
|
65 |
+
Table: employee
|
66 |
+
Employee_ID,Name,Age,City
|
67 |
+
1,George Chuter,23,Bristol
|
68 |
+
2,Lee Mears,29,Bath
|
69 |
+
3,Mark Regan,43,Bristol
|
70 |
+
4,Jason Hobson,30,Bristol
|
71 |
+
5,Tim Payne,29,Wasps
|
72 |
+
|
73 |
+
Table: flights
|
74 |
+
Airline,FlightNo,SourceAirport,DestAirport
|
75 |
+
1,28, APG, ASY
|
76 |
+
1,29, ASY, APG
|
77 |
+
1,44, CVO, ACV
|
78 |
+
1,45, ACV, CVO
|
79 |
+
1,54, AHD, AHT
|
80 |
+
|
81 |
+
Table: model_list
|
82 |
+
ModelId,Maker,Model
|
83 |
+
1,1,amc
|
84 |
+
2,2,audi
|
85 |
+
3,3,bmw
|
86 |
+
4,4,buick
|
87 |
+
5,4,cadillac
|
88 |
+
|
89 |
+
Table: heartAttack
|
90 |
+
age,sex,chestpaintype,restingbloodpressure,cholestoralinmg,fastingbloodsugar,restingelectrocardiographicrresults,numberofmajorvvessels,thall,output
|
91 |
+
62,male,typicalAngina,140,268,false,normal,2,2,noHeartAttack
|
92 |
+
64,female,asymptomatic,110,211,false,normal,0,2,heartAttack
|
93 |
+
68,female,nonAnginalPain,180,274,true,normal,0,3,noHeartAttack
|
94 |
+
50,female,typicalAngina,144,200,false,normal,0,3,noHeartAttack
|
95 |
+
76,male,nonAnginalPain,140,197,false,leftVentricularHypertrophy,0,2,heartAttack
|
96 |
+
|
97 |
+
Table: Paragraphs
|
98 |
+
Paragraph_ID,Document_ID,Paragraph_Text,Other_Details
|
99 |
+
7,2394,Korea,
|
100 |
+
9,3,Somalia,
|
101 |
+
65,50123,Palestinian Territory,
|
102 |
+
241,651512,Jersey,
|
103 |
+
3708,33930,UK,
|
104 |
+
|
105 |
+
Table: concert
|
106 |
+
concert_ID,concert_Name,Theme,Stadium_ID,Year
|
107 |
+
1,Auditions,Free choice,1,2014
|
108 |
+
2,Super bootcamp,Free choice 2,2,2014
|
109 |
+
3,Home Visits,Bleeding Love,2,2015
|
110 |
+
4,Week 1,Wide Awake,10,2014
|
111 |
+
5,Week 1,Happy Tonight,9,2015
|
112 |
+
|
113 |
+
Table: car_makers
|
114 |
+
Id,Maker,FullName,Country
|
115 |
+
1,amc,American Motor Company,1
|
116 |
+
2,volkswagen,Volkswagen,2
|
117 |
+
3,bmw,BMW,2
|
118 |
+
4,gm,General Motors,1
|
119 |
+
5,ford,Ford Motor Company,1
|
120 |
+
|
121 |
+
Table: evaluation
|
122 |
+
Employee_ID,Year_awarded,Bonus
|
123 |
+
1,2011,3000.0
|
124 |
+
2,2015,3200.0
|
125 |
+
1,2016,2900.0
|
126 |
+
4,2017,3200.0
|
127 |
+
7,2018,3200.0
|
128 |
+
|
129 |
+
Table: singer_in_concert
|
130 |
+
concert_ID,Singer_ID
|
131 |
+
1,2
|
132 |
+
1,3
|
133 |
+
1,5
|
134 |
+
2,3
|
135 |
+
2,6
|
136 |
+
|
137 |
+
Table: Documents
|
138 |
+
Document_ID,Template_ID,Document_Name,Document_Description,Other_Details
|
139 |
+
0,7,Introduction of OS,n,
|
140 |
+
1,25,Understanding DB,y,
|
141 |
+
3,6,Summer Show,u,
|
142 |
+
76,20,Robbin CV,y,
|
143 |
+
80,14,Welcome to NY,h,
|
144 |
+
|
145 |
+
Table: visit
|
146 |
+
Museum_ID,visitor_ID,Num_of_Ticket,Total_spent
|
147 |
+
1,5,20,320.14
|
148 |
+
2,5,4,89.98
|
149 |
+
4,3,10,320.44
|
150 |
+
2,3,24,209.98
|
151 |
+
4,6,3,20.44
|
152 |
+
|
153 |
+
Table: museum
|
154 |
+
Museum_ID,Name,Num_of_Staff,Open_Year
|
155 |
+
1,Plaza Museum,62,2000
|
156 |
+
2,Capital Plaza Museum,25,2012
|
157 |
+
3,Jefferson Development Museum,18,2010
|
158 |
+
4,Willow Grande Museum,17,2011
|
159 |
+
5,RiverPark Museum,16,2008
|
160 |
+
|
161 |
+
Table: singer
|
162 |
+
Singer_ID,Name,Country,Song_Name,Song_release_year,Age,Is_male
|
163 |
+
1,Joe Sharp,Netherlands,You,1992,52,F
|
164 |
+
2,Timbaland,United States,Dangerous,2008,32,T
|
165 |
+
3,Justin Brown,France,Hey Oh,2013,29,T
|
166 |
+
4,Rose White,France,Sun,2003,41,F
|
167 |
+
5,John Nizinik,France,Gentleman,2014,43,T
|
168 |
+
|
169 |
+
Table: countries
|
170 |
+
CountryId,CountryName,Continent
|
171 |
+
1,usa,1
|
172 |
+
2,germany,2
|
173 |
+
3,france,2
|
174 |
+
4,japan,3
|
175 |
+
5,italy,2
|
176 |
+
|
177 |
+
Table: continents
|
178 |
+
ContId,Continent
|
179 |
+
1,america
|
180 |
+
2,europe
|
181 |
+
3,asia
|
182 |
+
4,africa
|
183 |
+
5,australia
|
184 |
+
|
185 |
+
Table: adultCensus
|
186 |
+
workclass,education,maritalstatus,occupation,relationship,race,sex,hoursperweek,nativecountry,income
|
187 |
+
Private,Doctorate,Married-civ-spouse,Prof-specialty,Husband,White,Male,60,United-States,>50K
|
188 |
+
Local-gov,Some-college,Divorced,Adm-clerical,Not-in-family,Black,Female,40,United-States,<=50K
|
189 |
+
Private,10th,Married-civ-spouse,Machine-op-inspct,Husband,White,Male,40,United-States,<=50K
|
190 |
+
Private,Some-college,Married-civ-spouse,Exec-managerial,Husband,White,Male,44,United-States,>50K
|
191 |
+
?,HS-grad,Never-married,?,Not-in-family,White,Female,40,United-States,<=50K
|
192 |
+
|
193 |
+
Table: latePayment
|
194 |
+
customerid,paperlessdate,invoicenumber,invoicedate,duedate,invoiceamount,disputed,paperlessbill,daystosettle,dayslate
|
195 |
+
7758-WKLVM,2/6/2012,5510823569,4/11/2012,5/11/2012,30.06,No,Electronic,36,6
|
196 |
+
2820-XGXSB,1/26/2012,6528247418,1/4/2013,2/3/2013,84.86,No,Electronic,4,0
|
197 |
+
2621-XCLEH,9/24/2012,9465847338,6/18/2013,7/18/2013,37.49,No,Electronic,29,0
|
198 |
+
5196-TWQXF,6/20/2012,7092718520,12/2/2012,1/1/2013,50.17,No,Electronic,22,0
|
199 |
+
9725-EZTEJ,3/17/2012,685917930,10/13/2012,11/12/2012,124.38,Yes,Electronic,28,0
|
200 |
+
|
201 |
+
Table: course_arrange
|
202 |
+
Course_ID,Teacher_ID,Grade
|
203 |
+
2,5,1
|
204 |
+
2,3,3
|
205 |
+
3,2,5
|
206 |
+
4,6,7
|
207 |
+
5,6,1
|
208 |
+
|
209 |
+
Table: Has_Pet
|
210 |
+
StuID,PetID
|
211 |
+
1001,2001
|
212 |
+
1002,2002
|
213 |
+
1002,2003
|
214 |
+
|
215 |
+
Table: breastCancer
|
216 |
+
patientidentifier,age,menopausalstatus,tumorsize,tumorgrade,numberpositivelymphnodes,progesteronereceptor,estrogenreceptor,hormonaltherapy,status
|
217 |
+
1522,32,premenopausal,25,2,2,36,10,no,"aliveWithoutRecurrence,"
|
218 |
+
1329,61,postmenopausal,30,2,1,24,38,yes,"aliveWithoutRecurrence,"
|
219 |
+
1141,62,postmenopausal,33,1,5,239,76,no,recurrenceOrDeath
|
220 |
+
1488,66,postmenopausal,42,3,11,412,339,yes,recurrenceOrDeath
|
221 |
+
1294,38,premenopausal,23,3,3,14,6,no,"aliveWithoutRecurrence,"
|
222 |
+
|
223 |
+
Table: hiring
|
224 |
+
Shop_ID,Employee_ID,Start_from,Is_full_time
|
225 |
+
1,1,2009,T
|
226 |
+
1,2,2003,T
|
227 |
+
8,3,2011,F
|
228 |
+
4,4,2012,T
|
229 |
+
5,5,2013,T
|
230 |
+
|
231 |
+
Table: cars_data
|
232 |
+
Id,MPG,Cylinders,Edispl,Horsepower,Weight,Accelerate,Year
|
233 |
+
1,18,8,307.0,130,3504,12.0,1970
|
234 |
+
2,15,8,350.0,165,3693,11.5,1970
|
235 |
+
3,18,8,318.0,150,3436,11.0,1970
|
236 |
+
4,16,8,304.0,150,3433,12.0,1970
|
237 |
+
5,17,8,302.0,140,3449,10.5,1970
|
238 |
+
|
239 |
+
Table: car_names
|
240 |
+
MakeId,Model,Make
|
241 |
+
1,chevrolet,chevrolet chevelle malibu
|
242 |
+
2,buick,buick skylark 320
|
243 |
+
3,plymouth,plymouth satellite
|
244 |
+
4,amc,amc rebel sst
|
245 |
+
5,ford,ford torino
|
246 |
+
|
247 |
+
Table: visitor
|
248 |
+
ID,Name,Level_of_membership,Age
|
249 |
+
1,Gonzalo Higuaín ,8,35
|
250 |
+
2,Guti Midfielder,5,28
|
251 |
+
3,Arjen Robben,1,27
|
252 |
+
4,Raúl Brown,2,56
|
253 |
+
5,Fernando Gago,6,36
|
254 |
+
|
255 |
+
Table: salesTransactions
|
256 |
+
transactionno,date,productno,productname,price,quantity,customerno,country
|
257 |
+
549047,4/6/2019,21544,Skulls-Water-Transfer-Tattoos,11.12,2,17783.0,United-Kingdom
|
258 |
+
566959,9/15/2019,22113,Grey-Heart-Hot-Water-Bottle,14.61,2,17530.0,United-Kingdom
|
259 |
+
536526,12/1/2018,22173,Metal-4-Hook-Hanger-French-Chateau,13.27,16,14001.0,United-Kingdom
|
260 |
+
580355,12/2/2019,47599A,Pink-Party-Bags,6.19,12,13953.0,United-Kingdom
|
261 |
+
579557,11/30/2019,21671,Red-Spot-Ceramic-Drawer-Knob,6.19,1,12557.0,United-Kingdom
|
262 |
+
|
263 |
+
Table: airports
|
264 |
+
City,AirportCode,AirportName,Country,CountryAbbrev
|
265 |
+
Aberdeen ,APG,Phillips AAF ,United States ,US
|
266 |
+
Aberdeen ,ABR,Municipal ,United States ,US
|
267 |
+
Abilene ,DYS,Dyess AFB ,United States ,US
|
268 |
+
Abilene ,ABI,Municipal ,United States ,US
|
269 |
+
Abingdon ,VJI,Virginia Highlands ,United States ,US
|
270 |
+
|
271 |
+
Table: mushrooms
|
272 |
+
class,capshape,capsurface,capcolor,bruises,odor,gillattachment,gillspacing,gillsize,gillcolor
|
273 |
+
poisonous,flat,smooth,white,bruises,pungent,free,close,narrow,brown
|
274 |
+
edible,convex,fibrous,gray,no,none,free,crowded,broad,black
|
275 |
+
edible,bell,smooth,white,bruises,almond,free,close,broad,gray
|
276 |
+
edible,flat,scaly,brown,bruises,none,free,close,broad,pink
|
277 |
+
poisonous,convex,fibrous,yellow,no,foul,free,close,broad,gray
|
278 |
+
|
279 |
+
Table: Pets
|
280 |
+
PetID,PetType,pet_age,weight
|
281 |
+
2001,cat,3,12.0
|
282 |
+
2002,dog,2,13.4
|
283 |
+
2003,dog,1,9.3
|
284 |
+
|
285 |
+
Table: teacher
|
286 |
+
Teacher_ID,Name,Age,Hometown
|
287 |
+
1,Joseph Huts,32,Blackrod Urban District
|
288 |
+
2,Gustaaf Deloor,29,Bolton County Borough
|
289 |
+
3,Vicente Carretero,26,Farnworth Municipal Borough
|
290 |
+
4,John Deloor,33,Horwich Urban District
|
291 |
+
5,Kearsley Brown,45,Kearsley Urban District
|
292 |
+
|
293 |
+
Table: course
|
294 |
+
Course_ID,Staring_Date,Course
|
295 |
+
1,5 May,Language Arts
|
296 |
+
2,6 May,Math
|
297 |
+
3,7 May,Science
|
298 |
+
4,9 May,History
|
299 |
+
5,10 May,Bible
|
300 |
+
|
tables_dict.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a05f1d65a8f0d5ea2bb1aa1efd76cddb2685ca2da4a3aac54838d5be1205cbe6
|
3 |
+
size 22799
|
utilities.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import csv
|
2 |
import re
|
3 |
import pandas as pd
|
|
|
4 |
import sqlite3
|
5 |
import gradio as gr
|
6 |
import os
|
@@ -107,6 +108,10 @@ def generate_some_samples(connector, tbl_name):
|
|
107 |
samples.append(f"Error: {e}")
|
108 |
return samples
|
109 |
|
|
|
|
|
|
|
|
|
110 |
def extract_tables_dict(pnp_path):
|
111 |
tables_dict = {}
|
112 |
with open(pnp_path, mode='r', encoding='utf-8') as file:
|
@@ -126,5 +131,5 @@ def extract_tables_dict(pnp_path):
|
|
126 |
tables_dict[tbl_name] = df
|
127 |
except Exception as e:
|
128 |
tables_dict[tbl_name] = pd.DataFrame({"Error": [str(e)]}) # DataFrame con messaggio di errore
|
129 |
-
|
130 |
-
return tables_dict
|
|
|
1 |
import csv
|
2 |
import re
|
3 |
import pandas as pd
|
4 |
+
import pickle
|
5 |
import sqlite3
|
6 |
import gradio as gr
|
7 |
import os
|
|
|
108 |
samples.append(f"Error: {e}")
|
109 |
return samples
|
110 |
|
111 |
+
def load_tables_dict(file_path):
|
112 |
+
with open(file_path, 'rb') as f:
|
113 |
+
return pickle.load(f)
|
114 |
+
|
115 |
def extract_tables_dict(pnp_path):
|
116 |
tables_dict = {}
|
117 |
with open(pnp_path, mode='r', encoding='utf-8') as file:
|
|
|
131 |
tables_dict[tbl_name] = df
|
132 |
except Exception as e:
|
133 |
tables_dict[tbl_name] = pd.DataFrame({"Error": [str(e)]}) # DataFrame con messaggio di errore
|
134 |
+
return load_tables_dict('tables_dict.csv')
|
135 |
+
return tables_dict
|