vprzybylo commited on
Commit
8e89298
·
1 Parent(s): 489982c

Update Dockerfile to copy PDF file first and adjust PYTHONPATH; modify initialize_rag to support new PDF path structure

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -4
  2. app.py +4 -7
Dockerfile CHANGED
@@ -7,15 +7,18 @@ ENV PATH="/home/user/.local/bin:$PATH"
7
 
8
  WORKDIR /app
9
 
10
- # Copy only the midterm project files
11
  COPY --chown=user requirements.txt requirements.txt
12
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
- # Copy the app directory
 
 
 
15
  COPY --chown=user . .
16
 
17
- # Set environment variable for Python path
18
- ENV PYTHONPATH=/app
19
 
20
  # Run streamlit on port 7860 for Hugging Face Spaces
21
  CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
 
7
 
8
  WORKDIR /app
9
 
10
+ # Copy requirements and install dependencies
11
  COPY --chown=user requirements.txt requirements.txt
12
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
+ # Copy the PDF file first
15
+ COPY --chown=user Grid_Code.pdf Grid_Code.pdf
16
+
17
+ # Copy the rest of the application
18
  COPY --chown=user . .
19
 
20
+ # Set environment variables for Python path
21
+ ENV PYTHONPATH="${PYTHONPATH}:/app:/app/src"
22
 
23
  # Run streamlit on port 7860 for Hugging Face Spaces
24
  CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
app.py CHANGED
@@ -112,19 +112,16 @@ def initialize_rag():
112
 
113
  # Try multiple possible paths for the PDF
114
  possible_paths = [
115
- "app/data/raw/grid_code.pdf", # Local path
116
- "/app/app/data/raw/grid_code.pdf", # Docker path
117
- Path(__file__).parent
118
- / "app"
119
- / "data"
120
- / "raw"
121
- / "grid_code.pdf", # Absolute path
122
  ]
123
 
124
  data_path = None
125
  for path in possible_paths:
126
  if isinstance(path, str):
127
  path = Path(path)
 
128
  if path.exists():
129
  data_path = str(path)
130
  logger.info(f"Found PDF at: {data_path}")
 
112
 
113
  # Try multiple possible paths for the PDF
114
  possible_paths = [
115
+ "Grid_Code.pdf", # Base directory (local and Docker)
116
+ "/app/Grid_Code.pdf", # Docker container path
117
+ Path(__file__).parent / "Grid_Code.pdf", # Absolute path
 
 
 
 
118
  ]
119
 
120
  data_path = None
121
  for path in possible_paths:
122
  if isinstance(path, str):
123
  path = Path(path)
124
+ logger.info(f"Checking path: {path}")
125
  if path.exists():
126
  data_path = str(path)
127
  logger.info(f"Found PDF at: {data_path}")