From 65634811d64eaf930a38e4add630d14df020a84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20W=C3=B6lflein?= Date: Mon, 10 Feb 2025 10:48:16 +0100 Subject: [PATCH 1/5] Fix AttributeError: Can't pickle local object 'empty..' --- src/stamp/preprocessing/extractor/empty.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stamp/preprocessing/extractor/empty.py b/src/stamp/preprocessing/extractor/empty.py index 841c348c..11ed6be7 100644 --- a/src/stamp/preprocessing/extractor/empty.py +++ b/src/stamp/preprocessing/extractor/empty.py @@ -30,7 +30,7 @@ def empty() -> Extractor[_EmptyModel]: transform=torchvision.transforms.Compose( [ torchvision.transforms.PILToTensor(), - torchvision.transforms.Lambda(lambda x: x.float()), + torchvision.transforms.Lambda(torch.Tensor.float), ] ), identifier="empty", From 3ac8bcee2987c60c5b6854c2e21cbf3f646f418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20W=C3=B6lflein?= Date: Mon, 10 Feb 2025 11:31:31 +0100 Subject: [PATCH 2/5] Add GitHub CI actions --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ .github/workflows/format.yml | 25 +++++++++++++++++++++++++ pyproject.toml | 5 ++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ed814fb6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: Tests + +on: [ push, pull_request ] + # push: + # branches: [ main ] + # pull_request: + # branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + python-version: ${{ matrix.python-version }} + enable-cache: true + cache-dependency-glob: "uv.lock" + + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v5 + # with: + # python-version: ${{ matrix.python-version }} + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Run tests + run: uv run pytest tests/ \ No newline at end of file diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..55ad45eb --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,25 @@ +name: Formatting and linting + +on: [ push, pull_request ] + # push: + # branches: [ main ] + # pull_request: + # branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install the code linting and formatting tool Ruff + run: pipx install ruff + - name: Lint code with Ruff + run: ruff check --output-format=github --target-version=py311 + - name: Check code formatting with Ruff + run: ruff format --diff --target-version=py311 + # continue-on-error: true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 662fa9a3..63a7c0b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,4 +94,7 @@ allow-direct-references = true [tool.pytest.ini_options] markers = [ "slow: marks tests as slow (deselect with '-m \"not slow\"')", -] \ No newline at end of file +] + +[tool.ruff] +lint.ignore = ["F722"] # https://docs.kidger.site/jaxtyping/faq/#flake8-or-ruff-are-throwing-an-error \ No newline at end of file From 78bf9abcd69b3ef6c2c4c3e7f3d504a877eeb4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20W=C3=B6lflein?= Date: Mon, 10 Feb 2025 11:32:49 +0100 Subject: [PATCH 3/5] Fix indent --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed814fb6..24574901 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: # python-version: ${{ matrix.python-version }} - name: Install the project - run: uv sync --all-extras --dev + run: uv sync --all-extras --dev - name: Run tests - run: uv run pytest tests/ \ No newline at end of file + run: uv run pytest tests/ \ No newline at end of file From 193172c8c20ae04da077a46a6bd0b2c1b306fdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20W=C3=B6lflein?= Date: Mon, 10 Feb 2025 11:42:45 +0100 Subject: [PATCH 4/5] Rename build workflow --- .github/workflows/{ci.yml => build.yml} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename .github/workflows/{ci.yml => build.yml} (92%) diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 92% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index 24574901..f5ef7bf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Tests +name: Build and test on: [ push, pull_request ] # push: @@ -30,6 +30,9 @@ jobs: - name: Install the project run: uv sync --all-extras --dev + + - name: Build + run: uv build - name: Run tests run: uv run pytest tests/ \ No newline at end of file From ab4e077837c865415da165f952fa5a5c0b0a0350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20W=C3=B6lflein?= Date: Mon, 10 Feb 2025 11:59:59 +0100 Subject: [PATCH 5/5] Combine into single workflow definition --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++------- .github/workflows/format.yml | 25 ------------------------- 2 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5ef7bf5..6c1644b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,15 @@ -name: Build and test +name: CI -on: [ push, pull_request ] - # push: - # branches: [ main ] - # pull_request: - # branches: [ main ] +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: test: runs-on: ubuntu-latest + # needs: format_and_lint strategy: matrix: python-version: ["3.11", "3.12"] @@ -35,4 +36,22 @@ jobs: run: uv build - name: Run tests - run: uv run pytest tests/ \ No newline at end of file + run: uv run pytest tests/ + + format_and_lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install the code linting and formatting tool Ruff + run: pipx install ruff + - name: Lint code with Ruff + run: ruff check --output-format=github --target-version=py311 + - name: Check code formatting with Ruff + run: ruff format --diff --target-version=py311 + # continue-on-error: true + \ No newline at end of file diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 55ad45eb..00000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Formatting and linting - -on: [ push, pull_request ] - # push: - # branches: [ main ] - # pull_request: - # branches: [ main ] - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Install the code linting and formatting tool Ruff - run: pipx install ruff - - name: Lint code with Ruff - run: ruff check --output-format=github --target-version=py311 - - name: Check code formatting with Ruff - run: ruff format --diff --target-version=py311 - # continue-on-error: true \ No newline at end of file