Skip to content

Commit 88eb30f

Browse files
authored
ci: Adds multiple build CI jobs (#223)
* chore: Bumps numpy * ci: Adds new build jobs * style: Fixes mypy * ci: Fixes conda job * ci: Debug conda * ci: Debug * ci: Debug * ci: Debug * ci: Debug * ci: Fixing conda * ci: Fixes publish job
1 parent 97f91b5 commit 88eb30f

File tree

5 files changed

+65
-33
lines changed

5 files changed

+65
-33
lines changed

.conda/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
# {% set urls = pyproject.get('project', {}).get('urls') %}
77
package:
88
name: torchcam
9-
version: "{{ environ.get('BUILD_VERSION') }}"
9+
version: "{{ environ.get('BUILD_VERSION', '0.4.0.dev0') }}"
1010

1111
source:
12-
fn: torchcam-{{ environ.get('BUILD_VERSION') }}.tar.gz
13-
url: ../dist/torchcam-{{ environ.get('BUILD_VERSION') }}.tar.gz
12+
fn: torchcam-{{ environ.get('BUILD_VERSION', '0.4.0.dev0') }}.tar.gz
13+
url: ../dist/torchcam-{{ environ.get('BUILD_VERSION', '0.4.0.dev0') }}.tar.gz
1414

1515
build:
1616
noarch: python

.github/workflows/builds.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python: [3.8, 3.9]
16+
python: [3.8, 3.9, '3.10', 3.11]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Set up Python
@@ -32,3 +32,45 @@ jobs:
3232
pip install -e . --upgrade
3333
- name: Import package
3434
run: python -c "import torchcam; print(torchcam.__version__)"
35+
36+
pypi:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
- name: Set up Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: 3.9
44+
architecture: x64
45+
- name: Cache python modules
46+
uses: actions/cache@v2
47+
with:
48+
path: ~/.cache/pip
49+
key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-build
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install setuptools wheel twine --upgrade
54+
- run: |
55+
python setup.py sdist bdist_wheel
56+
twine check dist/*
57+
58+
conda:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v2
62+
- uses: conda-incubator/setup-miniconda@v2
63+
with:
64+
auto-update-conda: true
65+
python-version: "3.9"
66+
- name: Install dependencies
67+
shell: bash -el {0}
68+
run: conda install -y conda-build conda-verify
69+
- name: Build conda
70+
shell: bash -el {0}
71+
run: |
72+
python setup.py sdist
73+
mkdir conda-dist
74+
conda env list
75+
conda build .conda/ -c pytorch --output-folder conda-dist
76+
ls -l conda-dist/noarch/*tar.bz2
Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
name: release
1+
name: publish
22

33
on:
44
release:
55
types: [published]
66

77
jobs:
8-
pypi-publish:
8+
pypi:
99
if: "!github.event.release.prerelease"
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- name: Set up Python
14-
uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v4
1514
with:
1615
python-version: 3.9
1716
architecture: x64
@@ -24,24 +23,20 @@ jobs:
2423
run: |
2524
python -m pip install --upgrade pip
2625
pip install setuptools wheel twine --upgrade
27-
- name: Get release tag
28-
id: release_tag
29-
run: |
30-
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
3126
- name: Build and publish
3227
env:
3328
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
3429
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35-
VERSION: ${{ steps.release_tag.outputs.VERSION }}
3630
run: |
37-
BUILD_VERSION=${VERSION:1} python setup.py sdist bdist_wheel
31+
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" | cut -c 2- >> $GITHUB_ENV
32+
python setup.py sdist bdist_wheel
3833
twine check dist/*
3934
twine upload dist/*
4035
4136
pypi-check:
4237
if: "!github.event.release.prerelease"
4338
runs-on: ubuntu-latest
44-
needs: pypi-publish
39+
needs: pypi
4540
steps:
4641
- uses: actions/checkout@v2
4742
- name: Set up Python
@@ -55,7 +50,7 @@ jobs:
5550
pip install torchcam
5651
python -c "import torchcam; print(torchcam.__version__)"
5752
58-
conda-publish:
53+
conda:
5954
if: "!github.event.release.prerelease"
6055
runs-on: ubuntu-latest
6156
steps:
@@ -65,37 +60,32 @@ jobs:
6560
with:
6661
auto-update-conda: true
6762
python-version: 3.9
68-
auto-activate-base: true
6963
- name: Install dependencies
70-
run: |
71-
conda install -y conda-build conda-verify anaconda-client
72-
- name: Get release tag
73-
id: release_tag
74-
run: |
75-
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
64+
shell: bash -el {0}
65+
run: conda install -y conda-build conda-verify anaconda-client
7666
- name: Build and publish
67+
shell: bash -el {0}
7768
env:
7869
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
79-
VERSION: ${{ steps.release_tag.outputs.VERSION }}
8070
run: |
81-
BUILD_VERSION=${VERSION:1} python setup.py sdist
71+
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" | cut -c 2- >> $GITHUB_ENV
72+
python setup.py sdist
8273
mkdir conda-dist
83-
conda-build .conda/ -c pytorch --output-folder conda-dist
74+
conda build .conda/ -c pytorch --output-folder conda-dist
8475
ls -l conda-dist/noarch/*tar.bz2
8576
anaconda upload conda-dist/noarch/*tar.bz2
8677
8778
conda-check:
8879
if: "!github.event.release.prerelease"
8980
runs-on: ubuntu-latest
90-
needs: conda-publish
81+
needs: conda
9182
steps:
92-
- name: Miniconda setup
93-
uses: conda-incubator/setup-miniconda@v2
83+
- uses: conda-incubator/setup-miniconda@v2
9484
with:
9585
auto-update-conda: true
9686
python-version: 3.9
97-
auto-activate-base: true
9887
- name: Install package
88+
shell: bash -el {0}
9989
run: |
10090
conda install -c frgfm torchcam
10191
python -c "import torchcam; print(torchcam.__version__)"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dynamic = ["version"]
3232
dependencies = [
3333
# cf. https://github.com/frgfm/torch-cam/discussions/148
3434
"torch>=2.0.0,<3.0.0",
35-
"numpy>=1.14.0,<2.0.0",
35+
"numpy>=1.17.2,<2.0.0",
3636
# cf. https://github.com/advisories/GHSA-98vv-pw6r-q6q4
3737
# cf. https://github.com/pytorch/vision/issues/4934
3838
# https://github.com/frgfm/Holocron/security/dependabot/5

torchcam/methods/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from abc import abstractmethod
88
from functools import partial
99
from types import TracebackType
10-
from typing import Any, List, Optional, Tuple, Type, Union, cast
10+
from typing import Any, List, Optional, Tuple, Type, Union
1111

1212
import torch
1313
import torch.nn.functional as F
@@ -261,4 +261,4 @@ def _fuse_cams(cams: List[Tensor], target_shape: Tuple[int, int]) -> Tensor:
261261
]
262262

263263
# Fuse them
264-
return cast(Tensor, torch.stack(scaled_cams).max(dim=0).values.squeeze(1))
264+
return torch.stack(scaled_cams).max(dim=0).values.squeeze(1)

0 commit comments

Comments
 (0)