Spaces:
Running
Running
run health check on demand
Browse files- demo/app.py +6 -4
- demo/health.py +2 -2
- demo/layout.py +8 -7
demo/app.py
CHANGED
|
@@ -5,19 +5,21 @@ import os
|
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
import health
|
| 8 |
-
from layout import CELL_CSS,
|
| 9 |
|
| 10 |
|
| 11 |
def render_health_panel() -> str:
|
| 12 |
-
return
|
| 13 |
|
| 14 |
|
| 15 |
def create_app() -> gr.Blocks:
|
| 16 |
"""Create the Gradio application with a minimal notebook-like health cell."""
|
| 17 |
with gr.Blocks(title="Aileen3 Demo") as demo:
|
| 18 |
gr.HTML(f"<style>{CELL_CSS}</style>")
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
return demo
|
| 22 |
|
| 23 |
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
import health
|
| 8 |
+
from layout import CELL_CSS, cell
|
| 9 |
|
| 10 |
|
| 11 |
def render_health_panel() -> str:
|
| 12 |
+
return health.render_health_notice()
|
| 13 |
|
| 14 |
|
| 15 |
def create_app() -> gr.Blocks:
|
| 16 |
"""Create the Gradio application with a minimal notebook-like health cell."""
|
| 17 |
with gr.Blocks(title="Aileen3 Demo") as demo:
|
| 18 |
gr.HTML(f"<style>{CELL_CSS}</style>")
|
| 19 |
+
with cell("🧪 Health check"):
|
| 20 |
+
health_panel = gr.HTML(value=health.render_placeholder_notice())
|
| 21 |
+
run_button = gr.Button("Run health check", variant="primary")
|
| 22 |
+
run_button.click(fn=render_health_panel, outputs=health_panel, queue=False)
|
| 23 |
return demo
|
| 24 |
|
| 25 |
|
demo/health.py
CHANGED
|
@@ -233,7 +233,7 @@ def render_health_notice() -> str:
|
|
| 233 |
def render_placeholder_notice() -> str:
|
| 234 |
return (
|
| 235 |
"<div class='health-box health-placeholder'>"
|
| 236 |
-
"<div class='health-head'
|
| 237 |
-
"<p>
|
| 238 |
"</div>"
|
| 239 |
)
|
|
|
|
| 233 |
def render_placeholder_notice() -> str:
|
| 234 |
return (
|
| 235 |
"<div class='health-box health-placeholder'>"
|
| 236 |
+
"<div class='health-head'>🛠 Ready when you are.</div>"
|
| 237 |
+
"<p>Press the button below to run the health check before executing other cells.</p>"
|
| 238 |
"</div>"
|
| 239 |
)
|
demo/layout.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
CELL_CSS = """
|
| 4 |
.cell-wrapper {
|
| 5 |
border: 1px solid rgba(0, 0, 0, 0.9);
|
|
@@ -63,10 +66,8 @@ CELL_CSS = """
|
|
| 63 |
"""
|
| 64 |
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
"<div class='cell-title'
|
| 70 |
-
|
| 71 |
-
"</section>"
|
| 72 |
-
)
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
+
from contextlib import contextmanager
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
CELL_CSS = """
|
| 7 |
.cell-wrapper {
|
| 8 |
border: 1px solid rgba(0, 0, 0, 0.9);
|
|
|
|
| 66 |
"""
|
| 67 |
|
| 68 |
|
| 69 |
+
@contextmanager
|
| 70 |
+
def cell(title: str):
|
| 71 |
+
with gr.Column(elem_classes="cell-wrapper") as column:
|
| 72 |
+
gr.HTML(f"<div class='cell-title'>{title}</div>")
|
| 73 |
+
yield column
|
|
|
|
|
|