YALCINKAYA commited on
Commit
d3914c1
·
verified ·
1 Parent(s): de661f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -34,10 +34,20 @@ accelerator = Accelerator()
34
  highest_label = None
35
  loaded_models = {}
36
 
37
- # FAISS Index Setup
38
  UPLOAD_DIR = "/home/user/app/uploads"
39
  faiss_index_file = os.path.join(UPLOAD_DIR, "faiss_index.bin")
40
- os.makedirs(UPLOAD_DIR, exist_ok=True)
 
 
 
 
 
 
 
 
 
 
41
  document_store = {}
42
 
43
  if os.path.exists(faiss_index_file):
 
34
  highest_label = None
35
  loaded_models = {}
36
 
37
+ # Define upload directory and FAISS index file
38
  UPLOAD_DIR = "/home/user/app/uploads"
39
  faiss_index_file = os.path.join(UPLOAD_DIR, "faiss_index.bin")
40
+
41
+ # Ensure upload directory exists and has write permissions
42
+ try:
43
+ os.makedirs(UPLOAD_DIR, exist_ok=True)
44
+ if not os.access(UPLOAD_DIR, os.W_OK):
45
+ print(f"Fixing permissions for {UPLOAD_DIR}...")
46
+ os.chmod(UPLOAD_DIR, 0o777)
47
+ print(f"Uploads directory is ready: {UPLOAD_DIR}")
48
+ except PermissionError as e:
49
+ print(f"PermissionError: {e}. Try adjusting directory ownership or running with elevated permissions.")
50
+
51
  document_store = {}
52
 
53
  if os.path.exists(faiss_index_file):