Skip to content

Commit 6343cca

Browse files
authored
Merge pull request #41 from kozistr/feature/codecov
[CI] Add pytest & codecov
2 parents 9e637b2 + 0cdcbd9 commit 6343cca

File tree

9 files changed

+272
-20
lines changed

9 files changed

+272
-20
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,31 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v2
18-
- name: Set up Python ${{ matrix.python-version }}
18+
- name: set up Python ${{ matrix.python-version }}
1919
uses: actions/setup-python@v2
2020
with:
2121
python-version: ${{ matrix.python-version }}
22-
- name: Cache pip
22+
- name: cache pip
2323
uses: actions/cache@v2
2424
with:
2525
path: ~/.cache/pip
2626
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
2727
restore-keys: |
2828
${{ runner.os }}-pip-
2929
${{ runner.os }}-
30-
- name: Install dependencies
30+
- name: install dependencies
31+
run: pip install -r requirements-dev.txt
32+
- name: check lint
33+
run: make check
34+
- name: check test
3135
run: |
32-
pip install -r requirements-dev.txt
33-
- name: Lint
34-
run: |
35-
make format
36-
- name: Check Lint
37-
run: |
38-
make check
36+
make test
37+
- name: check codecov
38+
uses: codecov/codecov-action@v2
39+
with:
40+
token: ${{ secrets.CODECOV_TOKEN }}
41+
directory: ./
42+
files: ./coverage.xml
43+
env_vars: OS,PYTHON
44+
fail_ci_if_error: true
45+
verbose: true

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
.PHONY: init format check build deploy requirements
1+
.PHONY: init format test check build deploy requirements
22

33
init:
44
python3 -m pip install -U pipenv setuptools
55
python3 -m pipenv install --dev
66

77
format:
8-
isort --profile black -l 119 pytorch_optimizer setup.py lint.py
9-
black -S -l 119 pytorch_optimizer setup.py lint.py
8+
isort --profile black -l 119 pytorch_optimizer tests setup.py lint.py
9+
black -S -l 119 pytorch_optimizer tests setup.py lint.py
10+
11+
test:
12+
python3 -m pytest -sv -vv --cov=pytorch_optimizer --cov-report=xml ./tests
1013

1114
check:
12-
isort --check-only --profile black -l 119 pytorch_optimizer setup.py lint.py
13-
black -S -l 119 --check pytorch_optimizer setup.py lint.py
15+
isort --check-only --profile black -l 119 pytorch_optimizer tests setup.py lint.py
16+
black -S -l 119 --check pytorch_optimizer tests setup.py lint.py
1417
python3 lint.py
1518

1619
build:

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ verify_ssl = false
77
isort = "==5.10.1"
88
black = "==21.12b0"
99
pylint = "==3.0.0a4"
10+
pytest = "==6.2.5"
11+
pytest-cov = "==3.0.0"
1012

1113
[packages]
1214
numpy = "==1.21.4"

Pipfile.lock

Lines changed: 117 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pytorch-optimizer
22
=================
33

4-
| |workflow| |Documentation Status| |PyPI version| |PyPi download| |black|
4+
| |workflow| |codecov| |Documentation Status| |PyPI version| |PyPi download| |black|
55
66
| Bunch of optimizer implementations in PyTorch with clean-code, strict types. Also, including useful optimization ideas.
77
| Most of the implementations are based on the original paper, but I added some tweaks.
@@ -479,3 +479,5 @@ Hyeongchan Kim / `@kozistr <http://kozistr.tech/about>`__
479479
:target: https://badge.fury.io/py/pytorch-optimizer
480480
.. |PyPi download| image:: https://img.shields.io/pypi/dm/pytorch-optimizer?style=plastic
481481
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
482+
.. |codecov| image:: https://codecov.io/gh/kozistr/pytorch_optimizer/branch/main/graph/badge.svg?token=L4K00EA0VD
483+
:target: https://codecov.io/gh/kozistr/pytorch_optimizer

pytorch_optimizer/adahessian.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def check_valid_parameters(self):
8888
raise ValueError(f'Invalid beta_0 : {self.betas[0]}')
8989
if not 0.0 <= self.betas[1] < 1.0:
9090
raise ValueError(f'Invalid beta_1 : {self.betas[1]}')
91-
if not 0.0 <= self.hessian_power < 1.0:
91+
if not 0.0 <= self.hessian_power <= 1.0:
9292
raise ValueError(f'Invalid hessian_power : {self.hessian_power}')
9393
if self.eps < 0.0:
9494
raise ValueError(f'Invalid eps : {self.eps}')

pytorch_optimizer/ranger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def __init__(
3838
gc_conv_only: bool = False,
3939
adamd_debias_term: bool = False,
4040
):
41-
"""
41+
"""Ranger optimizer
4242
:param params: PARAMETERS. iterable of parameters to optimize or dicts defining parameter groups
43-
:param lr: float. learning rate.
43+
:param lr: float. learning rate
4444
:param betas: BETAS. coefficients used for computing running averages of gradient and the squared hessian trace
4545
:param weight_decay: float. weight decay (L2 penalty)
4646
:param n_sma_threshold: int. (recommended is 5)

requirements-dev.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@
1111
-i https://pypi.org/simple
1212
--trusted-host pypi.org
1313
astroid==2.6.6; python_version ~= '3.6'
14+
attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
1415
black==21.12b0
1516
click==8.0.3; python_version >= '3.6'
17+
coverage[toml]==6.3; python_version >= '3.7'
18+
iniconfig==1.1.1
1619
isort==5.10.1
1720
lazy-object-proxy==1.7.1; python_version >= '3.6'
1821
mccabe==0.6.1
1922
mypy-extensions==0.4.3
2023
numpy==1.21.4
24+
packaging==21.3; python_version >= '3.6'
2125
pathspec==0.9.0
2226
platformdirs==2.4.1; python_version >= '3.7'
27+
pluggy==1.0.0; python_version >= '3.6'
28+
py==1.11.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
2329
pylint==3.0.0a4
30+
pyparsing==3.0.7; python_version >= '3.6'
31+
pytest-cov==3.0.0
32+
pytest==6.2.5
2433
setuptools==60.5.0; python_version >= '3.7'
2534
toml==0.10.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
2635
tomli==1.2.3; python_version >= '3.6'

0 commit comments

Comments
 (0)