Michael Rey commited on
Commit
4efcfc7
·
1 Parent(s): 728a629

Fix Streamlit permission error for config path

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -1
src/streamlit_app.py CHANGED
@@ -1,10 +1,19 @@
1
  import os
 
 
2
  # Redirect .streamlit config and cache to /tmp where Streamlit has permission
3
  os.environ["STREAMLIT_HOME"] = "/tmp"
4
  os.environ["XDG_CONFIG_HOME"] = "/tmp"
5
  os.environ["XDG_CACHE_HOME"] = "/tmp"
6
 
7
- import sys
 
 
 
 
 
 
 
8
  import streamlit as st
9
  import torch
10
  import torchvision.transforms as transforms
 
1
  import os
2
+ import sys
3
+
4
  # Redirect .streamlit config and cache to /tmp where Streamlit has permission
5
  os.environ["STREAMLIT_HOME"] = "/tmp"
6
  os.environ["XDG_CONFIG_HOME"] = "/tmp"
7
  os.environ["XDG_CACHE_HOME"] = "/tmp"
8
 
9
+ # Force use of internal config (avoids /.streamlit access)
10
+ os.environ["STREAMLIT_CONFIG_FILE"] = os.path.abspath(
11
+ os.path.join(os.path.dirname(__file__), ".streamlit", "config.toml")
12
+ )
13
+
14
+ # Add project root to sys.path
15
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
16
+
17
  import streamlit as st
18
  import torch
19
  import torchvision.transforms as transforms