diff --git a/pkg/dockerfile/standard_generator.go b/pkg/dockerfile/standard_generator.go index 75dbe76439..b07a035896 100644 --- a/pkg/dockerfile/standard_generator.go +++ b/pkg/dockerfile/standard_generator.go @@ -432,9 +432,7 @@ func (g *StandardGenerator) installCog() (string, error) { } pipInstallLine := "RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir" pipInstallLine += " " + containerPath - // Install pydantic<2 for now, installing pydantic>2 wouldn't allow a downgrade later, - // but upgrading works fine - pipInstallLine += " 'pydantic<2'" + pipInstallLine += " 'pydantic>=1.9,<3'" if g.strip { pipInstallLine += " && " + StripDebugSymbolsCommand } diff --git a/pkg/dockerfile/standard_generator_test.go b/pkg/dockerfile/standard_generator_test.go index 575112c680..9d5bbc1499 100644 --- a/pkg/dockerfile/standard_generator_test.go +++ b/pkg/dockerfile/standard_generator_test.go @@ -46,7 +46,7 @@ func testInstallCog(relativeTmpDir string, stripped bool) string { } return fmt.Sprintf(`COPY %s/%s /tmp/%s ENV CFLAGS="-O3 -funroll-loops -fno-strict-aliasing -flto -S" -RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir /tmp/%s 'pydantic<2'%s +RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir /tmp/%s 'pydantic>=1.9,<3'%s ENV CFLAGS=`, relativeTmpDir, wheel, wheel, wheel, strippedCall) } diff --git a/test-integration/test_integration/fixtures/granite-project/cog.yaml b/test-integration/test_integration/fixtures/granite-project/cog.yaml new file mode 100644 index 0000000000..feb3124833 --- /dev/null +++ b/test-integration/test_integration/fixtures/granite-project/cog.yaml @@ -0,0 +1,15 @@ +# Configuration for Cog ⚙️ +# Reference: https://cog.run/yaml + +# image name:version +image: "r8.im/ibm-granite/granite-3.3-8b-instruct:1.0.0" + +build: + # python version in the form '3.11' or '3.11.4' + python_version: "3.11" + + # path to a Python requirements.txt file + python_requirements: requirements.txt + +# predict.py defines how predictions are run on your model +predict: "predict.py:Predictor" diff --git a/test-integration/test_integration/fixtures/granite-project/predict.py b/test-integration/test_integration/fixtures/granite-project/predict.py new file mode 100644 index 0000000000..92a80c4acc --- /dev/null +++ b/test-integration/test_integration/fixtures/granite-project/predict.py @@ -0,0 +1,8 @@ +from cog import BasePredictor + +import pydantic + + +class Predictor(BasePredictor): + def predict(self) -> str: + return pydantic.__version__ diff --git a/test-integration/test_integration/fixtures/granite-project/requirements.txt b/test-integration/test_integration/fixtures/granite-project/requirements.txt new file mode 100644 index 0000000000..ed2cf9cb0f --- /dev/null +++ b/test-integration/test_integration/fixtures/granite-project/requirements.txt @@ -0,0 +1,437 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile pyproject.toml --output-file requirements.txt +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.11.16 + # via vllm +aiosignal==1.3.2 + # via + # aiohttp + # ray +airportsdata==20250224 + # via outlines +annotated-types==0.7.0 + # via pydantic +anyio==4.9.0 + # via + # httpx + # openai + # starlette + # watchfiles +astor==0.8.1 + # via depyf +attrs==23.2.0 + # via + # aiohttp + # cog + # jsonschema + # referencing +blake3==1.0.4 + # via vllm +cachetools==5.5.2 + # via vllm +certifi==2025.1.31 + # via + # httpcore + # httpx + # requests +charset-normalizer==3.4.1 + # via requests +click==8.1.8 + # via + # ray + # rich-toolkit + # typer + # uvicorn +cloudpickle==3.1.1 + # via + # outlines + # vllm +compressed-tensors==0.9.2 + # via vllm +cupy-cuda12x==13.4.1 + # via ray +depyf==0.18.0 + # via vllm +dill==0.3.9 + # via depyf +diskcache==5.6.3 + # via outlines +distro==1.9.0 + # via openai +dnspython==2.7.0 + # via email-validator +einops==0.8.1 + # via vllm +email-validator==2.2.0 + # via fastapi +fastapi==0.115.12 + # via + # cog + # vllm +fastapi-cli==0.0.7 + # via fastapi +fastrlock==0.8.3 + # via cupy-cuda12x +filelock==3.18.0 + # via + # huggingface-hub + # ray + # torch + # transformers + # vllm +frozenlist==1.5.0 + # via + # aiohttp + # aiosignal + # ray +fsspec==2025.3.2 + # via + # huggingface-hub + # torch +gguf==0.10.0 + # via vllm +h11==0.14.0 + # via + # httpcore + # uvicorn +hf-xet==1.0.3 + # via huggingface-hub +httpcore==1.0.7 + # via httpx +httptools==0.6.4 + # via uvicorn +httpx==0.28.1 + # via + # fastapi + # openai +huggingface-hub==0.30.2 + # via + # tokenizers + # transformers + # vllm +idna==3.10 + # via + # anyio + # email-validator + # httpx + # requests + # yarl +importlib-metadata==8.6.1 + # via vllm +interegular==0.3.3 + # via + # lm-format-enforcer + # outlines + # outlines-core +jinja2==3.1.6 + # via + # fastapi + # outlines + # torch +jiter==0.9.0 + # via openai +jsonschema==4.23.0 + # via + # mistral-common + # outlines + # outlines-core + # ray +jsonschema-specifications==2024.10.1 + # via jsonschema +lark==1.2.2 + # via + # outlines + # vllm +llguidance==0.7.13 + # via vllm +llvmlite==0.44.0 + # via numba +lm-format-enforcer==0.10.11 + # via vllm +markdown-it-py==3.0.0 + # via rich +markupsafe==3.0.2 + # via jinja2 +mdurl==0.1.2 + # via markdown-it-py +mistral-common==1.5.4 + # via vllm +mpmath==1.3.0 + # via sympy +msgpack==1.1.0 + # via ray +msgspec==0.19.0 + # via vllm +multidict==6.4.3 + # via + # aiohttp + # yarl +nanobind==2.6.1 + # via xgrammar +nest-asyncio==1.6.0 + # via outlines +networkx==3.4.2 + # via torch +ninja==1.11.1.4 + # via + # vllm + # xgrammar +numba==0.61.0 + # via vllm +numpy==2.1.3 + # via + # cupy-cuda12x + # gguf + # mistral-common + # numba + # opencv-python-headless + # outlines + # scipy + # torchvision + # transformers + # vllm + # xformers +nvidia-cublas-cu12==12.4.5.8 + # via + # nvidia-cudnn-cu12 + # nvidia-cusolver-cu12 + # torch +nvidia-cuda-cupti-cu12==12.4.127 + # via torch +nvidia-cuda-nvrtc-cu12==12.4.127 + # via torch +nvidia-cuda-runtime-cu12==12.4.127 + # via torch +nvidia-cudnn-cu12==9.1.0.70 + # via torch +nvidia-cufft-cu12==11.2.1.3 + # via torch +nvidia-curand-cu12==10.3.5.147 + # via torch +nvidia-cusolver-cu12==11.6.1.9 + # via torch +nvidia-cusparse-cu12==12.3.1.170 + # via + # nvidia-cusolver-cu12 + # torch +nvidia-cusparselt-cu12==0.6.2 + # via torch +nvidia-nccl-cu12==2.21.5 + # via torch +nvidia-nvjitlink-cu12==12.4.127 + # via + # nvidia-cusolver-cu12 + # nvidia-cusparse-cu12 + # torch +nvidia-nvtx-cu12==12.4.127 + # via torch +openai==1.72.0 + # via vllm +outlines==0.1.11 + # via vllm +outlines-core==0.1.26 + # via outlines +packaging==24.2 + # via + # huggingface-hub + # lm-format-enforcer + # ray + # transformers +partial-json-parser==0.2.1.1.post5 + # via vllm +pillow==11.1.0 + # via + # mistral-common + # torchvision + # vllm +prometheus-client==0.21.1 + # via + # prometheus-fastapi-instrumentator + # vllm +prometheus-fastapi-instrumentator==7.1.0 + # via vllm +propcache==0.3.1 + # via + # aiohttp + # yarl +protobuf==6.30.2 + # via + # ray + # vllm +psutil==7.0.0 + # via vllm +py-cpuinfo==9.0.0 + # via vllm +pycountry==24.6.1 + # via outlines +pydantic==2.11.3 + # via + # cog + # compressed-tensors + # fastapi + # lm-format-enforcer + # mistral-common + # openai + # outlines + # vllm + # xgrammar +pydantic-core==2.33.1 + # via pydantic +pygments==2.19.1 + # via rich +python-dotenv==1.1.0 + # via uvicorn +python-json-logger==3.3.0 + # via vllm +python-multipart==0.0.20 + # via fastapi +pyyaml==6.0.2 + # via + # cog + # gguf + # huggingface-hub + # lm-format-enforcer + # ray + # transformers + # uvicorn + # vllm +pyzmq==26.4.0 + # via vllm +ray==2.43.0 + # via vllm +referencing==0.36.2 + # via + # jsonschema + # jsonschema-specifications + # outlines +regex==2024.11.6 + # via + # tiktoken + # transformers +requests==2.32.3 + # via + # cog + # huggingface-hub + # mistral-common + # outlines + # ray + # tiktoken + # transformers + # vllm +rich==14.0.0 + # via + # rich-toolkit + # typer +rich-toolkit==0.14.1 + # via fastapi-cli +rpds-py==0.24.0 + # via + # jsonschema + # referencing +safetensors==0.5.3 + # via transformers +scipy==1.15.2 + # via vllm +sentencepiece==0.2.0 + # via + # mistral-common + # vllm + # xgrammar +shellingham==1.5.4 + # via typer +sniffio==1.3.1 + # via + # anyio + # openai +starlette==0.46.1 + # via + # fastapi + # prometheus-fastapi-instrumentator +structlog==24.4.0 + # via cog +sympy==1.13.1 + # via torch +tiktoken==0.9.0 + # via + # mistral-common + # vllm + # xgrammar +tokenizers==0.21.1 + # via + # transformers + # vllm +torch==2.6.0 + # via + # compressed-tensors + # outlines + # torchaudio + # torchvision + # vllm + # xformers + # xgrammar +torchaudio==2.6.0 + # via vllm +torchvision==0.21.0 + # via vllm +tqdm==4.67.1 + # via + # gguf + # huggingface-hub + # openai + # outlines + # transformers + # vllm +transformers==4.51.1 + # via + # compressed-tensors + # vllm + # xgrammar +triton==3.2.0 + # via torch +typer==0.15.2 + # via fastapi-cli +typing-extensions==4.13.2 + # via + # anyio + # cog + # fastapi + # huggingface-hub + # mistral-common + # openai + # outlines + # pydantic + # pydantic-core + # referencing + # rich-toolkit + # torch + # typer + # typing-inspection + # vllm +typing-inspection==0.4.0 + # via pydantic +urllib3==2.4.0 + # via requests +uvicorn==0.34.0 + # via + # cog + # fastapi + # fastapi-cli +uvloop==0.21.0 + # via uvicorn +vllm==0.8.3 + # via granite-3-3-8b-instruct (pyproject.toml) +watchfiles==1.0.5 + # via + # uvicorn + # vllm +websockets==15.0.1 + # via uvicorn +xformers==0.0.29.post2 + # via vllm +xgrammar==0.1.17 + # via vllm +yarl==1.19.0 + # via aiohttp +zipp==3.21.0 + # via importlib-metadata diff --git a/test-integration/test_integration/test_predict.py b/test-integration/test_integration/test_predict.py index 63d42eea07..7965641467 100644 --- a/test-integration/test_integration/test_predict.py +++ b/test-integration/test_integration/test_predict.py @@ -521,3 +521,24 @@ def test_predict_string_list(docker_image): ) assert result.returncode == 0 assert result.stdout == "hello world\n" + + +def test_predict_granite_project(docker_image): + # We are checking that we are not clobbering pydantic to a <2 version. + project_dir = Path(__file__).parent / "fixtures/granite-project" + build_process = subprocess.run( + ["cog", "build", "-t", docker_image], + cwd=project_dir, + capture_output=True, + ) + assert build_process.returncode == 0 + result = subprocess.run( + ["cog", "predict", "--debug", docker_image], + cwd=project_dir, + check=True, + capture_output=True, + text=True, + timeout=DEFAULT_TIMEOUT, + ) + assert result.returncode == 0 + assert result.stdout == "2.11.3\n"