emvecchi commited on
Commit
ec9d229
1 Parent(s): 65d9b9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -565,10 +565,13 @@ if 0 <= st.session_state.current_index < len(st.session_state.data):
565
  def navigate_to_index():
566
  try:
567
  go_to_index = int(st.session_state.go_to)-1
 
568
  # Check if the index is within the valid range
569
  if 0 <= go_to_index < len(st.session_state.data):
570
- st.session_state.current_index = go_to_index
571
- #st.experimental_rerun()
 
 
572
  else:
573
  st.info(f"{st.session_state.go_to} is not in the range of data.")
574
  except ValueError:
@@ -580,7 +583,6 @@ with col2:
580
  st.number_input("Go to Page: ", key="go_to", format="%.0f")
581
  if st.form_submit_button("Go"):
582
  navigate_to_index()
583
- #st.form_submit_button("Go", on_click=navigate_to_index)
584
 
585
  st.markdown(
586
  """<style>
 
565
  def navigate_to_index():
566
  try:
567
  go_to_index = int(st.session_state.go_to)-1
568
+ farthest_index = get_start_index()
569
  # Check if the index is within the valid range
570
  if 0 <= go_to_index < len(st.session_state.data):
571
+ if go_to_index <= farthest_index:
572
+ st.session_state.current_index = go_to_index
573
+ else:
574
+ st.info(f"You have not annotated up to instance #{st.session_state.go_to} yet. Your last annotated instance was #{farthest_index+1}.")
575
  else:
576
  st.info(f"{st.session_state.go_to} is not in the range of data.")
577
  except ValueError:
 
583
  st.number_input("Go to Page: ", key="go_to", format="%.0f")
584
  if st.form_submit_button("Go"):
585
  navigate_to_index()
 
586
 
587
  st.markdown(
588
  """<style>