Spaces:
Running
Running
Fix CAI installation with Dockerfile approach
Browse files- Create custom Dockerfile that installs CAI with --no-use-pep517 flag
- Remove CAI from requirements.txt since it's handled in Dockerfile
- Add install_cai.py script for local testing
- This avoids the wheel naming issue that was causing build failures
- Dockerfile +68 -0
- install_cai.py +67 -0
- requirements.txt +0 -6
Dockerfile
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Install system dependencies
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
git \
|
| 8 |
+
git-lfs \
|
| 9 |
+
ffmpeg \
|
| 10 |
+
libsm6 \
|
| 11 |
+
libxext6 \
|
| 12 |
+
cmake \
|
| 13 |
+
rsync \
|
| 14 |
+
libgl1 \
|
| 15 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 16 |
+
&& git lfs install
|
| 17 |
+
|
| 18 |
+
# Upgrade pip and install base packages
|
| 19 |
+
RUN pip install --no-cache-dir pip -U && \
|
| 20 |
+
pip install --no-cache-dir \
|
| 21 |
+
setuptools \
|
| 22 |
+
wheel \
|
| 23 |
+
datasets \
|
| 24 |
+
"huggingface-hub>=0.30" \
|
| 25 |
+
"hf-transfer>=0.1.4" \
|
| 26 |
+
"protobuf<4" \
|
| 27 |
+
"click<8.1" \
|
| 28 |
+
"pydantic~=1.0"
|
| 29 |
+
|
| 30 |
+
# Install CAI package first with legacy build system to avoid wheel naming issues
|
| 31 |
+
RUN pip install --no-use-pep517 --no-cache-dir \
|
| 32 |
+
git+https://github.com/Benjamin-Lee/CodonAdaptationIndex.git@b6e017a92c58829f6a5aec8c26a21262bc2a6610
|
| 33 |
+
|
| 34 |
+
# Copy requirements file and install remaining dependencies
|
| 35 |
+
COPY requirements.txt /tmp/requirements.txt
|
| 36 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 37 |
+
|
| 38 |
+
# Install additional streamlit dependencies
|
| 39 |
+
RUN pip install --no-cache-dir \
|
| 40 |
+
streamlit==1.28.1 \
|
| 41 |
+
"uvicorn>=0.14.0" \
|
| 42 |
+
spaces
|
| 43 |
+
|
| 44 |
+
# Create user directory structure
|
| 45 |
+
RUN mkdir -p .streamlit && \
|
| 46 |
+
git config --global core.excludesfile ~/.gitignore && \
|
| 47 |
+
echo ".streamlit" > ~/.gitignore
|
| 48 |
+
|
| 49 |
+
RUN mkdir -p /home/user && \
|
| 50 |
+
( [ -e /home/user/app ] || ln -s /app/ /home/user/app ) || true
|
| 51 |
+
|
| 52 |
+
# Copy application files
|
| 53 |
+
COPY --link ./ /app
|
| 54 |
+
|
| 55 |
+
# Set up environment
|
| 56 |
+
ENV PYTHONPATH=/app
|
| 57 |
+
ENV STREAMLIT_SERVER_HEADLESS=true
|
| 58 |
+
ENV STREAMLIT_SERVER_PORT=7860
|
| 59 |
+
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 60 |
+
|
| 61 |
+
# Expose port
|
| 62 |
+
EXPOSE 7860
|
| 63 |
+
|
| 64 |
+
# Health check
|
| 65 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health
|
| 66 |
+
|
| 67 |
+
# Run the application
|
| 68 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
install_cai.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Install CAI package with workaround for wheel naming issues.
|
| 4 |
+
This script installs the CAI package using --no-use-pep517 to avoid
|
| 5 |
+
the dynamic wheel naming problem that occurs with pyproject.toml builds.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import subprocess
|
| 9 |
+
import sys
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
def install_cai():
|
| 13 |
+
"""Install CAI package with legacy setup.py build system."""
|
| 14 |
+
print("Installing CAI package...")
|
| 15 |
+
|
| 16 |
+
# CAI repository URL and commit
|
| 17 |
+
cai_url = "git+https://github.com/Benjamin-Lee/CodonAdaptationIndex.git@b6e017a92c58829f6a5aec8c26a21262bc2a6610"
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
# Install with --no-use-pep517 to force legacy setup.py build
|
| 21 |
+
cmd = [
|
| 22 |
+
sys.executable, "-m", "pip", "install",
|
| 23 |
+
"--no-use-pep517",
|
| 24 |
+
"--no-cache-dir",
|
| 25 |
+
cai_url
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
print(f"Running: {' '.join(cmd)}")
|
| 29 |
+
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
|
| 30 |
+
|
| 31 |
+
print("CAI installation successful!")
|
| 32 |
+
print(result.stdout)
|
| 33 |
+
return True
|
| 34 |
+
|
| 35 |
+
except subprocess.CalledProcessError as e:
|
| 36 |
+
print(f"CAI installation failed: {e}")
|
| 37 |
+
print(f"STDOUT: {e.stdout}")
|
| 38 |
+
print(f"STDERR: {e.stderr}")
|
| 39 |
+
return False
|
| 40 |
+
|
| 41 |
+
def verify_installation():
|
| 42 |
+
"""Verify CAI package can be imported."""
|
| 43 |
+
try:
|
| 44 |
+
import CAI
|
| 45 |
+
from CAI import CAI as cai_func, relative_adaptiveness
|
| 46 |
+
print("✅ CAI package imported successfully")
|
| 47 |
+
return True
|
| 48 |
+
except ImportError as e:
|
| 49 |
+
print(f"❌ Failed to import CAI: {e}")
|
| 50 |
+
return False
|
| 51 |
+
|
| 52 |
+
if __name__ == "__main__":
|
| 53 |
+
print("ColiFormer CAI Package Installer")
|
| 54 |
+
print("=" * 40)
|
| 55 |
+
|
| 56 |
+
# Install CAI
|
| 57 |
+
if install_cai():
|
| 58 |
+
# Verify installation
|
| 59 |
+
if verify_installation():
|
| 60 |
+
print("🎉 CAI installation completed successfully!")
|
| 61 |
+
sys.exit(0)
|
| 62 |
+
else:
|
| 63 |
+
print("💥 CAI installation verification failed!")
|
| 64 |
+
sys.exit(1)
|
| 65 |
+
else:
|
| 66 |
+
print("💥 CAI installation failed!")
|
| 67 |
+
sys.exit(1)
|
requirements.txt
CHANGED
|
@@ -17,9 +17,3 @@ requests>=2.25.0
|
|
| 17 |
ipywidgets>=7.6.0
|
| 18 |
huggingface-hub>=0.20.0
|
| 19 |
datasets>=2.0.0
|
| 20 |
-
# Install CAI (CodonAdaptationIndex) from GitHub. Pin to master branch.
|
| 21 |
-
# If this still fails, try installing this dependency separately with:
|
| 22 |
-
# pip install git+https://github.com/Benjamin-Lee/CodonAdaptationIndex.git@master
|
| 23 |
-
# or clone the repo and run `pip install .` inside it.
|
| 24 |
-
|
| 25 |
-
git+https://github.com/Benjamin-Lee/CodonAdaptationIndex.git@master
|
|
|
|
| 17 |
ipywidgets>=7.6.0
|
| 18 |
huggingface-hub>=0.20.0
|
| 19 |
datasets>=2.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|