Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +7 -7
src/streamlit_app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
-
import streamlit as st
|
| 3 |
|
| 4 |
-
# Fix
|
|
|
|
|
|
|
|
|
|
| 5 |
os.environ["HF_HOME"] = "/tmp/hf_home"
|
| 6 |
-
# os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf_cache"
|
| 7 |
os.environ["SENTENCE_TRANSFORMERS_HOME"] = "/tmp/sbert"
|
| 8 |
os.environ["XDG_CONFIG_HOME"] = "/tmp/.config"
|
| 9 |
-
os.environ["STREAMLIT_HOME"] = "/tmp/.streamlit"
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
# for path in ["/tmp/hf_home", "/tmp/
|
| 13 |
# os.makedirs(path, exist_ok=True)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
from huggingface_hub import login
|
| 17 |
login(os.environ.get("HF_TOKEN", ""))
|
| 18 |
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
|
| 3 |
+
# ✅ Fix for Streamlit writing to /.streamlit by setting HOME
|
| 4 |
+
os.environ["HOME"] = "/tmp"
|
| 5 |
+
|
| 6 |
+
# Optional: Redirect Hugging Face + other cache directories
|
| 7 |
os.environ["HF_HOME"] = "/tmp/hf_home"
|
|
|
|
| 8 |
os.environ["SENTENCE_TRANSFORMERS_HOME"] = "/tmp/sbert"
|
| 9 |
os.environ["XDG_CONFIG_HOME"] = "/tmp/.config"
|
|
|
|
| 10 |
|
| 11 |
+
# Optional: Create those folders if needed (not mandatory in Spaces, but safe)
|
| 12 |
+
# for path in ["/tmp/hf_home", "/tmp/sbert", "/tmp/.config", "/tmp/.config/streamlit"]:
|
| 13 |
# os.makedirs(path, exist_ok=True)
|
| 14 |
|
| 15 |
+
# Hugging Face login using secret
|
| 16 |
from huggingface_hub import login
|
| 17 |
login(os.environ.get("HF_TOKEN", ""))
|
| 18 |
|