Spaces:
Runtime error
Runtime error
Commit ·
ec44c7f
1
Parent(s): e7c1910
reverting some changes
Browse files
app.py
CHANGED
|
@@ -116,20 +116,29 @@ def onSelectedTablesChange(tablesSelected):
|
|
| 116 |
global queryHelper
|
| 117 |
print(f"Selected tables : {tablesSelected}")
|
| 118 |
metadataLayout = queryHelper.getMetadata()
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
tableBoxes = []
|
| 121 |
-
for i in range(len(
|
| 122 |
-
if
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
else:
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
return tableBoxes
|
| 127 |
|
| 128 |
def onSelectedColumnsChange(*tableBoxes):
|
| 129 |
#update selection of columns and tables (include new tables and cols in gpts context)
|
| 130 |
global queryHelper
|
| 131 |
metadataLayout = queryHelper.getMetadata()
|
| 132 |
-
|
|
|
|
| 133 |
tablesAndCols = {}
|
| 134 |
result = ''
|
| 135 |
print("Getting selected tables and columns from gradio")
|
|
@@ -148,18 +157,26 @@ def onSelectedColumnsChange(*tableBoxes):
|
|
| 148 |
|
| 149 |
def onResetToDefaultSelection():
|
| 150 |
global queryHelper
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
tableBoxes = []
|
| 153 |
-
allTablesList = list(metadataLayout.getAllTablesCols().keys())
|
| 154 |
for i in range(len(allTablesList)):
|
| 155 |
-
if allTablesList[i] in
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
| 157 |
else:
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
queryHelper.updateMetadata(metadataLayout)
|
| 163 |
|
| 164 |
return tableBoxes
|
| 165 |
|
|
|
|
| 116 |
global queryHelper
|
| 117 |
print(f"Selected tables : {tablesSelected}")
|
| 118 |
metadataLayout = queryHelper.getMetadata()
|
| 119 |
+
allTablesAndCols = metadataLayout.getAllTablesCols()
|
| 120 |
+
selectedTablesAndCols = metadataLayout.getSelectedTablesAndCols()
|
| 121 |
+
allTablesList = list(allTablesAndCols.keys())
|
| 122 |
tableBoxes = []
|
| 123 |
+
for i in range(len(allTablesList)):
|
| 124 |
+
if allTablesList[i] in tablesSelected:
|
| 125 |
+
dd = gr.Dropdown(
|
| 126 |
+
allTablesAndCols[allTablesList[i]],visible=True,value=selectedTablesAndCols.get(allTablesList[i],None), multiselect=True, label=allTablesList[i], info="Select columns of a table"
|
| 127 |
+
)
|
| 128 |
+
tableBoxes.append(dd)
|
| 129 |
else:
|
| 130 |
+
dd = gr.Dropdown(
|
| 131 |
+
allTablesAndCols[allTablesList[i]],visible=False,value=selectedTablesAndCols.get(allTablesList[i],None), multiselect=True, label=allTablesList[i], info="Select columns of a table"
|
| 132 |
+
)
|
| 133 |
+
tableBoxes.append(dd)
|
| 134 |
return tableBoxes
|
| 135 |
|
| 136 |
def onSelectedColumnsChange(*tableBoxes):
|
| 137 |
#update selection of columns and tables (include new tables and cols in gpts context)
|
| 138 |
global queryHelper
|
| 139 |
metadataLayout = queryHelper.getMetadata()
|
| 140 |
+
allTablesAndCols = metadataLayout.getAllTablesCols()
|
| 141 |
+
allTablesList = list(allTablesAndCols.keys())
|
| 142 |
tablesAndCols = {}
|
| 143 |
result = ''
|
| 144 |
print("Getting selected tables and columns from gradio")
|
|
|
|
| 157 |
|
| 158 |
def onResetToDefaultSelection():
|
| 159 |
global queryHelper
|
| 160 |
+
metadataLayout = queryHelper.getMetadata()
|
| 161 |
+
metadataLayout.setSelection(tablesAndCols=tablesAndCols)
|
| 162 |
+
queryHelper.updateMetadata(metadataLayout)
|
| 163 |
+
|
| 164 |
+
metadataLayout = queryHelper.getMetadata()
|
| 165 |
+
allTablesAndCols = metadataLayout.getAllTablesCols()
|
| 166 |
+
selectedTablesAndCols = metadataLayout.getSelectedTablesAndCols()
|
| 167 |
+
allTablesList = list(allTablesAndCols.keys())
|
| 168 |
tableBoxes = []
|
|
|
|
| 169 |
for i in range(len(allTablesList)):
|
| 170 |
+
if allTablesList[i] in selectedTablesAndCols.keys():
|
| 171 |
+
dd = gr.Dropdown(
|
| 172 |
+
allTablesAndCols[allTablesList[i]],visible=True,value=selectedTablesAndCols.get(allTablesList[i],None), multiselect=True, label=allTablesList[i], info="Select columns of a table"
|
| 173 |
+
)
|
| 174 |
+
tableBoxes.append(dd)
|
| 175 |
else:
|
| 176 |
+
dd = gr.Dropdown(
|
| 177 |
+
allTablesAndCols[allTablesList[i]],visible=False,value=selectedTablesAndCols.get(allTablesList[i],None), multiselect=True, label=allTablesList[i], info="Select columns of a table"
|
| 178 |
+
)
|
| 179 |
+
tableBoxes.append(dd)
|
|
|
|
| 180 |
|
| 181 |
return tableBoxes
|
| 182 |
|