Ehrii commited on
Commit
7c93a3d
·
1 Parent(s): 7602c5f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -5
main.py CHANGED
@@ -7,14 +7,13 @@ from langdetect import detect, DetectorFactory
7
  # Ensure consistent language detection results
8
  DetectorFactory.seed = 0
9
 
10
- # Set Hugging Face cache directory to a writable location
11
- os.environ["HF_HOME"] = "/app/huggingface_cache"
12
- os.environ["TRANSFORMERS_CACHE"] = "/app/huggingface_cache"
13
 
14
- # Create cache directory with proper permissions
15
  cache_dir = os.environ["HF_HOME"]
16
  os.makedirs(cache_dir, exist_ok=True)
17
- os.chmod(cache_dir, 0o755) # Set read/write/execute permissions for owner
18
 
19
  # Retrieve Hugging Face token from environment variable
20
  HF_TOKEN = os.getenv("HF_TOKEN")
 
7
  # Ensure consistent language detection results
8
  DetectorFactory.seed = 0
9
 
10
+ # Use /tmp for Hugging Face cache to avoid permission errors
11
+ os.environ["HF_HOME"] = "/tmp/huggingface_cache"
12
+ os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface_cache"
13
 
14
+ # Create cache directory if it doesn't exist
15
  cache_dir = os.environ["HF_HOME"]
16
  os.makedirs(cache_dir, exist_ok=True)
 
17
 
18
  # Retrieve Hugging Face token from environment variable
19
  HF_TOKEN = os.getenv("HF_TOKEN")