diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6c1644b7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: CI + +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"] + + 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: Build + run: uv build + + - name: Run tests + 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/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 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",