vaibhavsharda commited on
Commit
5b74bcd
1 Parent(s): ed5c0c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -220,7 +220,6 @@ def app_main(app_mode,example_files,model_name_files,clus_types):
220
 
221
  try:
222
 
223
-
224
  with st.form('twc_form'):
225
 
226
  step1_line = "Upload text file(one sentence in a line) or choose an example text file below"
@@ -245,14 +244,6 @@ def app_main(app_mode,example_files,model_name_files,clus_types):
245
  options = list(dict.keys(cluster_types)), index=0, key = "twc_cluster_types")
246
  st.write("")
247
  submit_button = st.form_submit_button('Run')
248
- st.download_button(
249
- label="Download results as json",
250
- data= st.session_state["download_ready"] if st.session_state["download_ready"] != None else "",
251
- disabled = False if st.session_state["download_ready"] != None else True,
252
- file_name= (st.session_state["model_name"] + "_" + str(st.session_state["threshold"]) + "_" + st.session_state["overlapped"] + "_" + '_'.join(st.session_state["file_name"].split(".")[:-1]) + ".json").replace("/","_"),
253
- mime='text/json',
254
- key ="download"
255
- )
256
 
257
 
258
  input_status_area = st.empty()
@@ -288,13 +279,35 @@ def app_main(app_mode,example_files,model_name_files,clus_types):
288
  st.info("Custom model overrides model selection in step 2 above. So please clear the custom model text box to choose models from step 2")
289
  display_results(sentences,results,response_info,app_mode,run_model)
290
  #st.json(results)
291
-
 
 
 
 
 
 
 
 
 
 
 
292
 
293
 
294
 
295
  except Exception as e:
296
  st.error("Some error occurred during loading" + str(e))
297
- st.stop()
 
 
 
 
 
 
 
 
 
 
 
298
 
299
  st.markdown(markdown_str, unsafe_allow_html=True)
300
 
 
220
 
221
  try:
222
 
 
223
  with st.form('twc_form'):
224
 
225
  step1_line = "Upload text file(one sentence in a line) or choose an example text file below"
 
244
  options = list(dict.keys(cluster_types)), index=0, key = "twc_cluster_types")
245
  st.write("")
246
  submit_button = st.form_submit_button('Run')
 
 
 
 
 
 
 
 
247
 
248
 
249
  input_status_area = st.empty()
 
279
  st.info("Custom model overrides model selection in step 2 above. So please clear the custom model text box to choose models from step 2")
280
  display_results(sentences,results,response_info,app_mode,run_model)
281
  #st.json(results)
282
+
283
+ if submit_button:
284
+ st.download_button(
285
+ label="Download results as JSON",
286
+ data=st.session_state["download_ready"] if st.session_state["download_ready"] is not None else "",
287
+ disabled=not st.session_state["download_ready"],
288
+ file_name=(st.session_state["model_name"] + "_" + str(st.session_state["threshold"]) + "_" +
289
+ st.session_state["overlapped"] + "_" + '_'.join(st.session_state["file_name"].split(".")[:-1]) +
290
+ ".json").replace("/", "_"),
291
+ mime='text/json',
292
+ key="download"
293
+ )
294
 
295
 
296
 
297
  except Exception as e:
298
  st.error("Some error occurred during loading" + str(e))
299
+ if submit_button:
300
+ st.download_button(
301
+ label="Download results as JSON",
302
+ data=st.session_state["download_ready"] if st.session_state["download_ready"] is not None else "",
303
+ disabled=not st.session_state["download_ready"],
304
+ file_name=(st.session_state["model_name"] + "_" + str(st.session_state["threshold"]) + "_" +
305
+ st.session_state["overlapped"] + "_" + '_'.join(st.session_state["file_name"].split(".")[:-1]) +
306
+ ".json").replace("/", "_"),
307
+ mime='text/json',
308
+ key="download"
309
+ )
310
+ #st.stop()
311
 
312
  st.markdown(markdown_str, unsafe_allow_html=True)
313