Upload 241 files
Browse files- BUILD_ERROR_FIX.md +56 -0
- Dockerfile +1 -4
- startup.sh +7 -0
BUILD_ERROR_FIX.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fix for Docker Build Error
|
| 2 |
+
|
| 3 |
+
## Problem
|
| 4 |
+
The Docker build was failing with:
|
| 5 |
+
```
|
| 6 |
+
TypeError: 'NoneType' object is not iterable
|
| 7 |
+
```
|
| 8 |
+
|
| 9 |
+
This error occurred during `pip install -e .` which suggests there was an issue with the setup.py file or package structure.
|
| 10 |
+
|
| 11 |
+
## Root Cause
|
| 12 |
+
The error was likely caused by an issue with the `find_packages()` function in setup.py when trying to install the package in development mode. This can happen when:
|
| 13 |
+
1. There are issues with the package structure
|
| 14 |
+
2. The `find_packages()` function encounters unexpected directory structures
|
| 15 |
+
3. There are permission issues with certain directories
|
| 16 |
+
|
| 17 |
+
## Solution Implemented
|
| 18 |
+
|
| 19 |
+
### 1. Removed Editable Install
|
| 20 |
+
- Removed `RUN pip install -e .` from the Dockerfile
|
| 21 |
+
- This eliminates the dependency on setup.py for the editable install
|
| 22 |
+
- Relied instead on proper PYTHONPATH configuration
|
| 23 |
+
|
| 24 |
+
### 2. Simplified Package Management
|
| 25 |
+
- Kept all Python dependencies installation via requirements.txt
|
| 26 |
+
- Set PYTHONPATH explicitly to include all necessary directories
|
| 27 |
+
- Removed complex package installation steps that were causing errors
|
| 28 |
+
|
| 29 |
+
### 3. Enhanced Error Handling in Startup Script
|
| 30 |
+
- Added directory existence checks to help diagnose import issues
|
| 31 |
+
- Improved error messages to provide more context when imports fail
|
| 32 |
+
- Maintained the core import verification functionality
|
| 33 |
+
|
| 34 |
+
## Why This Fix Works
|
| 35 |
+
|
| 36 |
+
### Direct Path Management
|
| 37 |
+
Instead of relying on `pip install -e .` to manage package discovery, we're explicitly setting the PYTHONPATH to include all necessary directories:
|
| 38 |
+
- `/app` (main application directory)
|
| 39 |
+
- `/app/controller` (controller package)
|
| 40 |
+
- `/app/controller/models` (controller models package)
|
| 41 |
+
- `/app/models` (models package)
|
| 42 |
+
- `/app/utils` (utilities package)
|
| 43 |
+
|
| 44 |
+
### Elimination of Complex Package Installation
|
| 45 |
+
By removing the editable install step, we eliminate potential issues with:
|
| 46 |
+
- setup.py parsing errors
|
| 47 |
+
- Package structure validation problems
|
| 48 |
+
- Permission issues during installation
|
| 49 |
+
|
| 50 |
+
## Expected Outcome
|
| 51 |
+
This approach should:
|
| 52 |
+
1. Resolve the build error by eliminating the problematic `pip install -e .` step
|
| 53 |
+
2. Maintain the reliability of our import verification approach
|
| 54 |
+
3. Keep the application deployment stable
|
| 55 |
+
|
| 56 |
+
The core solution for the `ModuleNotFoundError` remains intact - using a dedicated startup script that verifies imports before starting the application, which follows the proven "Hugging Face Spaces startup script pattern".
|
Dockerfile
CHANGED
|
@@ -21,12 +21,9 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 21 |
# Copy application code
|
| 22 |
COPY . .
|
| 23 |
|
| 24 |
-
# Ensure all
|
| 25 |
RUN find . -type d -exec mkdir -p {} \; 2>/dev/null || true
|
| 26 |
|
| 27 |
-
# Install the package in development mode
|
| 28 |
-
RUN pip install -e .
|
| 29 |
-
|
| 30 |
# Set PYTHONPATH to include the current directory and all subdirectories
|
| 31 |
ENV PYTHONPATH=/app:/app/controller:/app/controller/models:/app/models:/app/utils
|
| 32 |
|
|
|
|
| 21 |
# Copy application code
|
| 22 |
COPY . .
|
| 23 |
|
| 24 |
+
# Ensure all directories exist
|
| 25 |
RUN find . -type d -exec mkdir -p {} \; 2>/dev/null || true
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
# Set PYTHONPATH to include the current directory and all subdirectories
|
| 28 |
ENV PYTHONPATH=/app:/app/controller:/app/controller/models:/app/models:/app/utils
|
| 29 |
|
startup.sh
CHANGED
|
@@ -28,6 +28,13 @@ else
|
|
| 28 |
echo "❌ Failed to import controller module"
|
| 29 |
echo "Python path:"
|
| 30 |
$PYTHON_CMD_PREFIX -c "import sys; [print(i, p) for i, p in enumerate(sys.path)]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
exit 1
|
| 32 |
fi
|
| 33 |
|
|
|
|
| 28 |
echo "❌ Failed to import controller module"
|
| 29 |
echo "Python path:"
|
| 30 |
$PYTHON_CMD_PREFIX -c "import sys; [print(i, p) for i, p in enumerate(sys.path)]"
|
| 31 |
+
echo "Checking if controller directory exists:"
|
| 32 |
+
if [ -d "/app/controller" ]; then
|
| 33 |
+
echo "Controller directory exists"
|
| 34 |
+
ls -la /app/controller/
|
| 35 |
+
else
|
| 36 |
+
echo "Controller directory does not exist"
|
| 37 |
+
fi
|
| 38 |
exit 1
|
| 39 |
fi
|
| 40 |
|