From 8e1405af80b9d9041ba1da7806e6c694bf6a8f85 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 29 Jan 2025 14:17:22 +0100 Subject: [PATCH 1/4] fix mutable defaults error with Category descriptor and Python 3.12 --- noxfile.py | 2 +- src/pystencils/codegen/config.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index 1b882478a..11b3731ec 100644 --- a/noxfile.py +++ b/noxfile.py @@ -86,8 +86,8 @@ def typecheck(session: nox.Session): session.run("mypy", "src/pystencils") +@nox.session(python=["3.10", "3.12", "3.13"], tags=["test"]) @nox.parametrize("cupy_version", [None, "12", "13"], ids=["cpu", "cupy12", "cupy13"]) -@nox.session(python="3.10", tags=["test"]) def testsuite(session: nox.Session, cupy_version: str | None): if cupy_version is not None: install_cupy(session, cupy_version, skip_if_no_cuda=True) diff --git a/src/pystencils/codegen/config.py b/src/pystencils/codegen/config.py index cbb3f4f32..d56fe6642 100644 --- a/src/pystencils/codegen/config.py +++ b/src/pystencils/codegen/config.py @@ -196,12 +196,16 @@ class Category(Generic[Category_T]): def __get__(self, obj: ConfigBase, objtype: type[ConfigBase] | None = None) -> Category_T: if obj is None: - return self._default + return None - return cast(Category_T, getattr(obj, self._lookup, None)) + cat = getattr(obj, self._lookup, None) + if cat is None: + cat = self._default.copy() + setattr(obj, self._lookup, cat) + return cast(Category_T, cat) - def __set__(self, obj: ConfigBase, cat: Category_T): - setattr(obj, self._lookup, cat.copy()) + def __set__(self, obj: ConfigBase, cat: Category_T | None): + setattr(obj, self._lookup, cat.copy() if cat is not None else None) class _AUTO_TYPE: ... # noqa: E701 -- GitLab From e56026c4bc21f2ecfc1447cdcc681e6732bead30 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 29 Jan 2025 14:43:56 +0100 Subject: [PATCH 2/4] add testsuite CI task for python 3.13 --- .gitlab-ci.yml | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c6287f237..cccda7c93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -276,20 +276,9 @@ typecheck: # -------------------- Unit Tests --------------------------------------------------------------------- -# Normal test - runs on every commit all but "long run" tests -tests-and-coverage: +.testsuite-base: stage: "Unit Tests" needs: [] - image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6 - script: - - mkdir -p ~/.config/matplotlib - - echo "backend:template" > ~/.config/matplotlib/matplotlibrc - - mkdir public - - nox --session "testsuite(cupy12)" - tags: - - docker - - cuda11 - - AVX coverage: /Total coverage:\s\d+.\d+\%/ artifacts: when: always @@ -302,6 +291,28 @@ tests-and-coverage: path: coverage.xml junit: report.xml +testsuite-gpu-py3.10: + extends: .testsuite-base + image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6 + script: + - mkdir -p ~/.config/matplotlib + - echo "backend:template" > ~/.config/matplotlib/matplotlibrc + - mkdir public + - nox --session "testsuite-3.10(cupy12)" + tags: + - docker + - cuda11 + - AVX + +testsuite-cpu-py3.13: + extends: .testsuite-base + image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine + script: + - nox --session "testsuite-3.13(cupy12)" + tags: + - docker + - AVX + # -------------------- Documentation --------------------------------------------------------------------- -- GitLab From 6870d56fbb2dfb78fe421504325f8664c1c5feaa Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 29 Jan 2025 14:45:32 +0100 Subject: [PATCH 3/4] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cccda7c93..3db3f0b55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -291,7 +291,7 @@ typecheck: path: coverage.xml junit: report.xml -testsuite-gpu-py3.10: +"testsuite-gpu-py3.10": extends: .testsuite-base image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6 script: @@ -304,7 +304,7 @@ testsuite-gpu-py3.10: - cuda11 - AVX -testsuite-cpu-py3.13: +"testsuite-cpu-py3.13": extends: .testsuite-base image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine script: @@ -333,7 +333,7 @@ build-documentation: pages: image: alpine:latest stage: deploy - needs: ["tests-and-coverage", "build-documentation"] + needs: ["testsuite-gpu-py3.10", "build-documentation"] script: - mv docs/build/html public - mv coverage_report public/coverage_report -- GitLab From 321be81c7c35d96e9e0590db3eaa45f9ccec43bd Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 29 Jan 2025 14:49:55 +0100 Subject: [PATCH 4/4] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3db3f0b55..cc73eb5aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -308,7 +308,7 @@ typecheck: extends: .testsuite-base image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine script: - - nox --session "testsuite-3.13(cupy12)" + - nox --session "testsuite-3.13(cpu)" tags: - docker - AVX -- GitLab