emvecchi commited on
Commit
72d052b
·
verified ·
1 Parent(s): 32cdd9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -59,6 +59,18 @@ INPUT_FIELD_DEFAULT_VALUES = {'slider': 0,
59
  SHOW_HELP_ICON = False
60
  SHOW_VALIDATION_ERROR_MESSAGE = True
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ########################################################################################
63
  if filesystem == 'hf':
64
  HF_TOKEN = os.environ.get("HF_TOKEN_WRITE")
@@ -72,7 +84,7 @@ def get_start_index():
72
  try:
73
  files = hf_fs.ls(base_dir)
74
  except Exception as e:
75
- return -2
76
  return len(files)
77
 
78
  def read_data():
@@ -593,8 +605,7 @@ div[data-testid="stMarkdownContainer"] > p {
593
  """, unsafe_allow_html=True)
594
 
595
  def add_annotation_guidelines():
596
- guidelines_text = load_text("texts/guidelines.md")
597
- #st.write(f"username is {st.session_state.user_id}")
598
  st.markdown(
599
  f"<details><summary><b>Annotation Guidelines</b></summary><div>{guidelines_text}</div></details><br>",
600
  unsafe_allow_html=True)
@@ -657,7 +668,7 @@ if 'current_index' not in st.session_state:
657
  st.session_state.current_index = target_index
658
  else:
659
  st.session_state.current_index = target_index+1
660
- st.session_state.form_displayed = -2
661
 
662
  if 'step' not in st.session_state:
663
  st.session_state.step = 0
@@ -682,11 +693,17 @@ def load_text(path: str) -> str:
682
  with open(path, "r", encoding="utf-8") as f:
683
  return f.read()
684
 
685
- if st.session_state.current_index == -2:
686
  with st.form("data_form"):
687
  st.markdown(consent_text)
688
  add_checked_submit()
689
 
 
 
 
 
 
 
690
  elif st.session_state.current_index == -1:
691
  if st.session_state.get('user_id') and st.session_state.get("batch"):
692
  navigate(1)
 
59
  SHOW_HELP_ICON = False
60
  SHOW_VALIDATION_ERROR_MESSAGE = True
61
 
62
+ annotation_guidelines_fields: List[Field] = [
63
+ Field(name="annotation_guidelines", type="radio", title="Did you read the guidelines?", mandatory=True,
64
+ other_params={'labels': ['Yes, in detail, and I understand the study',
65
+ 'Yes, in detail, but still confused',
66
+ 'Yes, I skimmed it',
67
+ 'I will read it later',
68
+ 'No, not interested in reading them',
69
+ 'I can not open the link',
70
+ ],
71
+ 'accepted_values': [0]}),
72
+ ]
73
+
74
  ########################################################################################
75
  if filesystem == 'hf':
76
  HF_TOKEN = os.environ.get("HF_TOKEN_WRITE")
 
84
  try:
85
  files = hf_fs.ls(base_dir)
86
  except Exception as e:
87
+ return -3
88
  return len(files)
89
 
90
  def read_data():
 
605
  """, unsafe_allow_html=True)
606
 
607
  def add_annotation_guidelines():
608
+ guidelines_text = load_text("guidelines.md")
 
609
  st.markdown(
610
  f"<details><summary><b>Annotation Guidelines</b></summary><div>{guidelines_text}</div></details><br>",
611
  unsafe_allow_html=True)
 
668
  st.session_state.current_index = target_index
669
  else:
670
  st.session_state.current_index = target_index+1
671
+ st.session_state.form_displayed = -3
672
 
673
  if 'step' not in st.session_state:
674
  st.session_state.step = 0
 
693
  with open(path, "r", encoding="utf-8") as f:
694
  return f.read()
695
 
696
+ if st.session_state.current_index == -3:
697
  with st.form("data_form"):
698
  st.markdown(consent_text)
699
  add_checked_submit()
700
 
701
+ elif st.session_state.current_index == -2:
702
+ with st.form("intro_form"):
703
+ st.markdown("# Annotation Guidelines")
704
+ st.markdown(load_text("guidelines.md"))
705
+ show_fields(annotation_guidelines_fields)
706
+
707
  elif st.session_state.current_index == -1:
708
  if st.session_state.get('user_id') and st.session_state.get("batch"):
709
  navigate(1)