taskswithcode commited on
Commit
3baa608
·
1 Parent(s): 4277d83
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -33,13 +33,13 @@ from transformers import BertTokenizer, BertForMaskedLM
33
 
34
 
35
  def get_views(action):
36
- print("in get views",action)
37
  ret_val = 0
38
  hostname = socket.gethostname()
39
  ip_address = socket.gethostbyname(hostname)
40
  if ("view_count" not in st.session_state):
41
  try:
42
- print("inside get views")
43
  app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
44
  res = requests.post(INFO_URL, json = app_info).json()
45
  print(res)
@@ -51,6 +51,7 @@ def get_views(action):
51
  else:
52
  ret_val = st.session_state["view_count"]
53
  if (action != "init"):
 
54
  app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
55
  res = requests.post(INFO_URL, json = app_info).json()
56
  return "{:,}".format(ret_val)
@@ -184,10 +185,14 @@ def display_results(orig_sentences,main_index,results,response_info,app_mode,mod
184
 
185
 
186
  def init_session():
187
- st.session_state["download_ready"] = None
188
- st.session_state["model_name"] = "ss_test"
189
- st.session_state["main_index"] = 1
190
- st.session_state["file_name"] = "default"
 
 
 
 
191
 
192
  def app_main(app_mode,example_files,model_name_files):
193
  init_session()
@@ -234,6 +239,7 @@ def app_main(app_mode,example_files,model_name_files):
234
  input_status_area = st.empty()
235
  display_area = st.empty()
236
  if submit_button:
 
237
  start = time.time()
238
  if uploaded_file is not None:
239
  st.session_state["file_name"] = uploaded_file.name
 
33
 
34
 
35
  def get_views(action):
36
+ #print(f"in get views:outer:{action}")
37
  ret_val = 0
38
  hostname = socket.gethostname()
39
  ip_address = socket.gethostbyname(hostname)
40
  if ("view_count" not in st.session_state):
41
  try:
42
+ #print("inside get views:api request")
43
  app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
44
  res = requests.post(INFO_URL, json = app_info).json()
45
  print(res)
 
51
  else:
52
  ret_val = st.session_state["view_count"]
53
  if (action != "init"):
54
+ #print("non init:api request")
55
  app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
56
  res = requests.post(INFO_URL, json = app_info).json()
57
  return "{:,}".format(ret_val)
 
185
 
186
 
187
  def init_session():
188
+ if ("main_index" not in st.session_state):
189
+ print("Performing init session")
190
+ st.session_state["download_ready"] = None
191
+ st.session_state["model_name"] = "ss_test"
192
+ st.session_state["main_index"] = 1
193
+ st.session_state["file_name"] = "default"
194
+ else:
195
+ print("****Skipping init session")
196
 
197
  def app_main(app_mode,example_files,model_name_files):
198
  init_session()
 
239
  input_status_area = st.empty()
240
  display_area = st.empty()
241
  if submit_button:
242
+ print("Inside submit")
243
  start = time.time()
244
  if uploaded_file is not None:
245
  st.session_state["file_name"] = uploaded_file.name