Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -229,11 +229,18 @@ else:
|
|
| 229 |
hf_fs = LocalFileSystem()
|
| 230 |
|
| 231 |
def get_start_index():
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
return -2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
def read_data():
|
| 239 |
with hf_fs.open(input_repo_path + '/' + to_annotate_file_name) as f:
|
|
@@ -900,16 +907,16 @@ if 'current_index' not in st.session_state:
|
|
| 900 |
if start_index > 0:
|
| 901 |
last_idx = start_index - 1
|
| 902 |
last_path = f"{output_repo_path}/{get_base_path()}/{last_idx}.json"
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
|
| 914 |
if target_index < len(st.session_state.data)-1:
|
| 915 |
st.session_state.current_index = target_index
|
|
|
|
| 229 |
hf_fs = LocalFileSystem()
|
| 230 |
|
| 231 |
def get_start_index():
|
| 232 |
+
base_dir = f"{output_repo_path}/{get_base_path()}"
|
| 233 |
+
try:
|
| 234 |
+
files = hf_fs.ls(base_dir)
|
| 235 |
+
except Exception as e:
|
| 236 |
return -2
|
| 237 |
+
return len(files)
|
| 238 |
+
|
| 239 |
+
#if hf_fs.exists(output_repo_path + '/' + get_base_path()):
|
| 240 |
+
# files = hf_fs.ls(output_repo_path + '/' + get_base_path())
|
| 241 |
+
# return len(files) #-1
|
| 242 |
+
#else:
|
| 243 |
+
# return -2
|
| 244 |
|
| 245 |
def read_data():
|
| 246 |
with hf_fs.open(input_repo_path + '/' + to_annotate_file_name) as f:
|
|
|
|
| 907 |
if start_index > 0:
|
| 908 |
last_idx = start_index - 1
|
| 909 |
last_path = f"{output_repo_path}/{get_base_path()}/{last_idx}.json"
|
| 910 |
+
try:
|
| 911 |
+
with hf_fs.open(last_path, "rb") as f:
|
| 912 |
+
last_data = json.load(f)
|
| 913 |
+
except Exception:
|
| 914 |
+
last_data = {}
|
| 915 |
+
|
| 916 |
+
completed_val = last_data.get("completed", 1)
|
| 917 |
+
is_completed = bool(completed_val)
|
| 918 |
+
if not is_completed:
|
| 919 |
+
target_index = last_idx
|
| 920 |
|
| 921 |
if target_index < len(st.session_state.data)-1:
|
| 922 |
st.session_state.current_index = target_index
|