Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -787,7 +787,7 @@ def prep_and_save_data(index, skip_sample, completed: bool):
|
|
| 787 |
**(st.session_state.data.iloc[index][COLS_TO_SAVE].to_dict() if 0 <= index < len(st.session_state.data) else {}),
|
| 788 |
**{k: st.session_state[k + str(index)] for k in st.session_state.data_inputs_keys},
|
| 789 |
'skip': skip_sample,
|
| 790 |
-
'completed': completed,
|
| 791 |
}
|
| 792 |
|
| 793 |
for f in iter_all_input_fields():
|
|
@@ -884,10 +884,26 @@ if user_id_from_url and not st.session_state.get("user_id"):
|
|
| 884 |
# current index
|
| 885 |
if 'current_index' not in st.session_state:
|
| 886 |
start_index = get_start_index()
|
| 887 |
-
|
| 888 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 889 |
else:
|
| 890 |
-
st.session_state.current_index =
|
| 891 |
st.session_state.form_displayed = -2
|
| 892 |
|
| 893 |
if 'step' not in st.session_state:
|
|
|
|
| 787 |
**(st.session_state.data.iloc[index][COLS_TO_SAVE].to_dict() if 0 <= index < len(st.session_state.data) else {}),
|
| 788 |
**{k: st.session_state[k + str(index)] for k in st.session_state.data_inputs_keys},
|
| 789 |
'skip': skip_sample,
|
| 790 |
+
'completed': int(completed),
|
| 791 |
}
|
| 792 |
|
| 793 |
for f in iter_all_input_fields():
|
|
|
|
| 884 |
# current index
|
| 885 |
if 'current_index' not in st.session_state:
|
| 886 |
start_index = get_start_index()
|
| 887 |
+
target_index = start_index
|
| 888 |
+
|
| 889 |
+
if start_index > 0:
|
| 890 |
+
last_idx = start_index - 1
|
| 891 |
+
last_path = f"{output_repo_path}/{get_base_path()}/{last_idx}.json"
|
| 892 |
+
if hf_fs.exists(last_path):
|
| 893 |
+
try:
|
| 894 |
+
with hf_fs.open(last_path, "rb") as f:
|
| 895 |
+
last_data = json.load(f)
|
| 896 |
+
except Exception:
|
| 897 |
+
last_data = {}
|
| 898 |
+
completed_val = last_data.get("completed", 1)
|
| 899 |
+
is_completed = bool(completed_val)
|
| 900 |
+
if not is_completed:
|
| 901 |
+
target_index = last_idx
|
| 902 |
+
|
| 903 |
+
if target_index < len(st.session_state.data)-1:
|
| 904 |
+
st.session_state.current_index = target_index
|
| 905 |
else:
|
| 906 |
+
st.session_state.current_index = target_index+1
|
| 907 |
st.session_state.form_displayed = -2
|
| 908 |
|
| 909 |
if 'step' not in st.session_state:
|