Skip to content

Commit

Permalink
chore: Improved version specifiers and fixed conda recipe (#169)
Browse files Browse the repository at this point in the history
* ci: Fixed conda recipe

* docs: Extended makefile options

* docs: Fixed doc GH button

* chore: Improved version specifiers

* ci: Moved to header validation action

* ci: Updated default python version of the CI

* docs: Udpated headers

* docs: Fixed headers of docs config
  • Loading branch information
frgfm committed Jun 28, 2022
1 parent 88cab74 commit a5c6c51
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 145 deletions.
40 changes: 21 additions & 19 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}

# https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#loading-data-from-other-files
# https://github.com/conda/conda-build/pull/4480
# for conda-build > 3.21.9
# {% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %}
# {% set project = pyproject.get('project') %}
# {% set urls = pyproject.get('project', {}).get('urls') %}
package:
name: {{ data.name }}
version: "{{ data.version }}"
name: torchcam
version: "{{ environ.get('BUILD_VERSION') }}"

source:
fn: {{ data.name }}-{{ data.version }}.tar.gz
url: ../dist/{{ data.name }}-{{ data.version }}.tar.gz
fn: torchcam-{{ environ.get('BUILD_VERSION') }}.tar.gz
url: ../dist/torchcam-{{ environ.get('BUILD_VERSION') }}.tar.gz

build:
number: 0
noarch: python
script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:

host:
- python>=3.6
- python>=3.6, <4.0
- setuptools

run:
- pytorch >=1.7.0
- numpy >=1.14.0
- pytorch >=1.7.0, <2.0.0
- numpy >=1.14.0, <2.0.0
- pillow >=8.3.2
- matplotlib >=3.0.0
- matplotlib >=3.0.0, <4.0.0

test:
# Python imports
Expand All @@ -34,12 +37,11 @@ test:
- python

about:
home: {{ data.get('url') }}
license: {{ data['license'] }}
license_url: https://github.com/frgfm/torch-cam/blob/main/LICENSE
home: https://github.com/frgfm/torch-cam
license: Apache 2.0
license_file: LICENSE
summary: {{ data['description'] }}
description: |
{{ data['long_description'] | replace("\n", "\n ") | replace("#", '\#')}}
summary: 'Class activation maps for your PyTorch CNN models'
# description: |
# {{ data['long_description'] | replace("\n", "\n ") | replace("#", '\#')}}
doc_url: https://frgfm.github.io/torch-cam/
dev_url: {{ data.get('url') }}
dev_url: https://github.com/frgfm/torch-cam
4 changes: 2 additions & 2 deletions .github/collect_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2020-2022, François-Guillaume Fernandez.

# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.

"""
Based on https://github.com/pytorch/pytorch/blob/master/torch/utils/collect_env.py
Expand Down
57 changes: 0 additions & 57 deletions .github/validate_headers.py

This file was deleted.

5 changes: 5 additions & 0 deletions .github/verify_labels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (C) 2020-2022, François-Guillaume Fernandez.

# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.

"""
Borrowed & adapted from https://github.com/pytorch/vision/blob/main/.github/process_commit.py
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('demo/requirements.txt') }}-demo
restore-keys: |
${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-
key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-demo
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . --upgrade
pip install -r demo/requirements.txt
pip install -e ".[demo]" --upgrade
- name: Run demo app
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.8
architecture: x64
- name: Cache python modules
uses: actions/cache@v2
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.8
architecture: x64
- name: Install package
run: |
Expand All @@ -63,7 +63,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.7
python-version: 3.8
auto-activate-base: true
- name: Install dependencies
run: |
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.7
python-version: 3.8
auto-activate-base: true
- name: Install package
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -51,7 +51,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -98,7 +98,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
python: [3.8]
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -88,15 +88,15 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.7]
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v1
- name: Check the headers
uses: frgfm/validate-python-headers@main
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run unittests
run: python .github/validate_headers.py
license: 'Apache-2.0'
owner: 'François-Guillaume Fernandez'
starting-year: 2020
folders: 'torchcam,scripts,demo,docs,.github'
ignores: 'version.py,__init__.py'
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ style:
test:
coverage run -m pytest tests/

# Build documentation for current version
docs-single-version:
sphinx-build docs/source docs/_build -a

# Check that docs can build
docs:
cd docs && bash build.sh

# Run the Gradio demo
run-demo:
streamlit run demo/app.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ A minimal demo app is provided for you to play with the supported CAM methods! F
If you prefer running the demo by yourself, you will need an extra dependency ([Streamlit](https://streamlit.io/)) for the app to run:

```
pip install -r demo/requirements.txt
pip install -e ".[demo]"
```

You can then easily run your app in your default browser by running:
Expand Down
6 changes: 3 additions & 3 deletions demo/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2020-2022, François-Guillaume Fernandez.
# Copyright (C) 2021-2022, François-Guillaume Fernandez.

# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.

from io import BytesIO

Expand Down
3 changes: 0 additions & 3 deletions demo/requirements.txt

This file was deleted.

7 changes: 4 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2020-2021, François-Guillaume Fernandez.
# Copyright (C) 2020-2022, François-Guillaume Fernandez.

# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.

# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -97,6 +97,7 @@
},
],
"source_repository": "https://github.com/frgfm/torch-cam/",
"source_branch": "main",
}


Expand Down

0 comments on commit a5c6c51

Please sign in to comment.