ndurner commited on
Commit
83b02d0
·
1 Parent(s): 14937f7

run health check on demand

Browse files
Files changed (3) hide show
  1. demo/app.py +6 -4
  2. demo/health.py +2 -2
  3. 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, wrap_cell
9
 
10
 
11
  def render_health_panel() -> str:
12
- return wrap_cell(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
- health_panel = gr.HTML(value=wrap_cell(health.render_placeholder_notice()))
20
- demo.load(fn=render_health_panel, outputs=health_panel, queue=False)
 
 
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'>⏳ Running automated health check…</div>"
237
- "<p>Step 0 runs implicitly to validate Deno and yt-dlp before any other cell.</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
- def wrap_cell(body_html: str) -> str:
67
- return (
68
- "<section class='cell-wrapper'>"
69
- "<div class='cell-title'>🧪 Health check</div>"
70
- f"{body_html}"
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