Spaces:
Runtime error
Runtime error
Commit ·
ceec937
1
Parent(s): b73a352
downloadable log files as tab
Browse files
app.py
CHANGED
|
@@ -16,6 +16,9 @@ from utils import *
|
|
| 16 |
from gptManager import ChatgptManager
|
| 17 |
# from queryHelper import QueryHelper
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
pd.set_option('display.max_columns', None)
|
| 20 |
pd.set_option('display.max_rows', None)
|
| 21 |
|
|
@@ -258,10 +261,40 @@ def onResetToDefaultSelection():
|
|
| 258 |
|
| 259 |
return tableBoxes
|
| 260 |
|
|
|
|
|
|
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
-
with gr.Blocks() as demo:
|
| 264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
# screen 1 : Chatbot for question answering to generate sql query from user input in english
|
| 266 |
with gr.Tab("Query Helper"):
|
| 267 |
gr.Markdown("""<h1><center> Query Helper</center></h1>""")
|
|
@@ -320,6 +353,15 @@ with gr.Blocks() as demo:
|
|
| 320 |
|
| 321 |
resetToDefaultSelection = gr.Button("Reset to Default")
|
| 322 |
resetToDefaultSelection.click(onResetToDefaultSelection, inputs=None, outputs=tableBoxes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
|
| 325 |
demo.launch(share=True, debug=True, ssl_verify=False, auth=checkAuth)
|
|
|
|
| 16 |
from gptManager import ChatgptManager
|
| 17 |
# from queryHelper import QueryHelper
|
| 18 |
|
| 19 |
+
logs_dir = os.getenv("HF_HOME", "/data")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
pd.set_option('display.max_columns', None)
|
| 23 |
pd.set_option('display.max_rows', None)
|
| 24 |
|
|
|
|
| 261 |
|
| 262 |
return tableBoxes
|
| 263 |
|
| 264 |
+
import gradio as gr
|
| 265 |
+
import os
|
| 266 |
|
| 267 |
+
# Define your function
|
| 268 |
+
def getAllLogFilesUrls():
|
| 269 |
+
global logs_dir
|
| 270 |
+
# Save processed data to temporary file
|
| 271 |
+
logFiles = [file for file in os.listdir(logs_dir) if ('log' in file and '.csv' in file) ]
|
| 272 |
+
|
| 273 |
+
downloadableFiles = [{"url":f"/download?file_path={logFilePath}", "name":logFilePath} for logFilePath in logFiles]
|
| 274 |
+
return downloadableFiles
|
| 275 |
|
|
|
|
| 276 |
|
| 277 |
+
|
| 278 |
+
# Download function
|
| 279 |
+
def handle_button_click(download_url):
|
| 280 |
+
# Open the download URL in a new browser tab
|
| 281 |
+
js = f"window.open('{download_url}', '_blank')"
|
| 282 |
+
gr.run_js(js)
|
| 283 |
+
|
| 284 |
+
# Connect button click to download
|
| 285 |
+
download_button.click(handle_button_click, inputs=process_data, outputs=[0])
|
| 286 |
+
|
| 287 |
+
# Build the Gradio interface
|
| 288 |
+
with gr.Blocks() as interface:
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
# Launch the interface
|
| 292 |
+
interface.launch()
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
with gr.Blocks() as demo:
|
| 298 |
# screen 1 : Chatbot for question answering to generate sql query from user input in english
|
| 299 |
with gr.Tab("Query Helper"):
|
| 300 |
gr.Markdown("""<h1><center> Query Helper</center></h1>""")
|
|
|
|
| 353 |
|
| 354 |
resetToDefaultSelection = gr.Button("Reset to Default")
|
| 355 |
resetToDefaultSelection.click(onResetToDefaultSelection, inputs=None, outputs=tableBoxes)
|
| 356 |
+
|
| 357 |
+
#screen 4 for downloading logs
|
| 358 |
+
with gr.Tab("Log-files"):
|
| 359 |
+
downloadableFiles = getAllLogFilesUrls()
|
| 360 |
+
buttons = []
|
| 361 |
+
for downloadableFile in downloadableFiles:
|
| 362 |
+
button = gr.Button(f"Download {downloadableFile['name']}")
|
| 363 |
+
button.click(lambda url: gr.run_js(f"window.open('{url}', '_blank')"), inputs=[downloadableFile["url"]])
|
| 364 |
+
buttons.append(button)
|
| 365 |
|
| 366 |
|
| 367 |
demo.launch(share=True, debug=True, ssl_verify=False, auth=checkAuth)
|