Vivek0912 commited on
Commit
122ab6b
·
1 Parent(s): 991cb1a

updated code for files issue

Browse files
backend/.gitignore CHANGED
@@ -181,6 +181,7 @@ cython_debug/
181
 
182
  # Compiled output
183
  /dist
 
184
  /out-tsc
185
  /bazel-out
186
 
 
181
 
182
  # Compiled output
183
  /dist
184
+ /tmp
185
  /out-tsc
186
  /bazel-out
187
 
backend/app/api/endpoints.py CHANGED
@@ -21,7 +21,7 @@ from config import settings
21
  router = APIRouter()
22
 
23
  # Define the directory where attachments will be saved
24
- SAVE_DIR = Path("/tmp/attachments")
25
  SAVE_FILE_PATH = SAVE_DIR / settings.settings.ALLOWED_PRIORITY_RULES_FILENAME
26
 
27
  if not SAVE_DIR.exists():
@@ -58,13 +58,13 @@ async def process_email_files(files: List[UploadFile] = File(...)):
58
  async def process_email_directory():
59
  """Processes email files from a directory specified in an environment variable."""
60
  # directory_path = settings.settings.directory_path
61
- directory_path = Path("/data/emails")
62
 
63
  if not directory_path:
64
  raise HTTPException(status_code=400, detail="EMAIL_DIRECTORY_PATH environment variable not set.")
65
 
66
  if not os.path.exists(directory_path) or not os.path.isdir(directory_path):
67
- raise HTTPException(status_code=400, detail="Invalid directory path- {directory_path}")
68
 
69
  results = []
70
  email_files = []
 
21
  router = APIRouter()
22
 
23
  # Define the directory where attachments will be saved
24
+ SAVE_DIR = Path(settings.settings.DATA_DIRECTORY_ATTACHMENTS_PATH)
25
  SAVE_FILE_PATH = SAVE_DIR / settings.settings.ALLOWED_PRIORITY_RULES_FILENAME
26
 
27
  if not SAVE_DIR.exists():
 
58
  async def process_email_directory():
59
  """Processes email files from a directory specified in an environment variable."""
60
  # directory_path = settings.settings.directory_path
61
+ directory_path = Path(settings.settings.DATA_DIRECTORY_EMAILS_PATH)
62
 
63
  if not directory_path:
64
  raise HTTPException(status_code=400, detail="EMAIL_DIRECTORY_PATH environment variable not set.")
65
 
66
  if not os.path.exists(directory_path) or not os.path.isdir(directory_path):
67
+ raise HTTPException(status_code=400, detail=f"Invalid directory path- {directory_path}")
68
 
69
  results = []
70
  email_files = []
backend/app/services/retrieve_email_process.py CHANGED
@@ -131,7 +131,7 @@ def load_priority_rules() -> dict:
131
  """
132
  # Get the rules directory and filename from environment variables
133
  RULES_FILENAME = settings.settings.ALLOWED_PRIORITY_RULES_FILENAME
134
- RULES_DIR = Path("/tmp/attachments")
135
  # Build the full file path using pathlib
136
  RULES_FILE_PATH = Path(RULES_DIR) / RULES_FILENAME
137
 
 
131
  """
132
  # Get the rules directory and filename from environment variables
133
  RULES_FILENAME = settings.settings.ALLOWED_PRIORITY_RULES_FILENAME
134
+ RULES_DIR = Path(settings.settings.DATA_DIRECTORY_ATTACHMENTS_PATH)
135
  # Build the full file path using pathlib
136
  RULES_FILE_PATH = Path(RULES_DIR) / RULES_FILENAME
137
 
backend/config/settings.py CHANGED
@@ -17,6 +17,8 @@ class Settings:
17
  OCR_LANGUAGE = os.getenv("OCR_LANGUAGE", "eng")
18
  directory_path = os.getenv("EMAIL_DIRECTORY_PATH") or os.environ.get("EMAIL_DIRECTORY_PATH") # Make configurable
19
  ALLOWED_PRIORITY_RULES_FILENAME=os.getenv("ALLOWED_PRIORITY_RULES_FILENAME") or os.environ.get("ALLOWED_PRIORITY_RULES_FILENAME") # Make configurable
 
 
20
  # Debugging info
21
  print(f"Running in {ENV} mode with model path: {MODEL_NAME}")
22
  print(f"Running in {ENV} mode with TOKEN: {HUGGINGFACE_API_TOKEN}")
 
17
  OCR_LANGUAGE = os.getenv("OCR_LANGUAGE", "eng")
18
  directory_path = os.getenv("EMAIL_DIRECTORY_PATH") or os.environ.get("EMAIL_DIRECTORY_PATH") # Make configurable
19
  ALLOWED_PRIORITY_RULES_FILENAME=os.getenv("ALLOWED_PRIORITY_RULES_FILENAME") or os.environ.get("ALLOWED_PRIORITY_RULES_FILENAME") # Make configurable
20
+ DATA_DIRECTORY_ATTACHMENTS_PATH=os.getenv("DATA_DIRECTORY_ATTACHMENTS_PATH") or os.environ.get("DATA_DIRECTORY_ATTACHMENTS_PATH") # Make configurable
21
+ DATA_DIRECTORY_EMAILS_PATH=os.getenv("DATA_DIRECTORY_EMAILS_PATH") or os.environ.get("DATA_DIRECTORY_EMAILS_PATH") # Make configurable
22
  # Debugging info
23
  print(f"Running in {ENV} mode with model path: {MODEL_NAME}")
24
  print(f"Running in {ENV} mode with TOKEN: {HUGGINGFACE_API_TOKEN}")
backend/{tmp → data}/attachments/Priority_Extraction_Rules.json RENAMED
File without changes