From f954d359dbd6514b0a4dd8489bfaf6d1299e0f98 Mon Sep 17 00:00:00 2001 From: F Date: Mon, 6 Jan 2025 18:46:03 +0000 Subject: [PATCH] Use Python 3.13 by default --- .github/workflows/ci.yaml | 6 ++-- docs/yaml.md | 2 +- pkg/config/config.go | 2 +- pkg/config/config_test.go | 4 +-- pkg/config/torch_compatibility_matrix.json | 33 +++++++++++----------- pkg/dockerfile/base_test.go | 2 +- pkg/dockerfile/standard_generator_test.go | 15 +++++++++- pyproject.toml | 1 + tools/compatgen/internal/torch.go | 2 +- tox.ini | 8 +++--- 10 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 21774e6507..98512b60eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,7 @@ jobs: go-version-file: go.mod - uses: actions/setup-python@v5 with: - python-version: 3.12 + python-version: 3.13 - uses: hynek/setup-cached-uv@v2 - name: Prepare tox run: uv pip install --system tox tox-uv @@ -138,7 +138,7 @@ jobs: go-version-file: go.mod - uses: actions/setup-python@v5 with: - python-version: 3.12 + python-version: 3.13 - uses: hynek/setup-cached-uv@v2 - name: Prepare tox run: uv pip install --system tox tox-uv @@ -171,7 +171,7 @@ jobs: go-version-file: go.mod - uses: goreleaser/goreleaser-action@v6 with: - version: '~> v2' + version: "~> v2" args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/yaml.md b/docs/yaml.md index 42181a0848..399cd0e2fb 100644 --- a/docs/yaml.md +++ b/docs/yaml.md @@ -100,7 +100,7 @@ build: python_version: "3.11.1" ``` -Cog supports all active branches of Python: 3.8, 3.9, 3.10, 3.11, 3.12. 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 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.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. diff --git a/pkg/config/config.go b/pkg/config/config.go index f3e28eb7f6..7cc726c783 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -80,7 +80,7 @@ func DefaultConfig() *Config { return &Config{ Build: &Build{ GPU: false, - PythonVersion: "3.12", + PythonVersion: "3.13", }, } } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 934fba5a70..9686cf78b8 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -20,7 +20,7 @@ func TestValidateModelPythonVersion(t *testing.T) { }{ { name: "ValidVersion", - pythonVersion: "3.12", + pythonVersion: "3.13", }, { name: "MinimumVersion", @@ -39,7 +39,7 @@ func TestValidateModelPythonVersion(t *testing.T) { }, { name: "FullyQualifiedVersion", - pythonVersion: "3.12.1", + pythonVersion: "3.13.1", }, { name: "InvalidFormat", diff --git a/pkg/config/torch_compatibility_matrix.json b/pkg/config/torch_compatibility_matrix.json index 1bde2a3424..e5db5b3fc9 100644 --- a/pkg/config/torch_compatibility_matrix.json +++ b/pkg/config/torch_compatibility_matrix.json @@ -7,10 +7,10 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cpu", "CUDA": null, "Pythons": [ + "3.9", "3.10", "3.11", - "3.12", - "3.9" + "3.12" ] }, { @@ -21,10 +21,10 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu118", "CUDA": "11.8", "Pythons": [ + "3.9", "3.10", "3.11", - "3.12", - "3.9" + "3.12" ] }, { @@ -35,10 +35,10 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu121", "CUDA": "12.1", "Pythons": [ + "3.9", "3.10", "3.11", - "3.12", - "3.9" + "3.12" ] }, { @@ -49,10 +49,10 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu124", "CUDA": "12.4", "Pythons": [ + "3.9", "3.10", "3.11", - "3.12", - "3.9" + "3.12" ] }, { @@ -63,11 +63,11 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cpu", "CUDA": null, "Pythons": [ + "3.9", "3.10", "3.11", "3.12", - "3.13", - "3.9" + "3.13" ] }, { @@ -78,11 +78,11 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu118", "CUDA": "11.8", "Pythons": [ + "3.9", "3.10", "3.11", "3.12", - "3.13", - "3.9" + "3.13" ] }, { @@ -93,12 +93,11 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu121", "CUDA": "12.1", "Pythons": [ + "3.9", "3.10", "3.11", "3.12", - "3.13", - "3.9", - "3.10" + "3.13" ] }, { @@ -109,11 +108,11 @@ "ExtraIndexURL": "https://download.pytorch.org/whl/cu124", "CUDA": "12.4", "Pythons": [ + "3.9", "3.10", "3.11", "3.12", - "3.13", - "3.9" + "3.13" ] }, { diff --git a/pkg/dockerfile/base_test.go b/pkg/dockerfile/base_test.go index ea7f4faae1..13fc01e727 100644 --- a/pkg/dockerfile/base_test.go +++ b/pkg/dockerfile/base_test.go @@ -55,7 +55,7 @@ func TestBaseImageConfigurationExists(t *testing.T) { } func TestBaseImageConfigurationExistsNoTorch(t *testing.T) { - exists, _, _, _ := BaseImageConfigurationExists("", "3.12", "") + exists, _, _, _ := BaseImageConfigurationExists("", "3.13", "") require.True(t, exists) } diff --git a/pkg/dockerfile/standard_generator_test.go b/pkg/dockerfile/standard_generator_test.go index 65b660e7de..0cb01cbb24 100644 --- a/pkg/dockerfile/standard_generator_test.go +++ b/pkg/dockerfile/standard_generator_test.go @@ -87,6 +87,7 @@ func TestGenerateEmptyCPU(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: false + python_version: "3.12" predict: predict.py:Predictor `)) require.NoError(t, err) @@ -121,6 +122,7 @@ func TestGenerateEmptyGPU(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: true + python_version: "3.12" predict: predict.py:Predictor `)) require.NoError(t, err) @@ -155,6 +157,7 @@ func TestGenerateFullCPU(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: false + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -209,6 +212,7 @@ func TestGenerateFullGPU(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: true + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -264,6 +268,7 @@ func TestPreInstall(t *testing.T) { conf, err := config.FromYAML([]byte(` build: + python_version: "3.12" system_packages: - cowsay pre_install: @@ -303,6 +308,7 @@ func TestPythonRequirements(t *testing.T) { require.NoError(t, err) conf, err := config.FromYAML([]byte(` build: + python_version: "3.12" python_requirements: "my-requirements.txt" `)) require.NoError(t, err) @@ -349,6 +355,7 @@ func TestGenerateWithLargeModels(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: true + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -454,6 +461,7 @@ func TestGenerateDockerfileWithoutSeparateWeights(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: false + python_version: "3.12" predict: predict.py:Predictor `)) require.NoError(t, err) @@ -487,6 +495,7 @@ func TestGenerateEmptyCPUWithCogBaseImage(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: false + python_version: "3.12" predict: predict.py:Predictor `)) require.NoError(t, err) @@ -516,10 +525,10 @@ func TestGeneratePythonCPUWithCogBaseImage(t *testing.T) { conf, err := config.FromYAML([]byte(` build: gpu: false + python_version: "3.12" system_packages: - ffmpeg - cowsay - python_version: "3.12" python_packages: - pandas==1.2.0.12 run: @@ -624,6 +633,7 @@ func TestGenerateTorchWithStrippedModifiedVersion(t *testing.T) { build: gpu: true cuda: "11.8" + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -675,6 +685,7 @@ func TestGenerateWithStrip(t *testing.T) { build: gpu: true cuda: "11.8" + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -727,6 +738,7 @@ func TestGenerateDoesNotContainDangerousCFlags(t *testing.T) { build: gpu: true cuda: "11.8" + python_version: "3.12" system_packages: - ffmpeg - cowsay @@ -758,6 +770,7 @@ func TestGenerateWithPrecompile(t *testing.T) { build: gpu: true cuda: "11.8" + python_version: "3.12" system_packages: - ffmpeg - cowsay diff --git a/pyproject.toml b/pyproject.toml index bc8a52715a..becf97a209 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] requires-python = ">=3.8" diff --git a/tools/compatgen/internal/torch.go b/tools/compatgen/internal/torch.go index 6f3c4c18c0..650fa1bb8e 100644 --- a/tools/compatgen/internal/torch.go +++ b/tools/compatgen/internal/torch.go @@ -209,7 +209,7 @@ func parseTorchInstallString(s string, defaultVersions map[string]string, cuda * torchaudio := libVersions["torchaudio"] // TODO: this could be determined from https://download.pytorch.org/whl/torch/ - pythons := []string{"3.8", "3.9", "3.10", "3.11", "3.12"} + pythons := []string{"3.8", "3.9", "3.10", "3.11", "3.12", "3.13"} return &config.TorchCompatibility{ Torch: torch, diff --git a/tox.ini b/tox.ini index 450462c728..6f9ed9ed34 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ commands = tests: pytest python/tests --cov={env_site_packages_dir}/cog --cov-report term-missing:skip-covered {posargs:-n auto -vv} [testenv:lint] -base_python = python3.12 +base_python = python3.13 skip_install = true deps = ruff commands = @@ -40,7 +40,7 @@ commands = ruff format --check python [testenv:typecheck-pydantic1] -base_python = python3.12 +base_python = python3.13 deps = pyright==1.1.375 pydantic>=1,<2 @@ -54,14 +54,14 @@ allowlist_externals = sed [testenv:typecheck-pydantic2] -base_python = python3.12 +base_python = python3.13 deps = pyright==1.1.375 pydantic>=2,<3 commands = pyright {posargs} [testenv:integration] -base_python = python3.12 +base_python = python3.13 changedir = test-integration skip_install = true deps =