Show that a download is being prepared
#13
by lvwerra HF Staff - opened
app.css
CHANGED
|
@@ -78,3 +78,7 @@
|
|
| 78 |
#atlas-database .db-actions > * { flex:0 0 auto!important; width:auto!important; min-width:0!important; padding:0 18px; }
|
| 79 |
#atlas-database .db-toolbar fieldset .wrap { flex-wrap:nowrap; }
|
| 80 |
#atlas-database .db-toolbar fieldset label { white-space:nowrap; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
#atlas-database .db-actions > * { flex:0 0 auto!important; width:auto!important; min-width:0!important; padding:0 18px; }
|
| 79 |
#atlas-database .db-toolbar fieldset .wrap { flex-wrap:nowrap; }
|
| 80 |
#atlas-database .db-toolbar fieldset label { white-space:nowrap; }
|
| 81 |
+
#db-prepare:disabled { opacity:1; cursor:progress; }
|
| 82 |
+
#db-prepare:disabled::before { content:""; display:inline-block; width:11px; height:11px; margin-right:8px; vertical-align:-1px;
|
| 83 |
+
border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:db-spin .8s linear infinite; }
|
| 84 |
+
@keyframes db-spin { to { transform:rotate(360deg); } }
|
app.py
CHANGED
|
@@ -203,7 +203,7 @@ def build_app(catalog=None):
|
|
| 203 |
threshold = gr.Slider(0, 1, value=0.5, step=0.01, label="Threshold", min_width=200, scale=3)
|
| 204 |
with gr.Row(elem_classes="db-actions"):
|
| 205 |
view = gr.Button("Update region", variant="primary", size="sm", min_width=140, scale=0)
|
| 206 |
-
download = gr.Button("Prepare download", size="sm", min_width=150, scale=0)
|
| 207 |
file = gr.DownloadButton("Download per-base data (.parquet)", visible=False,
|
| 208 |
size="sm", min_width=240, scale=0)
|
| 209 |
plot = gr.Plot(show_label=False, elem_id="annotation-plot")
|
|
@@ -245,7 +245,21 @@ def build_app(catalog=None):
|
|
| 245 |
view.click(update_window, region_inputs, [plot, note])
|
| 246 |
mode.input(update_window, region_inputs, [plot, note])
|
| 247 |
threshold.release(update_window, region_inputs, [plot, note])
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
return demo
|
| 250 |
|
| 251 |
|
|
|
|
| 203 |
threshold = gr.Slider(0, 1, value=0.5, step=0.01, label="Threshold", min_width=200, scale=3)
|
| 204 |
with gr.Row(elem_classes="db-actions"):
|
| 205 |
view = gr.Button("Update region", variant="primary", size="sm", min_width=140, scale=0)
|
| 206 |
+
download = gr.Button("Prepare download", size="sm", min_width=150, scale=0, elem_id="db-prepare")
|
| 207 |
file = gr.DownloadButton("Download per-base data (.parquet)", visible=False,
|
| 208 |
size="sm", min_width=240, scale=0)
|
| 209 |
plot = gr.Plot(show_label=False, elem_id="annotation-plot")
|
|
|
|
| 245 |
view.click(update_window, region_inputs, [plot, note])
|
| 246 |
mode.input(update_window, region_inputs, [plot, note])
|
| 247 |
threshold.release(update_window, region_inputs, [plot, note])
|
| 248 |
+
# Writing a large segment takes seconds, and the only output is hidden
|
| 249 |
+
# until it is done, so the button itself has to show the work. One
|
| 250 |
+
# generator covers busy, done and failed: a chained .then does not run
|
| 251 |
+
# after an error, which left the button stuck on "Preparing".
|
| 252 |
+
def prepare(index):
|
| 253 |
+
idle = gr.Button("Prepare download", interactive=True)
|
| 254 |
+
yield gr.Button("Preparing download…", interactive=False), gr.DownloadButton(visible=False)
|
| 255 |
+
try:
|
| 256 |
+
ready = export(index)
|
| 257 |
+
except gr.Error:
|
| 258 |
+
yield idle, gr.DownloadButton(visible=False)
|
| 259 |
+
raise
|
| 260 |
+
yield idle, ready
|
| 261 |
+
|
| 262 |
+
download.click(prepare, selected, [download, file], show_progress="hidden")
|
| 263 |
return demo
|
| 264 |
|
| 265 |
|