[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #602 from bittner/feature/modernize-packaging-tests
Browse files Browse the repository at this point in the history
Modernize packaging and test automation (GHA, Tox)
  • Loading branch information
j-towns committed Jul 26, 2023
2 parents 1bb5cbc + 3e1e95d commit bd4f375
Show file tree
Hide file tree
Showing 16 changed files with 391 additions and 63 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Checks

on:
pull_request:
branches:
- master
push:
branches:
- master

env:
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PY_COLORS: '1'

jobs:
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
env:
#- ruff
- package
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build tools
run: |
python -m pip install tox wheel
- name: Run ${{ matrix.env }}
run: tox -e ${{ matrix.env }}
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
push:
tags:
- '*'

env:
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PY_COLORS: '1'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build tools
run: |
python -m pip install build twine wheel
- name: Build package
run: python -m build
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests

on:
pull_request:
branches:
- master
push:
branches:
- master

env:
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PY_COLORS: '1'

jobs:
test:
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-20.04
- macos-latest
- windows-latest
python-version:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- pypy-2.7
- pypy-3.8
- pypy-3.9
dependencies:
- none
- scipy
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: python -m pip install tox-gh-actions wheel
- name: Install optional dependencies
run: python -m pip install ${{ matrix.dependencies }}
if: ${{ matrix.dependencies != 'none' }}
- name: Run tests
run: tox
68 changes: 61 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,69 @@
*.pyc
scratch/
examples/data
.idea/
.DS_Store
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
build/
data/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
coverage.*
*.cover
.hypothesis/
nosetests.xml
.pytest_cache/
junit-report.xml

# pyenv
.python-version

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mypy
.mypy_cache/

# OS and IDE config files
.DS_Store
.idea/

# project-specific
data/
*.so
*.c
scratch/
examples/data

.asv/
autograd.egg-info/
asv.conf.json
benchmarks/asv.conf.js
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing

Use Tox to run tests and linting, e.g.

```shell
pip install tox
```

## Run tests, linting, packaging checks

```shell
tox list # list all Tox environments
tox run -e ruff # run code style checks
tox run -e py # run tests with your default Python
tox run -e package # verify packaging
tox # run all Tox environments
```

Make sure all tests pass before you push your changes to GitHub.
GH Actions will run the tests across all supported Python versions.

## Using arguments (reformat, upload package, help)

You can use additional arguments for the tools called by Tox by
separating them from the Tox arguments by a double-dash `--`, e.g.

```shell
tox run -e ruff -- autograd/core.py --show-source
tox run -e ruff -- autograd/core.py --fix
```

```shell
tox run -e package -- upload
```

```shell
tox run -e py -- --help
```
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include autograd *.c *.h *.pyx
prune tests
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ Townsend) are now working on [JAX](https://github.com/google/jax), with Dougal a
working on it full-time. JAX combines a new version of Autograd with extra
features such as jit compilation.__

# Autograd [![Test status](https://travis-ci.org/HIPS/autograd.svg?branch=master)](https://travis-ci.org/HIPS/autograd) [![asv](http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat)](#)
# Autograd [![Checks status][checks-badge]][checks-url] [![Tests status][tests-badge]][tests-url] [![Publish status][publish-badge]][publish-url] [![asv][asv-badge]](#)

[publish-badge]: https://github.com/HIPS/autograd/actions/workflows/publish.yml/badge.svg
[checks-badge]: https://github.com/HIPS/autograd/actions/workflows/check.yml/badge.svg
[tests-badge]: https://github.com/HIPS/autograd/actions/workflows/test.yml/badge.svg
[asv-badge]: http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat
[publish-url]: https://github.com/HIPS/autograd/actions/workflows/publish.yml
[checks-url]: https://github.com/HIPS/autograd/actions/workflows/check.yml
[tests-url]: https://github.com/HIPS/autograd/actions/workflows/test.yml

Autograd can automatically differentiate native Python and Numpy code. It can
handle a large subset of Python's features, including loops, ifs, recursion and
Expand Down Expand Up @@ -75,7 +83,18 @@ You can find a tutorial [here.](docs/tutorial.md)

## How to install

Just run `pip install autograd`
Install _autograd_ using Pip, e.g.

```shell
pip install autograd
```

Some features require _scipy_, which you can install separately or as an
optional dependency along with _autograd_ , e.g.

```shell
pip install "autograd[scipy]"
```

## Authors

Expand Down
3 changes: 1 addition & 2 deletions autograd/builtins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
from future.utils import with_metaclass
from six import with_metaclass
from .util import subvals
from .extend import (Box, primitive, notrace_primitive, VSpace, vspace,
SparseObject, defvjp, defvjp_argnum, defjvp, defjvp_argnum)
Expand Down
2 changes: 1 addition & 1 deletion autograd/numpy/numpy_vjps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import
from future.utils import string_types
from six import string_types
from functools import partial
import numpy as onp
from ..util import func
Expand Down
2 changes: 1 addition & 1 deletion autograd/scipy/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from autograd.extend import primitive, defvjp

from numpy.lib.stride_tricks import as_strided
from future.utils import iteritems
from six import iteritems

@primitive
def convolve(A, B, axes=None, dot_axes=[(),()], mode='full'):
Expand Down
6 changes: 4 additions & 2 deletions examples/data_mnist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import
from __future__ import print_function
from future.standard_library import install_aliases
install_aliases()
import sys
if sys.version < "3":
from future.standard_library import install_aliases
install_aliases()

import os
import gzip
Expand Down
Loading

0 comments on commit bd4f375

Please sign in to comment.