Spaces:
Sleeping
Sleeping
Move NLTK download from Docker build to app initialization to reduce image size
Browse files- Dockerfile +0 -3
- download_nltk_data.py +0 -20
Dockerfile
CHANGED
|
@@ -22,9 +22,6 @@ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
|
| 22 |
# Copy the entire application
|
| 23 |
COPY . .
|
| 24 |
|
| 25 |
-
# Download NLTK data during build with error handling
|
| 26 |
-
RUN python download_nltk_data.py
|
| 27 |
-
|
| 28 |
# Expose the port the app runs on
|
| 29 |
EXPOSE 7860
|
| 30 |
|
|
|
|
| 22 |
# Copy the entire application
|
| 23 |
COPY . .
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
# Expose the port the app runs on
|
| 26 |
EXPOSE 7860
|
| 27 |
|
download_nltk_data.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
"""Script to download NLTK data during Docker build"""
|
| 2 |
-
import nltk
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
-
# Set NLTK data directory
|
| 6 |
-
nltk_data_dir = '/root/nltk_data'
|
| 7 |
-
os.makedirs(nltk_data_dir, exist_ok=True)
|
| 8 |
-
nltk.data.path.append(nltk_data_dir)
|
| 9 |
-
|
| 10 |
-
# Download required NLTK data
|
| 11 |
-
required_data = ['punkt', 'vader_lexicon']
|
| 12 |
-
for data_name in required_data:
|
| 13 |
-
try:
|
| 14 |
-
nltk.download(data_name, quiet=True)
|
| 15 |
-
print(f'Downloaded {data_name}')
|
| 16 |
-
except Exception as e:
|
| 17 |
-
print(f'Failed to download {data_name}: {e}')
|
| 18 |
-
|
| 19 |
-
print('NLTK download step completed')
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|