TillCyrill commited on
Commit
10114c2
1 Parent(s): 6646de2

download button

Browse files
Files changed (2) hide show
  1. main.py +11 -0
  2. mock_download.py +23 -0
main.py CHANGED
@@ -230,6 +230,10 @@ def predict(pdb_code, pdb_file, topN):
230
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
231
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", pd.DataFrame(data, columns=['index','element','x','y','z','Adaptability'])
232
 
 
 
 
 
233
 
234
  callback = gr.CSVLogger()
235
 
@@ -253,11 +257,18 @@ def run():
253
  single_btn = gr.Button(label="Run")
254
  with gr.Row():
255
  html = gr.HTML()
 
 
 
256
  with gr.Row():
257
  dataframe = gr.Dataframe()
258
 
259
  single_btn.click(fn=predict, inputs=[inp, pdb_file, topN], outputs=[html, dataframe])
260
 
 
 
 
 
261
 
262
  demo.launch(server_name="0.0.0.0", server_port=7860)
263
 
 
230
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
231
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", pd.DataFrame(data, columns=['index','element','x','y','z','Adaptability'])
232
 
233
+ def export_csv(d):
234
+ d.to_csv("adaptabilities.csv")
235
+ return gr.File.update(value="adaptabilities.csv", visible=True)
236
+
237
 
238
  callback = gr.CSVLogger()
239
 
 
257
  single_btn = gr.Button(label="Run")
258
  with gr.Row():
259
  html = gr.HTML()
260
+ with gr.Row():
261
+ Dbutton = gr.Button("Download adaptability values")
262
+ csv = gr.File(interactive=False, visible=False)
263
  with gr.Row():
264
  dataframe = gr.Dataframe()
265
 
266
  single_btn.click(fn=predict, inputs=[inp, pdb_file, topN], outputs=[html, dataframe])
267
 
268
+ Dbutton.click(export_csv, dataframe, csv)
269
+
270
+
271
+
272
 
273
  demo.launch(server_name="0.0.0.0", server_port=7860)
274
 
mock_download.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def mock_ocr(f):
4
+ return [[1, 2, 3], [4, 5, 6]]
5
+
6
+ def export_csv(d):
7
+ d.to_csv("output.csv")
8
+ return gr.File.update(value="output.csv", visible=True)
9
+
10
+ with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ file = gr.File(label="PDF file", file_types=[".pdf"])
13
+ dataframe = gr.Dataframe()
14
+
15
+ with gr.Column():
16
+ button = gr.Button("Export")
17
+ csv = gr.File(interactive=False, visible=False)
18
+
19
+
20
+ file.change(mock_ocr, file, dataframe)
21
+ button.click(export_csv, dataframe, csv)
22
+
23
+ demo.launch()