rmm commited on
Commit
8609001
·
1 Parent(s): 6d20197

feat: inputs frozen after validation clicked

Browse files
src/input/input_handling.py CHANGED
@@ -249,6 +249,7 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
249
  latitude = viewcontainer.text_input(
250
  "Latitude for " + filename,
251
  latitude0,
 
252
  #key=f"input_latitude_{image_hash}")
253
  )
254
  if latitude and not is_valid_number(latitude):
@@ -258,6 +259,7 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
258
  longitude = viewcontainer.text_input(
259
  "Longitude for " + filename,
260
  longitude0,
 
261
  #key=f"input_longitude_{image_hash}")
262
  )
263
  if longitude and not is_valid_number(longitude):
@@ -296,8 +298,10 @@ def metadata_inputs_one_file(file:UploadedFile, image_hash:str, dbg_ix:int=0) ->
296
 
297
 
298
  ## either way, give user the option to enter manually (or correct, e.g. if camera has no rtc clock)
299
- date = viewcontainer.date_input("Date for "+filename, value=date_value, key=f"input_date_{image_hash}")
300
- time = viewcontainer.time_input("Time for "+filename, time_value, key=f"input_time_{image_hash}")
 
 
301
 
302
  tz_str = dt.strftime('%z') # this is numeric, otherwise the info isn't consistent.
303
 
@@ -368,6 +372,7 @@ def _setup_oneoff_inputs() -> None:
368
  #print(f"[D] author email: {text0}")
369
  author_email = st.text_input("Author Email",
370
  value=st.session_state.get("input_author_email", None),
 
371
  #spoof_metadata.get('author_email', ""),
372
  #key="input_author_email")
373
  )
@@ -381,6 +386,7 @@ def _setup_oneoff_inputs() -> None:
381
  st.file_uploader(
382
  "Upload one or more images", type=["png", 'jpg', 'jpeg', 'webp'],
383
  accept_multiple_files=True,
 
384
  key="file_uploader_data", on_change=buffer_uploaded_files)
385
 
386
 
 
249
  latitude = viewcontainer.text_input(
250
  "Latitude for " + filename,
251
  latitude0,
252
+ disabled=st.session_state.get("input_disabled", False),
253
  #key=f"input_latitude_{image_hash}")
254
  )
255
  if latitude and not is_valid_number(latitude):
 
259
  longitude = viewcontainer.text_input(
260
  "Longitude for " + filename,
261
  longitude0,
262
+ disabled=st.session_state.get("input_disabled", False),
263
  #key=f"input_longitude_{image_hash}")
264
  )
265
  if longitude and not is_valid_number(longitude):
 
298
 
299
 
300
  ## either way, give user the option to enter manually (or correct, e.g. if camera has no rtc clock)
301
+ date = viewcontainer.date_input("Date for "+filename, value=date_value, key=f"input_date_{image_hash}",
302
+ disabled=st.session_state.get("input_disabled", False), )
303
+ time = viewcontainer.time_input("Time for "+filename, time_value, key=f"input_time_{image_hash}",
304
+ disabled=st.session_state.get("input_disabled", False),)
305
 
306
  tz_str = dt.strftime('%z') # this is numeric, otherwise the info isn't consistent.
307
 
 
372
  #print(f"[D] author email: {text0}")
373
  author_email = st.text_input("Author Email",
374
  value=st.session_state.get("input_author_email", None),
375
+ disabled=st.session_state.get("input_disabled", False),
376
  #spoof_metadata.get('author_email', ""),
377
  #key="input_author_email")
378
  )
 
386
  st.file_uploader(
387
  "Upload one or more images", type=["png", 'jpg', 'jpeg', 'webp'],
388
  accept_multiple_files=True,
389
+ disabled=st.session_state.get("input_disabled", False),
390
  key="file_uploader_data", on_change=buffer_uploaded_files)
391
 
392
 
src/pages/4_🔥_classifiers.py CHANGED
@@ -86,10 +86,15 @@ with tab_inference:
86
  df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
87
  # with tab_coords:
88
  # st.table(df)
 
 
 
 
89
  # there doesn't seem to be any actual validation here?? TODO: find validator function (each element is validated by the input box, but is there something at the whole image level?)
90
  # hmm, maybe it should actually just be "I'm done with data entry"
91
  st.session_state.workflow_fsm.complete_current_state()
92
  # -> data_entry_validated
 
93
 
94
  if st.session_state.MODE_DEV_STATEFUL:
95
  dbg_show_observation_hashes()
 
86
  df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
87
  # with tab_coords:
88
  # st.table(df)
89
+
90
+ # now disable all the input boxes / widgets
91
+ st.session_state.input_disabled = True
92
+
93
  # there doesn't seem to be any actual validation here?? TODO: find validator function (each element is validated by the input box, but is there something at the whole image level?)
94
  # hmm, maybe it should actually just be "I'm done with data entry"
95
  st.session_state.workflow_fsm.complete_current_state()
96
  # -> data_entry_validated
97
+ st.rerun() # refresh so the input widgets are immediately disabled
98
 
99
  if st.session_state.MODE_DEV_STATEFUL:
100
  dbg_show_observation_hashes()
src/utils/workflow_ui.py CHANGED
@@ -9,6 +9,11 @@ def init_workflow_session_states():
9
  if "workflow_fsm" not in st.session_state:
10
  # create and init the state machine
11
  st.session_state.workflow_fsm = WorkflowFSM(FSM_STATES)
 
 
 
 
 
12
 
13
  def refresh_progress_display() -> None:
14
  """
 
9
  if "workflow_fsm" not in st.session_state:
10
  # create and init the state machine
11
  st.session_state.workflow_fsm = WorkflowFSM(FSM_STATES)
12
+
13
+ if "input_disabled" not in st.session_state:
14
+ # after workflow reaches some stage, disable chance to change inputs
15
+ st.session_state.input_disabled = False
16
+
17
 
18
  def refresh_progress_display() -> None:
19
  """