Skip to content

Commit

Permalink
Merge pull request #550 from mdekstrand/tweak/py313
Browse files Browse the repository at this point in the history
Test with Python 3.13 and Numpy 2.x
  • Loading branch information
mdekstrand authored Dec 14, 2024
2 parents 114b5da + bcd8070 commit 5c830c6
Show file tree
Hide file tree
Showing 10 changed files with 9,868 additions and 13,213 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ jobs:
python:
- py311
- py312
- py313
platform:
- ubuntu-latest
- macos-latest
- windows-latest
exclude:
- python: py313
platform: windows-latest
steps:
- name: "🛒 Checkout"
uses: actions/checkout@v4
Expand Down Expand Up @@ -84,9 +88,13 @@ jobs:
python:
- '3.11'
- '3.12'
- '3.13'
platform:
- ubuntu-latest
- macos-latest
exclude:
- python: '3.13'
platform: macos-latest
steps:
- name: "🛒 Checkout"
uses: actions/checkout@v4
Expand Down Expand Up @@ -229,6 +237,7 @@ jobs:
python:
- py311
- py312
- py313
steps:
- name: "🛒 Checkout"
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion lenskit-implicit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
readme = "README.md"
license = { file = "LICENSE.md" }
requires-python = ">= 3.11"
dependencies = ["lenskit", "implicit >=0.6.1"]
dependencies = ["lenskit", "implicit >=0.7.2"]
dynamic = ["version"]

[project.urls]
Expand Down
6 changes: 3 additions & 3 deletions lenskit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ license = { file = "LICENSE.md" }
dynamic = ["version"]
dependencies = [
"pandas ~=2.0",
"numpy >= 1.24",
"scipy >= 1.10.0",
"numpy >=1.25",
"scipy >=1.11",
"torch ~=2.1",
"threadpoolctl >=3.0",
"structlog >= 23.2",
"structlog >=23.2",
"rich ~=13.5",
"pyzmq >=24",
"pydantic ~=2.7",
Expand Down
3 changes: 2 additions & 1 deletion lenskit/tests/pipeline/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pathlib import Path
from types import NoneType
from typing import Any, TypeVar
from uuid import UUID

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -135,7 +136,7 @@ def test_type_string_generic():


def test_type_string_class():
assert type_string(Path) == "pathlib.Path"
assert type_string(UUID) == "uuid.UUID"


def test_parse_string_None():
Expand Down
22,945 changes: 9,785 additions & 13,160 deletions pixi.lock

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ channels = ["conda-forge", "pytorch", "nodefaults"]
platforms = ["linux-64", "win-64", "osx-arm64"]

[dependencies]
pandas = ">=1.5, <3"
numpy = ">=1.23, <2"
scipy = ">=1.9"
pandas = "~=2.0"
numpy = ">=1.25"
scipy = ">=1.11"
pytorch = "~=2.1"
threadpoolctl = ">=3.0"
structlog = ">=24.4.0,<25"
Expand All @@ -23,6 +23,11 @@ python = "=3.11"
[feature.py312.dependencies]
python = "=3.12"

[feature.py313]
platforms = ["linux-64", "osx-arm64"]
[feature.py313.dependencies]
python = "=3.13"

[feature.sklearn.dependencies]
scikit-learn = "~=1.1"

Expand All @@ -39,7 +44,7 @@ lenskit-funksvd = { path = "lenskit-funksvd", editable = true }
platforms = ["linux-64", "osx-arm64"]

[feature.implicit.dependencies]
implicit = ">=0.6.1"
implicit = ">=0.7.2"

[feature.implicit.pypi-dependencies]
lenskit-implicit = { path = "lenskit-implicit", editable = true }
Expand Down Expand Up @@ -151,6 +156,7 @@ dev-compat = { features = [

test-py311-core = { features = ["py311", "test"], solve-group = "py311" }
test-py312-core = { features = ["py312", "test"], solve-group = "py312" }
test-py313-core = { features = ["py313", "test"], solve-group = "py313" }

test-py311-sklearn = { features = [
"py311",
Expand All @@ -162,6 +168,11 @@ test-py312-sklearn = { features = [
"test",
"sklearn",
], solve-group = "py312" }
test-py313-sklearn = { features = [
"py313",
"test",
"sklearn",
], solve-group = "py313" }

test-py311-funksvd = { features = [
"py311",
Expand Down
10 changes: 5 additions & 5 deletions workflows/lib/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* List of packages in the monorepo.
*/
export const PACKAGES = [
"lenskit",
"lenskit-funksvd",
"lenskit-implicit",
"lenskit-hpf",
"lenskit",
"lenskit-funksvd",
"lenskit-implicit",
"lenskit-hpf",
];

export const META_PYTHON = "3.11";
export const PYTHONS = ["3.11", "3.12"];
export const PYTHONS = ["3.11", "3.12", "3.13"];
export const PLATFORMS = ["ubuntu-latest", "macos-latest", "windows-latest"];
export const VANILLA_PLATFORMS = ["ubuntu-latest", "macos-latest"];
export const CONDA_PYTHONS = PYTHONS.map((s) => `py${s.replaceAll(".", "")}`);
20 changes: 15 additions & 5 deletions workflows/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { evalTestJob } from "./test/test-eval.ts";
import { exampleTestJob } from "./test/test-examples.ts";
import { aggregateResultsJob } from "./test/results.ts";

const FULLDEP_CONDA_PYTHONS = ["py311", "py312"];

const FILTER_PATHS = [
"lenskit*/**.py",
"**pyproject.toml",
Expand All @@ -25,13 +27,21 @@ const test_matrix = {
install: "conda",
key: "conda",
name: "Conda Python ${{matrix.python}} on ${{matrix.platform}}",
matrix: { "python": CONDA_PYTHONS, "platform": PLATFORMS },
matrix: {
python: CONDA_PYTHONS,
platform: PLATFORMS,
exclude: [{ python: "py313", platform: "windows-latest" }],
},
}),
vanilla: testJob({
install: "vanilla",
key: "vanilla",
name: "Vanilla Python ${{matrix.python}} on ${{matrix.platform}}",
matrix: { "python": PYTHONS, "platform": VANILLA_PLATFORMS },
matrix: {
python: PYTHONS,
platform: VANILLA_PLATFORMS,
exclude: [{ python: "3.13", platform: "macos-latest" }],
},
}),
nojit: testJob({
install: "conda",
Expand Down Expand Up @@ -68,7 +78,7 @@ const test_matrix = {
key: "funksvd",
name: "FunkSVD tests on Python ${{matrix.python}}",
packages: ["lenskit-funksvd"],
matrix: { "python": CONDA_PYTHONS },
matrix: { "python": FULLDEP_CONDA_PYTHONS },
variant: "funksvd",
}),
"funksvd-mindep": testJob({
Expand All @@ -83,7 +93,7 @@ const test_matrix = {
key: "implicit",
name: "Implicit bridge tests on Python ${{matrix.python}}",
packages: ["lenskit-implicit"],
matrix: { "python": CONDA_PYTHONS },
matrix: { "python": FULLDEP_CONDA_PYTHONS },
variant: "implicit",
}),
"implicit-mindep": testJob({
Expand All @@ -98,7 +108,7 @@ const test_matrix = {
key: "hpf",
name: "HPF bridge tests on Python ${{matrix.python}}",
packages: ["lenskit-hpf"],
matrix: { "python": CONDA_PYTHONS },
matrix: { "python": FULLDEP_CONDA_PYTHONS },
variant: "hpf",
}),
"eval-tests": evalTestJob(),
Expand Down
5 changes: 0 additions & 5 deletions workflows/test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ function testArtifactName(options: TestJobSpec): string {
if (options.matrix.python) {
name += "-py${{matrix.python}}";
}
for (const key of Object.keys(options.matrix)) {
if (key != "platform" && key != "python") {
name += "-${{matrix." + key + "}}";
}
}
}
return name;
}
62 changes: 33 additions & 29 deletions workflows/test/spec.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
import { PYTHONS } from "../lib/defs.ts";

export interface TestJobSpec {
install: string;
key: string;
name: string;
runs_on?: string;
matrix?: Record<string, string[]>;
python?: string;
packages?: string[];
test_args?: string[];
test_env?: Record<string, string | number>;
install: string;
key: string;
name: string;
runs_on?: string;
matrix?: {
python?: string[];
platform?: string[];
exclude?: Record<string, string>[];
};
python?: string;
packages?: string[];
test_args?: string[];
test_env?: Record<string, string | number>;
}

export function testPlatform(spec: TestJobSpec): string {
if (spec.runs_on) {
return spec.runs_on;
} else if (spec.matrix?.platform) {
return "${{matrix.platform}}";
} else {
return "ubuntu-latest";
}
if (spec.runs_on) {
return spec.runs_on;
} else if (spec.matrix?.platform) {
return "${{matrix.platform}}";
} else {
return "ubuntu-latest";
}
}

/**
* Get a Python version string for a spec.
*/
export function pythonVersionString(spec: TestJobSpec): string {
if (spec.python) {
return translatePythonVersion(spec.python, spec.install);
} else if (spec.matrix?.python) {
return "${{matrix.python}}";
} else {
return translatePythonVersion(PYTHONS[0], spec.install);
}
if (spec.python) {
return translatePythonVersion(spec.python, spec.install);
} else if (spec.matrix?.python) {
return "${{matrix.python}}";
} else {
return translatePythonVersion(PYTHONS[0], spec.install);
}
}

/**
Expand All @@ -42,13 +46,13 @@ export function pythonVersionString(spec: TestJobSpec): string {
* @returns The translated string (e.g. py311 for Conda).
*/
export function translatePythonVersion(ver: string, install: string): string {
if (install == "conda") {
return "py" + ver.replaceAll(".", "");
} else {
return ver;
}
if (install == "conda") {
return "py" + ver.replaceAll(".", "");
} else {
return ver;
}
}

export function packages(spec: TestJobSpec): string[] {
return spec.packages ?? ["lenskit"];
return spec.packages ?? ["lenskit"];
}

0 comments on commit 5c830c6

Please sign in to comment.