Update Dockerfile
Browse files- Dockerfile +26 -25
Dockerfile
CHANGED
@@ -1,29 +1,30 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# Download and install the Kabyle model
|
15 |
-
RUN curl -L -o /app/en_kab_comp.argosmodel \
|
16 |
-
https://huggingface.co/spaces/axxam/LibreTranslate_Kabyle/resolve/main/en_kab_comp.argosmodel && \
|
17 |
-
/app/venv/bin/python3 -c "import argostranslate.package; argostranslate.package.install_from_path('/app/en_kab_comp.argosmodel')"
|
18 |
-
|
19 |
-
# Set environment variables
|
20 |
-
ENV LT_HOST="0.0.0.0"
|
21 |
-
ENV LT_PORT="7860"
|
22 |
-
ENV LT_LOAD_ONLY="en,fr,kab_comp"
|
23 |
-
ENV LT_SSL=True
|
24 |
-
ENV LT_SUGGESTIONS="true"
|
25 |
-
ENV LT_REQ_LIMIT="100"
|
26 |
-
ENV LT_FRONTEND_LANGUAGE_SOURCE="en"
|
27 |
-
ENV LT_FRONTEND_LANGUAGE_TARGET="kab_comp"
|
28 |
-
|
29 |
-
ENTRYPOINT ["/app/venv/bin/libretranslate"]
|
|
|
1 |
+
import os
|
2 |
+
from huggingface_hub import HfApi
|
3 |
|
4 |
+
SUGGESTIONS_FILE = "/app/suggestions/suggestions.jsonl"
|
5 |
+
REPO_ID = "axxam/LibreTranslate_Kabyle"
|
6 |
|
7 |
+
def upload():
|
8 |
+
token = os.environ.get("HF_TOKEN")
|
9 |
+
if not token:
|
10 |
+
print("HF_TOKEN not set. Skipping upload.")
|
11 |
+
return
|
12 |
+
if not os.path.exists(SUGGESTIONS_FILE):
|
13 |
+
print("No suggestions file found. Nothing to upload.")
|
14 |
+
return
|
15 |
|
16 |
+
api = HfApi()
|
17 |
+
try:
|
18 |
+
api.upload_file(
|
19 |
+
path_or_fileobj=SUGGESTIONS_FILE,
|
20 |
+
path_in_repo="suggestions/suggestions.jsonl",
|
21 |
+
repo_id=REPO_ID,
|
22 |
+
repo_type="space",
|
23 |
+
token=token
|
24 |
+
)
|
25 |
+
print("Uploaded suggestions to Hugging Face repo.")
|
26 |
+
except Exception as e:
|
27 |
+
print(f"Upload failed: {e}")
|
28 |
|
29 |
+
if __name__ == "__main__":
|
30 |
+
upload()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|