Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
fail-fast: false
matrix:
pydantic: ["1", "2"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: mise run test:rust

# coglet-python checks (requires Python + maturin build)
# Builds once with ABI3 (works across Python 3.8+)
# Builds once with ABI3 (works across Python 3.10+)
coglet-python:
name: coglet-python
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
- **Error Handling**: Raise exceptions with descriptive messages; avoid generic exception catching
- **Naming**: snake_case for functions/variables/modules, PascalCase for classes
- **Testing**: Use pytest with fixtures; async tests with pytest-asyncio
- **Compatibility**: Must support Python 3.8-3.13 and both Pydantic 1.x and 2.x (test with tox)
- **Compatibility**: Must support Python 3.10-3.13 and both Pydantic 1.x and 2.x (test with tox)

### Rust
- **Formatting**: Use `cargo fmt`
Expand Down Expand Up @@ -189,4 +189,4 @@ For comprehensive architecture documentation, see [`architecture/`](./architectu
- Tests use real Docker operations (no mocking Docker API)
- Always run `make wheel` after making Python changes before testing Go code
- Both Pydantic 1.x and 2.x must pass tests (use appropriate tox environments)
- Python 3.8-3.13 compatibility is required
- Python 3.10-3.13 compatibility is required
2 changes: 1 addition & 1 deletion architecture/01-model-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ concurrency:

| Field | Purpose |
|-------|---------|
| `build.python_version` | Python interpreter version (3.8-3.12) |
| `build.python_version` | Python interpreter version (3.10-3.13) |
| `build.gpu` | Enable CUDA support |
| `build.python_packages` | pip packages to install |
| `build.system_packages` | apt packages to install |
Expand Down
4 changes: 2 additions & 2 deletions architecture/05-build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ flowchart TB
### 1. Config Parsing & Validation

Reads `cog.yaml` and validates/completes the configuration:
- Validates Python version (3.8-3.12)
- Validates Python version (3.10-3.13)
- Auto-detects CUDA version from PyTorch/TensorFlow requirements
- Resolves package versions against compatibility matrix

Expand Down Expand Up @@ -121,7 +121,7 @@ flowchart LR
subgraph output["Cog determines"]
cuda["CUDA 12.1"]
cudnn["cuDNN 8"]
python["Python 3.8-3.11"]
python["Python 3.10-3.13"]
end

torch --> lookup
Expand Down
2 changes: 1 addition & 1 deletion architecture/ffi/04-container-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ How coglet gets invoked when running a Cog container:
- **Memory safety**: No Python GIL contention in HTTP layer

### Why PyO3 FFI?
- **ABI3 wheel**: Single wheel works across Python 3.8-3.13
- **ABI3 wheel**: Single wheel works across Python 3.10-3.13
- **Native performance**: Direct C API calls, no serialization overhead
- **Same predictor code**: Users don't change anything
- **Drop-in replacement**: Same HTTP API, same behavior
Expand Down
2 changes: 1 addition & 1 deletion docs/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ build:
python_version: "3.11.1"
```

Cog supports all active branches of Python: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13. If you don't define a version, Cog will use the latest version of Python 3.12 or a version of Python that is compatible with the versions of PyTorch or TensorFlow you specify.
Cog supports Python 3.10, 3.11, 3.12, and 3.13. If you don't define a version, Cog will use the latest version of Python 3.13 or a version of Python that is compatible with the versions of PyTorch or TensorFlow you specify.

Note that these are the versions supported **in the Docker container**, not your host machine. You can run any version(s) of Python you wish on your host machine.

Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/replicate/cog
go 1.25

require (
github.com/alecthomas/kong v1.12.1
github.com/anaskhan96/soup v1.2.5
github.com/aquasecurity/go-pep440-version v0.0.1
github.com/aws/aws-sdk-go-v2 v1.36.3
Expand All @@ -12,7 +11,6 @@ require (
github.com/docker/cli v28.3.0+incompatible
github.com/docker/docker v28.1.1+incompatible
github.com/docker/go-connections v0.5.0
github.com/gabriel-vasile/mimetype v1.4.10
github.com/getkin/kin-openapi v0.128.0
github.com/google/go-containerregistry v0.20.5
github.com/hashicorp/go-version v1.7.0
Expand All @@ -35,7 +33,6 @@ require (
github.com/vincent-petithory/dataurl v1.0.0
github.com/xeipuuv/gojsonschema v1.2.0
github.com/xeonx/timeago v1.0.0-rc5
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.38.0
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
golang.org/x/sync v0.14.0
Expand Down Expand Up @@ -170,10 +167,8 @@ require (
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/in-toto/in-toto-golang v0.5.0 // indirect
Expand Down Expand Up @@ -306,6 +301,7 @@ require (
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.40.0 // indirect
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU=
github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E=
github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0=
github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alexkohler/nakedret/v2 v2.0.5 h1:fP5qLgtwbx9EJE8dGEERT02YwS8En4r9nnZ71RK+EVU=
Expand Down Expand Up @@ -209,8 +207,6 @@ github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQ
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getkin/kin-openapi v0.128.0 h1:jqq3D9vC9pPq1dGcOCv7yOp1DaEe7c/T1vzcLbITSp4=
github.com/getkin/kin-openapi v0.128.0/go.mod h1:OZrfXzUfGrNbsKj+xmFBx6E5c6yH3At/tAKSc2UszXM=
github.com/ghostiam/protogetter v0.3.9 h1:j+zlLLWzqLay22Cz/aYwTHKQ88GE2DQ6GkWSYFOI4lQ=
Expand Down Expand Up @@ -319,16 +315,10 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJ
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo=
github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
Expand Down
5 changes: 1 addition & 4 deletions integration-tests/tests/apt_packages.txtar
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+
[cog_dataclass] skip
[coglet_rust] skip

# Test that system packages are installed correctly via system_packages in cog.yaml

# Build the image (the run command verifies git is installed)
Expand All @@ -14,7 +11,7 @@ stdout 'hello world'
-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random thought, but I wonder if we should omit the python version from fixtures unless we're specifically testing version behavior. When missing it'll use the default, 3.13 atm.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should. that seems like a useful enhancement.

system_packages:
- "git"
run:
Expand Down
5 changes: 1 addition & 4 deletions integration-tests/tests/bad_dockerignore.txtar
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+
[cog_dataclass] skip
[coglet_rust] skip

# Test that build fails with proper error when .cog is in .dockerignore
! cog build -t $TEST_IMAGE
stderr 'The .cog tmp path cannot be ignored by docker in .dockerignore'

-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
predict: "predict.py:Predictor"

-- .dockerignore --
Expand Down
32 changes: 0 additions & 32 deletions integration-tests/tests/optional_input.txtar

This file was deleted.

6 changes: 1 addition & 5 deletions integration-tests/tests/python37_deprecated.txtar
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Test that Python 3.7 is deprecated and build fails with appropriate error
# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+
[cog_dataclass] skip
[coglet_rust] skip

# Build should fail with deprecation error
! cog build -t $TEST_IMAGE
stderr 'minimum supported Python version is 3.8. requested 3.7'
stderr 'minimum supported Python version is 3.10. requested 3.7'

-- cog.yaml --
build:
Expand Down
18 changes: 18 additions & 0 deletions integration-tests/tests/python38_deprecated.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test that Python 3.8 is deprecated and build fails with appropriate error
# Build should fail with deprecation error
! cog build -t $TEST_IMAGE
stderr 'minimum supported Python version is 3.10. requested 3.8'

-- cog.yaml --
build:
gpu: false
python_version: "3.8"
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, num: int) -> int:
return num * 2
18 changes: 18 additions & 0 deletions integration-tests/tests/python39_deprecated.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test that Python 3.9 is deprecated and build fails with appropriate error
# Build should fail with deprecation error
! cog build -t $TEST_IMAGE
stderr 'minimum supported Python version is 3.10. requested 3.9'

-- cog.yaml --
build:
gpu: false
python_version: "3.9"
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, num: int) -> int:
return num * 2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[cog_dataclass] skip
[coglet_rust] skip

# Skip for coglet_alpha which requires Python 3.9+
# Skip for coglet_alpha which requires Python 3.10+
[coglet_alpha] skip

# Test multiprocessing.Process spawned during setup
Expand All @@ -27,7 +27,7 @@ stdout 'received .* from background job'

-- cog.yaml --
build:
python_version: "3.8"
python_version: "3.10"
predict: "predict.py:Predictor"

-- predict.py --
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/torch_baseimage_fallback.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cog build -t $TEST_IMAGE --openapi-schema openapi.json
-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
python_packages:
- "torch==1.13.0"
predict: "predict.py:Predictor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cog build -t $TEST_IMAGE --openapi-schema openapi.json --use-cog-base-image=fals
-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
python_packages:
- "torch==1.13.0"
predict: "predict.py:Predictor"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/torch_baseimage_precompile.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cog build -t $TEST_IMAGE --openapi-schema openapi.json --use-cog-base-image=fals
-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
python_packages:
- "torch==1.13.0"
predict: "predict.py:Predictor"
Expand Down
5 changes: 1 addition & 4 deletions integration-tests/tests/torch_cuda_baseimage.txtar
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[short] skip 'slow test - run without -short flag'
# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+
[cog_dataclass] skip
[coglet_rust] skip

# Test Torch 2.0.1+cu118 with --use-cog-base-image flag
cog build -t $TEST_IMAGE --use-cog-base-image

-- cog.yaml --
build:
gpu: true
python_version: "3.9"
python_version: "3.10"
python_packages:
- "torch==2.0.1+cu118"
predict: "predict.py:Predictor"
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/replicate/cog/pkg/util/version"
)

// TODO(andreas): check tf/py versions. tf 1.5.0 didn't install on py 3.8
// TODO(andreas): check tf/py versions. tf 1.5.0 didn't install on py 3.10
// TODO(andreas): support more tf versions. No matching tensorflow CPU package for version 1.15.4, etc.
// TODO(andreas): allow user to install versions that aren't compatible
// TODO(andreas): allow user to install tf cpu package on gpu
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (

const (
MinimumMajorPythonVersion int = 3
MinimumMinorPythonVersion int = 8
MinimumMinorPythonVersion int = 10
MinimumMinorPythonVersionForConcurrency int = 11
MinimumMajorCudaVersion int = 11
)
Expand Down
Loading