Skip to content

Commit 2ce4fed

Browse files
authored
Prevent pydantic 2 clobbering (#2273)
* Add granite integration test * Verify the behaviour of pydantic clobbering with the IBM granite project * Use the stated pydantic tolerances * We now support >=2 in pydantic so mirror the tolerances we set in the toml * Fix test to focus on granite-project --------- Signed-off-by: Will Sackfield <[email protected]>
1 parent cc937e8 commit 2ce4fed

File tree

6 files changed

+483
-4
lines changed

6 files changed

+483
-4
lines changed

pkg/dockerfile/standard_generator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,7 @@ func (g *StandardGenerator) installCog() (string, error) {
432432
}
433433
pipInstallLine := "RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir"
434434
pipInstallLine += " " + containerPath
435-
// Install pydantic<2 for now, installing pydantic>2 wouldn't allow a downgrade later,
436-
// but upgrading works fine
437-
pipInstallLine += " 'pydantic<2'"
435+
pipInstallLine += " 'pydantic>=1.9,<3'"
438436
if g.strip {
439437
pipInstallLine += " && " + StripDebugSymbolsCommand
440438
}

pkg/dockerfile/standard_generator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func testInstallCog(relativeTmpDir string, stripped bool) string {
4646
}
4747
return fmt.Sprintf(`COPY %s/%s /tmp/%s
4848
ENV CFLAGS="-O3 -funroll-loops -fno-strict-aliasing -flto -S"
49-
RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir /tmp/%s 'pydantic<2'%s
49+
RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir /tmp/%s 'pydantic>=1.9,<3'%s
5050
ENV CFLAGS=`, relativeTmpDir, wheel, wheel, wheel, strippedCall)
5151
}
5252

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Configuration for Cog ⚙️
2+
# Reference: https://cog.run/yaml
3+
4+
# image name:version
5+
image: "r8.im/ibm-granite/granite-3.3-8b-instruct:1.0.0"
6+
7+
build:
8+
# python version in the form '3.11' or '3.11.4'
9+
python_version: "3.11"
10+
11+
# path to a Python requirements.txt file
12+
python_requirements: requirements.txt
13+
14+
# predict.py defines how predictions are run on your model
15+
predict: "predict.py:Predictor"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from cog import BasePredictor
2+
3+
import pydantic
4+
5+
6+
class Predictor(BasePredictor):
7+
def predict(self) -> str:
8+
return pydantic.__version__

0 commit comments

Comments
 (0)