Update upload_suggestions.py
Browse files- upload_suggestions.py +16 -8
upload_suggestions.py
CHANGED
@@ -10,12 +10,21 @@ CHECKSUM_FILE = "/app/.last_suggestions_checksum"
|
|
10 |
|
11 |
def get_suggestions_db_path():
|
12 |
cwd = os.getcwd()
|
13 |
-
print(f"Running in CWD: {cwd}")
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return None
|
20 |
|
21 |
def file_checksum(path):
|
@@ -59,8 +68,7 @@ def upload_if_updated():
|
|
59 |
path_in_repo=DEST_PATH_IN_REPO,
|
60 |
repo_id=REPO_ID,
|
61 |
repo_type="space",
|
62 |
-
token=HF_TOKEN
|
63 |
-
overwrite=True
|
64 |
)
|
65 |
save_checksum(current_checksum)
|
66 |
print(f"Upload successful at {time.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
|
10 |
|
11 |
def get_suggestions_db_path():
|
12 |
cwd = os.getcwd()
|
13 |
+
print(f"Running in CWD: {cwd}")
|
14 |
+
|
15 |
+
possible_paths = [
|
16 |
+
os.path.join(cwd, "db", "suggestions.db"),
|
17 |
+
"/root/.local/share/db/suggestions.db",
|
18 |
+
"/home/libretranslate/.local/share/db/suggestions.db",
|
19 |
+
"/app/.local/share/db/suggestions.db"
|
20 |
+
]
|
21 |
+
|
22 |
+
for path in possible_paths:
|
23 |
+
if os.path.exists(path):
|
24 |
+
print(f"Found suggestions.db at {path}")
|
25 |
+
return path
|
26 |
+
|
27 |
+
print("suggestions.db not found in any known path.")
|
28 |
return None
|
29 |
|
30 |
def file_checksum(path):
|
|
|
68 |
path_in_repo=DEST_PATH_IN_REPO,
|
69 |
repo_id=REPO_ID,
|
70 |
repo_type="space",
|
71 |
+
token=HF_TOKEN
|
|
|
72 |
)
|
73 |
save_checksum(current_checksum)
|
74 |
print(f"Upload successful at {time.strftime('%Y-%m-%d %H:%M:%S')}")
|