Skip to content

Commit a7df511

Browse files
authored
Merge pull request #330 from pyiron/ruff
Add ruff linter
2 parents 2288e1f + a0003dd commit a7df511

File tree

9 files changed

+88
-21
lines changed

9 files changed

+88
-21
lines changed

.ci_support/release.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
def get_setup_version_and_pattern(setup_content):
22
depend_lst, version_lst = [], []
33
for l in setup_content:
4-
if '==' in l:
5-
lst = l.split('[')[-1].split(']')[0].replace(' ', '').replace('"', '').replace("'", '').split(',')
4+
if "==" in l:
5+
lst = (
6+
l.split("[")[-1]
7+
.split("]")[0]
8+
.replace(" ", "")
9+
.replace('"', "")
10+
.replace("'", "")
11+
.split(",")
12+
)
613
for dep in lst:
7-
if dep != '\n':
8-
version_lst.append(dep.split('==')[1])
9-
depend_lst.append(dep.split('==')[0])
14+
if dep != "\n":
15+
version_lst.append(dep.split("==")[1])
16+
depend_lst.append(dep.split("==")[0])
1017

1118
version_high_dict = {d: v for d, v in zip(depend_lst, version_lst)}
1219
return version_high_dict
@@ -16,14 +23,14 @@ def get_env_version(env_content):
1623
read_flag = False
1724
depend_lst, version_lst = [], []
1825
for l in env_content:
19-
if 'dependencies:' in l:
26+
if "dependencies:" in l:
2027
read_flag = True
2128
elif read_flag:
22-
lst = l.replace('-', '').replace(' ', '').replace('\n', '').split("=")
29+
lst = l.replace("-", "").replace(" ", "").replace("\n", "").split("=")
2330
if len(lst) == 2:
2431
depend_lst.append(lst[0])
2532
version_lst.append(lst[1])
26-
return {d:v for d, v in zip(depend_lst, version_lst)}
33+
return {d: v for d, v in zip(depend_lst, version_lst)}
2734

2835

2936
def update_dependencies(setup_content, version_low_dict, version_high_dict):
@@ -35,27 +42,29 @@ def update_dependencies(setup_content, version_low_dict, version_high_dict):
3542
version_combo_dict[dep] = dep + "==" + ver
3643

3744
setup_content_new = ""
38-
pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()}
45+
pattern_dict = {d: d + "==" + v for d, v in version_high_dict.items()}
3946
for l in setup_content:
4047
for k, v in pattern_dict.items():
4148
if v in l:
4249
l = l.replace(v, version_combo_dict[k])
43-
setup_content_new +=l
50+
setup_content_new += l
4451
return setup_content_new
4552

4653

4754
if __name__ == "__main__":
48-
with open('pyproject.toml', "r") as f:
55+
with open("pyproject.toml", "r") as f:
4956
setup_content = f.readlines()
5057

51-
with open('environment.yml', "r") as f:
58+
with open("environment.yml", "r") as f:
5259
env_content = f.readlines()
5360

5461
setup_content_new = update_dependencies(
5562
setup_content=setup_content[2:],
5663
version_low_dict=get_env_version(env_content=env_content),
57-
version_high_dict=get_setup_version_and_pattern(setup_content=setup_content[2:]),
64+
version_high_dict=get_setup_version_and_pattern(
65+
setup_content=setup_content[2:]
66+
),
5867
)
5968

60-
with open('pyproject.toml', "w") as f:
69+
with open("pyproject.toml", "w") as f:
6170
f.writelines("".join(setup_content[:2]) + setup_content_new)

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.4.4
4+
hooks:
5+
- id: ruff
6+
name: ruff lint
7+
args: ["--fix"]
8+
files: ^pympipool/
9+
- id: ruff-format
10+
name: ruff format

pympipool/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99

1010
__version__ = get_versions()["version"]
11+
__all__ = [
12+
SubprocessExecutor,
13+
ShellExecutor,
14+
]
1115

1216

1317
class Executor:

pympipool/shared/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,17 @@
99
from pympipool.shared.executorbase import cancel_items_in_queue
1010
from pympipool.shared.thread import RaisingThread
1111
from pympipool.shared.interface import MpiExecInterface, SrunInterface
12+
13+
14+
__all__ = [
15+
SocketInterface,
16+
interface_bootup,
17+
interface_connect,
18+
interface_send,
19+
interface_shutdown,
20+
interface_receive,
21+
cancel_items_in_queue,
22+
RaisingThread,
23+
MpiExecInterface,
24+
SrunInterface,
25+
]

pympipool/shell/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
from pympipool.shell.executor import SubprocessExecutor
22
from pympipool.shell.interactive import ShellExecutor
3+
4+
5+
__all__ = [
6+
SubprocessExecutor,
7+
ShellExecutor,
8+
]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
setup(
66
version=versioneer.get_version(),
77
cmdclass=versioneer.get_cmdclass(),
8-
)
8+
)

tests/benchmark/llh.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,37 @@ def run_static(mean=0.1, sigma=1.1, runs=32):
4545
from pympipool import Executor
4646

4747
run_with_executor(
48-
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="mpi", block_allocation=True
48+
executor=Executor,
49+
mean=0.1,
50+
sigma=1.1,
51+
runs=32,
52+
max_cores=4,
53+
backend="mpi",
54+
block_allocation=True,
4955
)
5056
elif run_mode == "pympipool":
5157
from pympipool import Executor
5258

5359
run_with_executor(
54-
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="mpi", block_allocation=False
60+
executor=Executor,
61+
mean=0.1,
62+
sigma=1.1,
63+
runs=32,
64+
max_cores=4,
65+
backend="mpi",
66+
block_allocation=False,
5567
)
5668
elif run_mode == "flux":
5769
from pympipool import Executor
5870

5971
run_with_executor(
60-
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="flux", block_allocation=True
72+
executor=Executor,
73+
mean=0.1,
74+
sigma=1.1,
75+
runs=32,
76+
max_cores=4,
77+
backend="flux",
78+
block_allocation=True,
6179
)
6280
elif run_mode == "mpi4py":
6381
from mpi4py.futures import MPIPoolExecutor

tests/benchmark/test_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_result(self):
99
self.assertEqual(min(timing_dict, key=timing_dict.get), "process")
1010
self.assertEqual(max(timing_dict, key=timing_dict.get), "static")
1111
self.assertTrue(timing_dict["process"] < timing_dict["pympipool"])
12-
self.assertTrue(timing_dict["block_allocation"] < timing_dict["process"] * 1.1)
12+
self.assertTrue(timing_dict["block_allocation"] < timing_dict["process"] * 1.1)
1313
self.assertTrue(timing_dict["pympipool"] < timing_dict["process"] * 1.35)
1414
self.assertTrue(timing_dict["process"] < timing_dict["mpi4py"])
1515
self.assertTrue(timing_dict["block_allocation"] < timing_dict["mpi4py"])

tests/test_executor_backend_mpi_noblock.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ def test_errors(self):
6464
)
6565
with self.assertRaises(ValueError):
6666
with Executor(
67-
max_cores=1, hostname_localhost=True, backend="mpi", block_allocation=False
67+
max_cores=1,
68+
hostname_localhost=True,
69+
backend="mpi",
70+
block_allocation=False,
6871
) as exe:
6972
exe.submit(resource_dict, resource_dict={})
7073
with self.assertRaises(ValueError):
7174
with Executor(
72-
max_cores=1, hostname_localhost=True, backend="mpi", block_allocation=True
75+
max_cores=1,
76+
hostname_localhost=True,
77+
backend="mpi",
78+
block_allocation=True,
7379
) as exe:
7480
exe.submit(resource_dict, resource_dict={})

0 commit comments

Comments
 (0)