Skip to content

Commit 5f94106

Browse files
committed
consolidate linting from flake8, blake, etc to ruff. adding linting dependencies to dev group
1 parent ea1f06d commit 5f94106

File tree

16 files changed

+923
-490
lines changed

16 files changed

+923
-490
lines changed

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
name: CI
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
pull_request:
10+
workflow_dispatch:
11+
12+
env:
13+
UV_CACHE_DIR: /tmp/.uv-cache
14+
PROJECT_PATH: "src/memory_profiler"
15+
16+
jobs:
17+
code-quality:
18+
name: Check code quality
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
# https://github.com/actions/checkout
23+
- name: ⤵️ Checkout repository
24+
uses: actions/checkout@v4
25+
26+
# https://github.com/astral-sh/setup-uv
27+
- name: 🏗 Install uv and Python
28+
uses: astral-sh/setup-uv@v6
29+
with:
30+
enable-cache: true
31+
cache-dependency-glob: "uv.lock"
32+
cache-local-path: ${{ env.UV_CACHE_DIR }}
33+
python-version: "3.13"
34+
35+
- name: 🏗 Install the project
36+
run: uv sync --locked --dev
37+
38+
- name: Run mypy
39+
run: uv run --frozen mypy ${{ env.PROJECT_PATH }}/
40+
- name: Pylint review
41+
run: uv run --frozen pylint ${{ env.PROJECT_PATH }}/
42+
- name: Ruff check
43+
run: uv run --frozen ruff check ${{ env.PROJECT_PATH }}/
44+
45+
tests:
46+
name: Run tests
47+
runs-on: ubuntu-latest
48+
49+
strategy:
50+
matrix:
51+
python-version:
52+
- "3.10"
53+
- "3.11"
54+
- "3.12"
55+
- "3.13"
56+
57+
steps:
58+
# https://github.com/actions/checkout
59+
- name: ⤵️ Checkout repository
60+
uses: actions/checkout@v4
61+
62+
# https://github.com/astral-sh/setup-uv
63+
- name: 🏗 Install uv and Python ${{ matrix.python-version }}
64+
uses: astral-sh/setup-uv@v6
65+
with:
66+
enable-cache: true
67+
cache-dependency-glob: "uv.lock"
68+
cache-local-path: ${{ env.UV_CACHE_DIR }}
69+
python-version: ${{ matrix.python-version }}
70+
71+
- name: 🏗 Install the project
72+
run: uv sync --locked --dev
73+
74+
- name: Run pytest
75+
run: uv run --frozen pytest tests/ --cov=./ --cov-report=xml --junitxml=pytest-report.xml
76+
77+
# https://github.com/actions/upload-artifact
78+
- name: Upload test report
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: pytest-report-${{ matrix.python-version }}
82+
path: pytest-report.xml
83+
84+
# https://github.com/actions/upload-artifact
85+
- name: Upload coverage results
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: coverage-results-${{ matrix.python-version }}
89+
path: coverage.xml
90+
91+
# # https://github.com/codecov/codecov-action
92+
# - name: Upload coverage to Codecov
93+
# uses: codecov/codecov-action@v5
94+
# with:
95+
# token: ${{ secrets.CODECOV_TOKEN }}
96+
# fail_ci_if_error: true

.github/workflows/lint_python.yml

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

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Pre-commit configuration
3+
# For details, visit: https://pre-commit.com/hooks.html
4+
5+
ci:
6+
autofix_prs: false
7+
skip:
8+
# These steps run in the CI workflow. Keep in sync.
9+
- mypy
10+
- ruff
11+
12+
repos:
13+
14+
# Local hooks for mypy and pylint
15+
- repo: local
16+
hooks:
17+
- id: mypy
18+
name: Run mypy
19+
entry: scripts/run-mypy.sh
20+
language: script
21+
types: [python]
22+
- id: ruff
23+
name: Run ruff
24+
entry: scripts/run-ruff.sh
25+
language: script
26+
types: [ python ]
27+
# - id: lint
28+
# name: Run pylint
29+
# entry: scripts/run-pylint.sh
30+
# language: script
31+
# types: [ python ]

examples/exxample_psutil_memory_full_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def subprocess(i):
3333
return a[i,i]
3434

3535
results = joblib.Parallel(n_jobs=n_jobs)(
36-
joblib.delayed(subprocess)(i)
36+
joblib.delayed(subprocess)(i)
3737
for i in range(n_jobs))
3838

3939
return results
@@ -60,7 +60,7 @@ def subprocess(i):
6060
return aa[i,i]
6161

6262
results = joblib.Parallel(n_jobs=n_jobs)(
63-
joblib.delayed(subprocess)(i)
63+
joblib.delayed(subprocess)(i)
6464
for i in range(n_jobs))
6565

6666
return results
@@ -91,7 +91,7 @@ def func():
9191
# Creating data: 10000x10000 ... done (0.75 Gb). Starting processing: n_jobs=64 ... done (0:00:14.701243). RSS: 111362.79
9292
# Creating data: 10000x10000 ... done (0.75 Gb). Starting processing: n_jobs=64 ... done (0:00:15.020202). USS: 56108.69
9393
# Creating data: 10000x10000 ... done (0.75 Gb). Starting processing: n_jobs=64 ... done (0:00:15.072918). PSS: 54826.61
94-
94+
9595
# Conclusion:
9696
# * RSS is overestimating like crazy (I checked the actual memory usage using htop)
9797

@@ -108,17 +108,17 @@ def subprocess(i):
108108
aa = a.copy()
109109
time.sleep(10)
110110
return r
111-
111+
112112
# r = a[1,1]
113113
# # time.sleep(10)
114114
# return r
115-
115+
116116
pass
117117

118118
start = datetime.datetime.now()
119119
print("Starting processing: n_jobs={n_jobs} ... ".format(n_jobs=n_jobs), end="")
120120
results = joblib.Parallel(n_jobs=n_jobs)(
121-
joblib.delayed(subprocess)(i)
121+
joblib.delayed(subprocess)(i)
122122
for i in range(n_jobs))
123123
print("done ({}). ".format(datetime.datetime.now() - start), end="")
124124

examples/reporting_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def my_func1():
1818

1919
if __name__ == '__main__':
2020
my_func()
21-
my_func1()
21+
my_func1()

0 commit comments

Comments
 (0)