NorthernTribe-Research commited on
Commit
888ea35
·
verified ·
1 Parent(s): 0397f06

Fix Gradio Textbox copy-button compatibility in app startup

Browse files
Files changed (2) hide show
  1. README.md +1 -3
  2. app.py +12 -1
README.md CHANGED
@@ -1,10 +1,8 @@
1
  ---
2
  title: Math Conjecture Trainer
3
- emoji: 🧮
4
  sdk: gradio
5
  app_file: app.py
6
  pinned: false
7
- sdk_version: 6.6.0
8
  ---
9
 
10
  # Math Conjecture Trainer Space
@@ -32,4 +30,4 @@ Set this in Space Settings > Variables and Secrets:
32
 
33
  - `configs/deepseek_math_sota.yaml`
34
  - base model default: `deepseek-ai/deepseek-math-v2`
35
- - output root: `workspace/runs/math-conjecture-sota`
 
1
  ---
2
  title: Math Conjecture Trainer
 
3
  sdk: gradio
4
  app_file: app.py
5
  pinned: false
 
6
  ---
7
 
8
  # Math Conjecture Trainer Space
 
30
 
31
  - `configs/deepseek_math_sota.yaml`
32
  - base model default: `deepseek-ai/deepseek-math-v2`
33
+ - output root: `workspace/runs/math-conjecture-sota`
app.py CHANGED
@@ -4,6 +4,7 @@
4
  from __future__ import annotations
5
 
6
  import datetime as dt
 
7
  import json
8
  import os
9
  import shutil
@@ -105,6 +106,16 @@ def stream_subprocess(
105
  return ret
106
 
107
 
 
 
 
 
 
 
 
 
 
 
108
  def run_pipeline(
109
  hf_token: str,
110
  dataset_repo_id: str,
@@ -249,7 +260,7 @@ with gr.Blocks(title="Math Conjecture Trainer Space") as demo:
249
  eval_samples = gr.Slider(label="Eval Max Samples", minimum=50, maximum=1000, step=50, value=300)
250
  run_button = gr.Button("Start Train + Push")
251
  status = gr.Textbox(label="Status", value="Idle")
252
- logs = gr.Textbox(label="Logs", lines=24, max_lines=30, show_copy_button=True)
253
 
254
  run_button.click(
255
  fn=run_pipeline,
 
4
  from __future__ import annotations
5
 
6
  import datetime as dt
7
+ import inspect
8
  import json
9
  import os
10
  import shutil
 
106
  return ret
107
 
108
 
109
+ def make_logs_textbox() -> gr.Textbox:
110
+ textbox_kwargs = {"label": "Logs", "lines": 24, "max_lines": 30}
111
+ textbox_init_params = inspect.signature(gr.Textbox.__init__).parameters
112
+ if "buttons" in textbox_init_params:
113
+ textbox_kwargs["buttons"] = ["copy"]
114
+ elif "show_copy_button" in textbox_init_params:
115
+ textbox_kwargs["show_copy_button"] = True
116
+ return gr.Textbox(**textbox_kwargs)
117
+
118
+
119
  def run_pipeline(
120
  hf_token: str,
121
  dataset_repo_id: str,
 
260
  eval_samples = gr.Slider(label="Eval Max Samples", minimum=50, maximum=1000, step=50, value=300)
261
  run_button = gr.Button("Start Train + Push")
262
  status = gr.Textbox(label="Status", value="Idle")
263
+ logs = make_logs_textbox()
264
 
265
  run_button.click(
266
  fn=run_pipeline,