Skip to content

Commit 2a97347

Browse files
authored
Merge pull request #98 from ayasyrev/nox_tests
nox_tests
2 parents 91c3318 + 25fa5e9 commit 2a97347

File tree

11 files changed

+72
-10
lines changed

11 files changed

+72
-10
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
select = C,E,F,W
33
max-complexity = 10
44
max-line-length = 120
5-
disable-noqa = True
5+
; disable-noqa = True
66
application-import-names = model_constructor, tests
77
import-order-style = google
88
per-file-ignores =

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ _tmp*
1010
tmp*
1111
tags
1212

13+
.nox/
14+
1315
# Byte-compiled / optimized / DLL files
1416
__pycache__/
1517
*.py[cod]

noxfile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import nox
2+
3+
4+
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
5+
def tests(session: nox.Session) -> None:
6+
args = session.posargs or ["--cov"]
7+
session.install(".", "pytest", "pytest-cov")
8+
session.run("pytest", *args)

noxfile_conda.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import nox
2+
3+
4+
@nox.session(python=["3.9", "3.10", "3.11"], venv_backend="mamba")
5+
def conda_tests(session: nox.Session) -> None:
6+
args = session.posargs or ["--cov"]
7+
# session.install("pytest", "pytest-cov")
8+
session.conda_install("pytest", "pytest-cov")
9+
session.conda_install("pytorch")
10+
session.conda_install("pydantic")
11+
session.install("-e", ".", "--no-deps")
12+
session.run("pytest", *args)

noxfile_conda_lint.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import nox
2+
3+
locations = "src/model_constructor", "tests", "noxfile.py"
4+
5+
6+
@nox.session(python=["3.8", "3.9", "3.10", "3.11"], venv_backend="mamba")
7+
def conda_lint(session: nox.Session) -> None:
8+
args = session.posargs or locations
9+
session.conda_install("flake8")
10+
session.run("flake8", *args)

noxfile_cov.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import nox
2+
3+
4+
@nox.session(python=["3.10"])
5+
def cov_tests(session: nox.Session) -> None:
6+
args = session.posargs or ["--cov"]
7+
session.install(".", "pytest", "pytest-cov", "coverage[toml]")
8+
session.run("pytest", *args)
9+
10+
11+
@nox.session(python="3.10")
12+
def coverage(session: nox.Session) -> None:
13+
"""Upload coverage data."""
14+
session.install("coverage[toml]", "codecov")
15+
session.run("coverage", "xml", "--fail-under=0")
16+
session.run("codecov", *session.posargs)

noxfile_lint.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import nox
2+
3+
4+
locations = "src/model_constructor", "tests", "noxfile.py"
5+
6+
7+
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
8+
def lint(session: nox.Session) -> None:
9+
args = session.posargs or locations
10+
session.install("flake8")
11+
session.run("flake8", *args)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pydantic
2-
# pytorch
2+
torch
33
# numpy

requirements_test.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pytest
22
pytest-cov
33
coverage[toml]
4-
flake8
4+
flake8
5+
nox

src/model_constructor/base_constructor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def __init__(self, ni, nh, expansion=4, stride=1, zero_bn=False,
9494
ni = ni * expansion
9595
nf = nh * expansion
9696
self.conv = nn.Sequential(OrderedDict([
97-
('conv_0', conv_layer(ni, nh, ks=1, act_fn=act_fn, **kwargs)), # noqa: E241
98-
('conv_1', conv_layer(nh, nh, stride=stride, act_fn=act_fn, **kwargs)), # noqa: E241
97+
('conv_0', conv_layer(ni, nh, ks=1, act_fn=act_fn, **kwargs)),
98+
('conv_1', conv_layer(nh, nh, stride=stride, act_fn=act_fn, **kwargs)),
9999
('conv_2', conv_layer(nh, nf, ks=1, zero_bn=zero_bn, act=False, act_fn=act_fn, **kwargs))]))
100100
if self.downsample:
101101
self.downsample = downsample_block(conv_layer, ni, nf, ks=1,

0 commit comments

Comments
 (0)