pittman commited on
Commit
7b2d900
·
verified ·
1 Parent(s): 60506df

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -3
src/streamlit_app.py CHANGED
@@ -1,13 +1,17 @@
1
  import streamlit as st
2
  import os
3
  import shutil # Built-in, no need for pip
 
 
 
 
4
  from transformers import pipeline
5
 
6
- # Set custom writable cache directory in /tmp to avoid permission issues
7
- os.environ['HF_HOME'] = '/tmp/huggingface_cache'
8
  cache_dir = os.environ['HF_HOME']
9
 
10
- # Create cache dir if not exists ( /tmp is always writable in containers)
11
  os.makedirs(cache_dir, exist_ok=True)
12
 
13
  # Clear any lock files in cache to fix interrupted downloads
 
1
  import streamlit as st
2
  import os
3
  import shutil # Built-in, no need for pip
4
+
5
+ # Set XDG_CACHE_HOME to writable /tmp before any imports that use it
6
+ os.environ['XDG_CACHE_HOME'] = '/tmp'
7
+
8
  from transformers import pipeline
9
 
10
+ # Set HF_HOME based on XDG (redirects cache to /tmp/huggingface)
11
+ os.environ['HF_HOME'] = os.path.join(os.environ['XDG_CACHE_HOME'], 'huggingface')
12
  cache_dir = os.environ['HF_HOME']
13
 
14
+ # Create cache dir if not exists
15
  os.makedirs(cache_dir, exist_ok=True)
16
 
17
  # Clear any lock files in cache to fix interrupted downloads