From f89b0e0cbd4861b63f5b585db6559f8d2a1be278 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:35:01 +0100 Subject: [PATCH 1/8] build(deps-dev): bump ruff to 0.3.0 --- .pre-commit-config.yaml | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab42a34..b3a75d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.2.0' + rev: 'v0.3.0' hooks: - id: ruff args: diff --git a/pyproject.toml b/pyproject.toml index 3879a84..ca918aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ test = [ "pytest-pretty>=1.0.0,<2.0.0", ] quality = [ - "ruff==0.2.0", + "ruff==0.3.0", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", ] @@ -76,7 +76,7 @@ dev = [ "pytest-cov>=4.0.0,<5.0.0", "pytest-pretty>=1.0.0,<2.0.0", # style - "ruff==0.2.0", + "ruff==0.3.0", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", # docs From def35f6ad5f555c8ef536eed2839197783e98f60 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:35:45 +0100 Subject: [PATCH 2/8] ci(github): bump ruff in CI --- .github/workflows/style.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index e3a4768..c28e010 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -21,7 +21,7 @@ jobs: architecture: x64 - name: Run ruff run: | - pip install ruff==0.2.0 + pip install ruff==0.3.0 ruff --version ruff check --diff . @@ -65,7 +65,7 @@ jobs: architecture: x64 - name: Run ruff run: | - pip install ruff==0.2.0 + pip install ruff==0.3.0 ruff --version ruff format --check --diff . From d7cf99300bee00a5637b4fed95ef96418f24bfcc Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:47:27 +0100 Subject: [PATCH 3/8] ci(github): replaces pip with uv --- .github/workflows/builds.yml | 30 ++++++++----------------- .github/workflows/demo.yml | 14 ++++-------- .github/workflows/doc-status.yml | 2 +- .github/workflows/docs.yaml | 14 ++++-------- .github/workflows/publish.yml | 26 +++++++++------------- .github/workflows/pull_requests.yml | 14 ++++-------- .github/workflows/scripts.yml | 32 +++++++++------------------ .github/workflows/style.yml | 34 ++++++++++++++--------------- .github/workflows/tests.yml | 18 +++++---------- 9 files changed, 64 insertions(+), 120 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index dd57e3c..2159376 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -15,42 +15,30 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] python: [3.8, 3.9, '3.10', 3.11] steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-build - name: Install package run: | - python -m pip install --upgrade pip - pip install -e . --upgrade + python -m pip install --upgrade uv + uv pip install --system --upgrade -e "torchcam @ ." - name: Import package run: python -c "import torchcam; print(torchcam.__version__)" pypi: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-build - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine --upgrade + python -m pip install --upgrade uv + uv pip install --system --upgrade setuptools wheel twine - run: | python setup.py sdist bdist_wheel twine check dist/* @@ -58,7 +46,7 @@ jobs: conda: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v2 with: auto-update-conda: true diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 65b5e71..b38fe0c 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -15,21 +15,15 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-demo - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e ".[demo]" --upgrade + python -m pip install --upgrade uv + uv pip install --system --upgrade -e "torchcam[demo] @ ." - name: Run demo app run: | diff --git a/.github/workflows/doc-status.yml b/.github/workflows/doc-status.yml index d2f2d9d..3a294ac 100644 --- a/.github/workflows/doc-status.yml +++ b/.github/workflows/doc-status.yml @@ -6,7 +6,7 @@ jobs: see-page-build-payload: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 192caa3..331acaf 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -11,23 +11,17 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v1 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e ".[docs]" + python -m pip install --upgrade uv + uv pip install --system -e "torchcam[docs] @ ." - name: Build documentation run: cd docs && bash build.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8945f92..1cbf481 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,20 +9,15 @@ jobs: if: "!github.event.release.prerelease" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-build - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine --upgrade + python -m pip install --upgrade uv + uv pip install --system --upgrade setuptools wheel twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} @@ -38,23 +33,22 @@ jobs: runs-on: ubuntu-latest needs: pypi steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 - name: Install package run: | - python -m pip install --upgrade pip - pip install torchcam + python -m pip install --upgrade uv + uv pip install --system torchcam python -c "import torchcam; print(torchcam.__version__)" conda: if: "!github.event.release.prerelease" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Miniconda setup uses: conda-incubator/setup-miniconda@v3 with: @@ -80,7 +74,7 @@ jobs: runs-on: ubuntu-latest needs: conda steps: - - uses: conda-incubator/setup-miniconda@v2 + - uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true python-version: 3.9 diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 2d9ac11..ff41947 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -8,21 +8,15 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-docs - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e ".[docs]" + python -m pip install --upgrade uv + uv pip install -e "torchcam[docs] @ ." - name: Build documentation run: cd docs && bash build.sh diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml index bf6a957..a7bb5fd 100644 --- a/.github/workflows/scripts.yml +++ b/.github/workflows/scripts.yml @@ -15,22 +15,16 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-scripts - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e . --upgrade - pip install -r scripts/requirements.txt + python -m pip install --upgrade uv + uv pip install --system --upgrade -e "torchcam @ ." + uv pip install --system -r scripts/requirements.txt - name: Run analysis script run: python scripts/cam_example.py --arch resnet18 --class-idx 232 --noblock --method LayerCAM @@ -43,22 +37,16 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-scripts - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e . --upgrade - pip install -r scripts/requirements.txt + python -m pip install --upgrade uv + uv pip install --system --upgrade -e "torchcam @ ." + uv pip install --system -r scripts/requirements.txt - name: Run analysis script run: python scripts/eval_latency.py --arch resnet18 LayerCAM diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index c28e010..2b1168d 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -14,14 +14,15 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - name: Run ruff run: | - pip install ruff==0.3.0 + python -m pip install --upgrade uv + uv pip install --system ruff==0.3.0 ruff --version ruff check --diff . @@ -32,20 +33,15 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e ".[quality]" --upgrade + python -m pip install --upgrade uv + uv pip install --system --upgrade -e "torchcam[quality] @ ." - name: Run mypy run: | mypy --version @@ -58,14 +54,15 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - name: Run ruff run: | - pip install ruff==0.3.0 + python -m pip install --upgrade uv + uv pip install --system ruff==0.3.0 ruff --version ruff format --check --diff . @@ -76,14 +73,15 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - name: Run pre-commit hooks run: | - pip install pre-commit + python -m pip install --upgrade uv + uv pip install --system pre-commit git checkout -b temp pre-commit install pre-commit --version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e8e821..56728d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,23 +14,17 @@ jobs: os: [ubuntu-latest] python: [3.9] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 - - name: Cache python modules - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-test - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -e ".[test]" + python -m pip install --upgrade uv + uv pip install --system -e "torchcam[test] @ ." - name: Run unittests run: pytest --cov=torchcam --cov-report xml tests/ - uses: actions/upload-artifact@v2 @@ -42,7 +36,7 @@ jobs: runs-on: ubuntu-latest needs: pytest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/download-artifact@v2 @@ -59,7 +53,7 @@ jobs: matrix: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: persist-credentials: false - name: Check the headers From fc6fbc922ed5fd4e67bcd814bffa0b2b9205d87a Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:50:00 +0100 Subject: [PATCH 4/8] ci(github): fix uv install command --- .github/workflows/pull_requests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index ff41947..a8da894 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -16,7 +16,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install -e "torchcam[docs] @ ." + uv pip install --system -e "torchcam[docs] @ ." - name: Build documentation run: cd docs && bash build.sh From 68a487a171a3295bf9f73e8a5cbbf81f4d1bcb18 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:52:46 +0100 Subject: [PATCH 5/8] ci(github): fix uv install command --- .github/workflows/builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 2159376..d194499 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -23,7 +23,7 @@ jobs: - name: Install package run: | python -m pip install --upgrade uv - uv pip install --system --upgrade -e "torchcam @ ." + uv pip install --system --upgrade -e . - name: Import package run: python -c "import torchcam; print(torchcam.__version__)" From 11e20379462e82ee6ba244301011d83f191264f8 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:55:43 +0100 Subject: [PATCH 6/8] ci(github): fix uv install command --- .github/workflows/demo.yml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/pull_requests.yml | 2 +- .github/workflows/scripts.yml | 2 +- .github/workflows/style.yml | 2 +- .github/workflows/tests.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index b38fe0c..f5c6494 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system --upgrade -e "torchcam[demo] @ ." + uv pip install --system --upgrade -e ".[demo]" - name: Run demo app run: | diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 331acaf..f99586d 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system -e "torchcam[docs] @ ." + uv pip install --system -e ".[docs]" - name: Build documentation run: cd docs && bash build.sh diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index a8da894..cc2205f 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -16,7 +16,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system -e "torchcam[docs] @ ." + uv pip install --system -e ".[docs]" - name: Build documentation run: cd docs && bash build.sh diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml index a7bb5fd..d8fe3e2 100644 --- a/.github/workflows/scripts.yml +++ b/.github/workflows/scripts.yml @@ -45,7 +45,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system --upgrade -e "torchcam @ ." + uv pip install --system --upgrade -e . uv pip install --system -r scripts/requirements.txt - name: Run analysis script diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 2b1168d..a0e0398 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -41,7 +41,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system --upgrade -e "torchcam[quality] @ ." + uv pip install --system --upgrade -e ".[quality]" - name: Run mypy run: | mypy --version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56728d5..69e106a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system -e "torchcam[test] @ ." + uv pip install --system -e ".[test]" - name: Run unittests run: pytest --cov=torchcam --cov-report xml tests/ - uses: actions/upload-artifact@v2 From 58f3af5c33d2ea367bb870000c845d6243a798cb Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:55:55 +0100 Subject: [PATCH 7/8] docs(makefile): update style command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1a30b3d..dffebad 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ quality: # this target runs checks on all files and potentially modifies some of them style: ruff format . - ruff --fix . + ruff check --fix . # Run tests for the library test: From b4e195f675f98e1a8d82662121225d00dfc59b42 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:57:02 +0100 Subject: [PATCH 8/8] ci(github): fix script CI job --- .github/workflows/scripts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml index d8fe3e2..0ece340 100644 --- a/.github/workflows/scripts.yml +++ b/.github/workflows/scripts.yml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade uv - uv pip install --system --upgrade -e "torchcam @ ." + uv pip install --system --upgrade -e . uv pip install --system -r scripts/requirements.txt - name: Run analysis script