MohitG012 commited on
Commit
4b6dddf
·
verified ·
1 Parent(s): 146e6a0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -7
src/streamlit_app.py CHANGED
@@ -1,18 +1,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
 
 
1
  import os
2
+ import streamlit as st
3
 
4
+ # Fix permission errors by forcing writable directories
 
 
 
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
+ # Make those folders if not already present
12
+ # for path in ["/tmp/hf_home", "/tmp/hf_cache", "/tmp/sbert", "/tmp/.config", "/tmp/.streamlit"]:
13
  # os.makedirs(path, exist_ok=True)
14
 
15
+ # HuggingFace login (requires HF_TOKEN to be added as secret in Hugging Face Spaces)
16
  from huggingface_hub import login
17
  login(os.environ.get("HF_TOKEN", ""))
18