Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,9 @@ from tqdm.auto import tqdm
|
|
| 7 |
from graph import SheamiMilestone, create_graph, SheamiState, HealthReport
|
| 8 |
from pdf_reader import read_pdf
|
| 9 |
from gradio_modal import Modal
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
def disable_component():
|
| 13 |
return gr.update(interactive=False)
|
|
@@ -17,11 +19,16 @@ def enable_component():
|
|
| 17 |
return gr.update(interactive=True)
|
| 18 |
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
else:
|
| 24 |
-
return hide_component()
|
| 25 |
|
| 26 |
|
| 27 |
def construct_process_message(
|
|
@@ -271,6 +278,7 @@ with gr.Blocks(
|
|
| 271 |
resize: none;
|
| 272 |
padding: 8px;
|
| 273 |
max-height: 200px;
|
|
|
|
| 274 |
overflow: auto;
|
| 275 |
}
|
| 276 |
|
|
@@ -319,6 +327,7 @@ with gr.Blocks(
|
|
| 319 |
file_count="multiple",
|
| 320 |
label="Upload your Lab Reports (PDF)",
|
| 321 |
)
|
|
|
|
| 322 |
with gr.Row():
|
| 323 |
gr.Column()
|
| 324 |
about_us_btn = gr.Button("🛈 About", scale=0)
|
|
@@ -352,9 +361,11 @@ with gr.Blocks(
|
|
| 352 |
show_reset_button=False,
|
| 353 |
label="",
|
| 354 |
visible=False,
|
|
|
|
| 355 |
)
|
| 356 |
gr.Row() # spacer
|
| 357 |
logs_textbox = gr.HTML(
|
|
|
|
| 358 |
label="Logs",
|
| 359 |
# lines=1,
|
| 360 |
# max_lines=10,
|
|
@@ -363,18 +374,22 @@ with gr.Blocks(
|
|
| 363 |
visible=False,
|
| 364 |
# show_copy_button=True,
|
| 365 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
milestone_df = gr.DataFrame(
|
| 367 |
-
value=
|
| 368 |
-
headers=
|
| 369 |
-
"Step",
|
| 370 |
-
"Status",
|
| 371 |
-
"Start Time",
|
| 372 |
-
"End Time",
|
| 373 |
-
"Duration (s)",
|
| 374 |
-
],
|
| 375 |
datatype=["str", "str", "str", "str", "str"],
|
| 376 |
interactive=False,
|
| 377 |
visible=True,
|
|
|
|
| 378 |
)
|
| 379 |
|
| 380 |
def hide_slider_if_0_or_100(progress_value):
|
|
@@ -383,16 +398,17 @@ with gr.Blocks(
|
|
| 383 |
else:
|
| 384 |
return show_component()
|
| 385 |
|
| 386 |
-
overall_progress_bar.change(
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
)
|
| 391 |
file_input.change(
|
| 392 |
handle_file_input_change,
|
| 393 |
inputs=[file_input],
|
| 394 |
outputs=[
|
| 395 |
run_btn,
|
|
|
|
| 396 |
],
|
| 397 |
)
|
| 398 |
run_btn.click(show_component, outputs=[logs_textbox]).then(
|
|
@@ -420,3 +436,4 @@ with gr.Blocks(
|
|
| 420 |
|
| 421 |
if __name__ == "__main__":
|
| 422 |
demo.queue().launch(favicon_path="assets/favicon.jpg")
|
|
|
|
|
|
| 7 |
from graph import SheamiMilestone, create_graph, SheamiState, HealthReport
|
| 8 |
from pdf_reader import read_pdf
|
| 9 |
from gradio_modal import Modal
|
| 10 |
+
from dotenv import load_dotenv
|
| 11 |
|
| 12 |
+
load_dotenv(override=True)
|
| 13 |
|
| 14 |
def disable_component():
|
| 15 |
return gr.update(interactive=False)
|
|
|
|
| 19 |
return gr.update(interactive=True)
|
| 20 |
|
| 21 |
|
| 22 |
+
MAX_FILES = os.getenv("MAX_FILES",3)
|
| 23 |
+
|
| 24 |
+
def handle_file_input_change(files):
|
| 25 |
+
if files:
|
| 26 |
+
if(len(files) > MAX_FILES):
|
| 27 |
+
return hide_component(), f"❌ Maximum of {MAX_FILES} files can be uploaded at a time."
|
| 28 |
+
else:
|
| 29 |
+
return show_component(), f"✅ {len(files)} selected."
|
| 30 |
else:
|
| 31 |
+
return hide_component(), "❌ No files selected."
|
| 32 |
|
| 33 |
|
| 34 |
def construct_process_message(
|
|
|
|
| 278 |
resize: none;
|
| 279 |
padding: 8px;
|
| 280 |
max-height: 200px;
|
| 281 |
+
min-height: 300px;
|
| 282 |
overflow: auto;
|
| 283 |
}
|
| 284 |
|
|
|
|
| 327 |
file_count="multiple",
|
| 328 |
label="Upload your Lab Reports (PDF)",
|
| 329 |
)
|
| 330 |
+
file_upload_status = gr.Markdown()
|
| 331 |
with gr.Row():
|
| 332 |
gr.Column()
|
| 333 |
about_us_btn = gr.Button("🛈 About", scale=0)
|
|
|
|
| 361 |
show_reset_button=False,
|
| 362 |
label="",
|
| 363 |
visible=False,
|
| 364 |
+
precision=0
|
| 365 |
)
|
| 366 |
gr.Row() # spacer
|
| 367 |
logs_textbox = gr.HTML(
|
| 368 |
+
value="<div class='transparent_div'>Processing request <span class='dots'></span></div>",
|
| 369 |
label="Logs",
|
| 370 |
# lines=1,
|
| 371 |
# max_lines=10,
|
|
|
|
| 374 |
visible=False,
|
| 375 |
# show_copy_button=True,
|
| 376 |
)
|
| 377 |
+
# Number of empty rows
|
| 378 |
+
num_rows = 5
|
| 379 |
+
|
| 380 |
+
# Headers
|
| 381 |
+
headers = ["Step", "Status", "Start Time", "End Time", "Duration (s)"]
|
| 382 |
+
|
| 383 |
+
# Create empty data (5 rows of empty strings)
|
| 384 |
+
empty_data = [["" for _ in headers] for _ in range(num_rows)]
|
| 385 |
+
|
| 386 |
milestone_df = gr.DataFrame(
|
| 387 |
+
value=empty_data,
|
| 388 |
+
headers=headers,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
datatype=["str", "str", "str", "str", "str"],
|
| 390 |
interactive=False,
|
| 391 |
visible=True,
|
| 392 |
+
row_count=5
|
| 393 |
)
|
| 394 |
|
| 395 |
def hide_slider_if_0_or_100(progress_value):
|
|
|
|
| 398 |
else:
|
| 399 |
return show_component()
|
| 400 |
|
| 401 |
+
# overall_progress_bar.change(
|
| 402 |
+
# hide_slider_if_0_or_100,
|
| 403 |
+
# inputs=[overall_progress_bar],
|
| 404 |
+
# outputs=[overall_progress_bar],
|
| 405 |
+
# )
|
| 406 |
file_input.change(
|
| 407 |
handle_file_input_change,
|
| 408 |
inputs=[file_input],
|
| 409 |
outputs=[
|
| 410 |
run_btn,
|
| 411 |
+
file_upload_status
|
| 412 |
],
|
| 413 |
)
|
| 414 |
run_btn.click(show_component, outputs=[logs_textbox]).then(
|
|
|
|
| 436 |
|
| 437 |
if __name__ == "__main__":
|
| 438 |
demo.queue().launch(favicon_path="assets/favicon.jpg")
|
| 439 |
+
|