Skip to content

Commit a088540

Browse files
Use pytest template to improve tests and coverage reports
1 parent 51c6792 commit a088540

File tree

11 files changed

+159
-121
lines changed

11 files changed

+159
-121
lines changed

.coveragerc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[paths]
2+
source =
3+
bluepyparallel
4+
*/bluepyparallel/bluepyparallel

.gitlab-ci.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ include:
44
- /ci/lib/tox-bb5.yml
55
- /ci/jobs/check-version.yml
66
- /ci/jobs/lint.yml
7-
- /ci/jobs/py36.yml
8-
- /ci/jobs/py37.yml
9-
- /ci/jobs/py38.yml
107
- /ci/jobs/docs.yml
118
- /ci/jobs/build-package.yml
129
- /ci/jobs/publish-package.yml
@@ -15,15 +12,13 @@ include:
1512
- project: neuromath/ci
1613
file:
1714
- /ci/jobs/auto-release.yml
15+
- /ci/lib/pytest-template.yml
16+
- /ci/jobs/py36.yml
17+
- /ci/jobs/py37.yml
18+
- /ci/jobs/py38.yml
19+
- /ci/jobs/coverage.yml
1820

19-
py36:
20-
variables:
21-
bb5_cpus_per_task: 6
22-
23-
py37:
24-
variables:
25-
bb5_cpus_per_task: 6
26-
27-
py38:
21+
.tox-template:
2822
variables:
23+
EXTRA_MODULES: archive/2021-05:py-mpi4py
2924
bb5_cpus_per_task: 6

.pylintrc

Lines changed: 0 additions & 70 deletions
This file was deleted.

bluepyparallel/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _evaluate_basic(
113113

114114

115115
def _prepare_db(db_url, to_evaluate, df, resume, task_ids):
116-
""" "Prepare db."""
116+
"""Prepare db."""
117117
db = DataBase(db_url)
118118

119119
if resume and db.exists("df"):

bluepyparallel/parallel.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _chunksize_to_kwargs(self, chunk_size, kwargs, label="chunk_size"):
102102

103103

104104
class NoDaemonProcess(multiprocessing.Process):
105-
"""Class that represents a non-daemon process"""
105+
"""Class that represents a non-daemon process."""
106106

107107
# pylint: disable=dangerous-default-value
108108

@@ -111,17 +111,17 @@ def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
111111
super().__init__(group=None, target=target, name=name, args=args, kwargs=kwargs)
112112

113113
def _get_daemon(self): # pylint: disable=no-self-use
114-
"""Get daemon flag"""
114+
"""Get daemon flag."""
115115
return False # pragma: no cover
116116

117117
def _set_daemon(self, value):
118-
"""Set daemon flag"""
118+
"""Set daemon flag."""
119119

120120
daemon = property(_get_daemon, _set_daemon)
121121

122122

123123
class NestedPool(Pool): # pylint: disable=abstract-method
124-
"""Class that represents a MultiProcessing nested pool"""
124+
"""Class that represents a MultiProcessing nested pool."""
125125

126126
Process = NoDaemonProcess
127127

@@ -146,7 +146,6 @@ class MultiprocessingFactory(ParallelFactory):
146146

147147
def __init__(self, batch_size=None, chunk_size=None, processes=None, **kwargs):
148148
"""Initialize multiprocessing factory."""
149-
150149
super().__init__(batch_size, chunk_size)
151150

152151
self.nb_processes = processes or os.cpu_count()
@@ -280,7 +279,7 @@ def __init__(
280279
scheduler_file=None,
281280
address=None,
282281
dask_config=None,
283-
**kwargs
282+
**kwargs,
284283
):
285284
super().__init__(
286285
batch_size, chunk_size, scheduler_file=scheduler_file, address=address, **kwargs
@@ -308,7 +307,6 @@ def _with_batches(self, *args, **kwargs):
308307

309308
def get_mapper(self, batch_size=None, chunk_size=None, **kwargs):
310309
"""Get a Dask mapper."""
311-
312310
self._chunksize_to_kwargs(chunk_size, kwargs, label="chunksize")
313311
if not kwargs.get("chunksize"):
314312
kwargs["npartitions"] = self.nb_processes or 1

bluepyparallel/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"""Package version"""
1+
"""Package version."""
22
# pragma: no cover
33
VERSION = "0.0.7.dev0"

pyproject.toml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# BLACK
2+
[tool.black]
3+
line-length = 100
4+
target-version = ["py36"]
5+
6+
# PYLINT
7+
[tool.pylint.messages-control]
8+
# C0103 - Invalid name "%s" (should match %s) - matches too many things, like variables w/ single char names
9+
# C0325 - superfluous-parens
10+
# I0013 - Ignore the 'Ignoring entire file' warning
11+
# R0205 - useless-object-inheritance
12+
# R0401 - cyclic-import
13+
# R0801 - Similar lines in %d files
14+
# R0903 - Too Few public methods
15+
# R0904 - Too Many public methods
16+
# R0921 - Abstract class not referenced
17+
# R0922 - Abstract class is only referenced 1 times
18+
# W0141 - Used builtin function 'map'
19+
# W0142 - Used * or ** magic
20+
# W0232 - Class has no __init__ method
21+
# W0511 - TODO in code
22+
# W0622 - redefined-builti
23+
disable = [
24+
"C0103",
25+
"C0112",
26+
"C0116",
27+
"C0302",
28+
"C0325",
29+
"C0330",
30+
"C0415",
31+
"E1133",
32+
"E231",
33+
"I0013",
34+
"R0201",
35+
"R0205",
36+
"R0401",
37+
"R0801",
38+
"R0903",
39+
"R0904",
40+
"R0921",
41+
"R0922",
42+
"W0141",
43+
"W0142",
44+
"W0221",
45+
"W0232",
46+
"W0511",
47+
"W0622",
48+
]
49+
50+
[tool.pylint.format]
51+
# Maximum number of characters on a single line.
52+
max-line-length = 100
53+
54+
[tool.pylint.design]
55+
# Maximum number of arguments for function / method
56+
max-args = 15
57+
# Argument names that match this expression will be ignored. Default to name
58+
# with leading underscore
59+
ignored-argument-names = "args|kwargs|_.*"
60+
# Maximum number of locals for function / method body
61+
max-locals = 25
62+
# Maximum number of return / yield for function / method body
63+
max-returns = 6
64+
# Maximum number of branch for function / method body
65+
max-branches = 20
66+
# Maximum number of statements in function / method body
67+
max-statements = 60
68+
# Maximum number of parents for a class (see R0901).
69+
max-parents = 10
70+
# Maximum number of attributes for a class (see R0902).
71+
max-attributes = 40
72+
# Minimum number of public methods for a class (see R0903).
73+
min-public-methods = 0
74+
# Maximum number of public methods for a class (see R0904).
75+
max-public-methods = 60
76+
77+
[tool.pylint.similarities]
78+
# Minimum lines number of a similarity.
79+
min-similarity-lines = 25
80+
# Ignore comments when computing similarities.
81+
ignore-comments = true
82+
# Ignore docstrings when computing similarities.
83+
ignore-docstrings = true
84+
85+
[tool.pylint.typecheck]
86+
# List of module names for which member attributes should not be checked
87+
# (useful for modules/projects where namespaces are manipulated during runtime
88+
# and thus existing member attributes cannot be deduced by static analysis. It
89+
# supports qualified module names, as well as Unix pattern matching.
90+
ignored-modules = []
91+
92+
# PYDOCSTYLE
93+
[tool.pydocstyle]
94+
add-ignore = [
95+
"D107",
96+
"D413",
97+
]
98+
convention = "google"
99+
100+
# ISORT
101+
[tool.isort]
102+
line_length = 100
103+
profile = "black"
104+
force_single_line = true

setup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env python
2-
1+
"""Setup for the BluePyParallel package."""
32
import imp
43
import sys
54

6-
from setuptools import setup, find_packages
5+
from setuptools import find_packages
6+
from setuptools import setup
77

88
if sys.version_info < (3, 6):
99
sys.exit("Sorry, Python < 3.6 is not supported")
@@ -51,10 +51,10 @@
5151
packages=find_packages(exclude=["tests"]),
5252
python_requires=">=3.6",
5353
classifiers=[
54-
'Programming Language :: Python',
55-
'Programming Language :: Python :: 3',
56-
'Programming Language :: Python :: 3.6',
57-
'Programming Language :: Python :: 3.7',
58-
'Programming Language :: Python :: 3.8',
54+
"Programming Language :: Python",
55+
"Programming Language :: Python :: 3",
56+
"Programming Language :: Python :: 3.6",
57+
"Programming Language :: Python :: 3.7",
58+
"Programming Language :: Python :: 3.8",
5959
],
6060
)

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Tests for the BluePyParallel package."""

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@
1111

1212
@pytest.fixture
1313
def db_url(tmpdir):
14+
"""The DB URL."""
1415
return tmpdir / "db.sql"
1516

1617

1718
@pytest.fixture(params=[None, "multiprocessing", "ipyparallel", "dask", "dask_dataframe"])
1819
def factory_type(request):
20+
"""The factory type."""
1921
return request.param
2022

2123

2224
@pytest.fixture(scope="session")
2325
def dask_cluster():
26+
"""The dask cluster."""
2427
cluster = dask.distributed.LocalCluster()
2528
yield cluster
2629
cluster.close()
@@ -36,6 +39,7 @@ def dask_cluster():
3639
]
3740
)
3841
def parallel_factory(factory_type, dask_cluster, request):
42+
"""The parallel factory."""
3943
factory_kwargs = copy.deepcopy(request.param)
4044
if factory_type in ["dask", "dask_dataframe"]:
4145
factory_kwargs["address"] = dask_cluster

0 commit comments

Comments
 (0)