Spaces:
Sleeping
Sleeping
File size: 1,959 Bytes
bb3d4d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # M3GNet FastMCP HuggingFace Space image
FROM python:3.10-slim
ENV PIP_NO_CACHE_DIR=1 \
HF_HUB_DISABLE_TELEMETRY=1 \
TF_CPP_MIN_LOG_LEVEL=2 \
CUDA_VISIBLE_DEVICES=-1
WORKDIR /app
# System build/runtime dependencies for pymatgen, ASE, and TensorFlow
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
libopenblas-dev \
liblapack-dev \
libffi-dev \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy everything from the build context into the image
COPY . /app
# Staged installation to avoid dependency conflicts:
# 1) Install TensorFlow 2.13 (requires numpy<=1.24.3)
# 2) Install m3gnet with --no-deps, then its deps manually with compatible versions
# 3) Install MCP service deps (needs pydantic v2)
# 4) Force upgrade pydantic to v2 (pymatgen works fine with it at runtime)
RUN pip install --upgrade pip
# Stage 1: TensorFlow with compatible numpy
RUN pip install --no-cache-dir tensorflow==2.13.0 numpy==1.24.3
# Stage 2: M3GNet and materials science stack
RUN pip install --no-cache-dir \
ase==3.22.1 \
monty==2024.2.2 \
sympy \
spglib \
scipy \
matplotlib \
pandas \
networkx \
requests \
ruamel.yaml \
tabulate \
uncertainties
# Install pymatgen with relaxed deps, then m3gnet
RUN pip install --no-cache-dir --no-deps pymatgen==2024.2.20 \
&& pip install --no-cache-dir --no-deps m3gnet==0.2.4
# Stage 3: MCP service dependencies
RUN if [ -f "mcp_output/requirements.txt" ]; then \
pip install --no-cache-dir -r mcp_output/requirements.txt; \
elif [ -f "requirements.txt" ]; then \
pip install --no-cache-dir -r requirements.txt; \
fi
# Stage 4: Ensure pydantic v2 for MCP (runtime compatible with pymatgen)
RUN pip install --no-cache-dir --upgrade "pydantic>=2.0"
EXPOSE 7860
CMD ["python", "/app/entrypoint.py"]
|