Skip to content

Commit 8541bf0

Browse files
Merge pull request #79 from apdavison/faster-build
Replace the "black" formatter with "ruff"
2 parents 6f60dd3 + aabef62 commit 8541bf0

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ jobs:
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323

24-
- name: Run build
24+
- name: Install requirements
2525
run: |
2626
pip install -r requirements.txt
27+
28+
- name: Run build
29+
run: |
2730
python build.py
2831
2932
- name: Test built package

build.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
import subprocess
77
import sys
8+
from time import perf_counter
89
from urllib.request import urlopen, HTTPError
910

1011
from jinja2 import Environment, select_autoescape, FileSystemLoader
@@ -23,6 +24,8 @@
2324
print(f"Triggering the generation of Python package for openMINDS, from the {args.branch} branch")
2425
print("*******************************************************************************")
2526

27+
start_time = perf_counter()
28+
2629
# Step 0 - read code for additional methods
2730
additional_methods = {}
2831
with open("pipeline/src/additional_methods/by_name.py.txt") as fp:
@@ -35,6 +38,7 @@
3538
instance_loader = InstanceLoader()
3639
if os.path.exists("target"):
3740
shutil.rmtree("target")
41+
print(f"Cloned {args.branch} branch of central repository ({perf_counter() - start_time} s)")
3842

3943
# Step 2 - load instances
4044
instances = {}
@@ -45,6 +49,7 @@
4549
with open(instance_path) as fp:
4650
instance_data = json.load(fp)
4751
instances[version][instance_data["@type"]].append(instance_data)
52+
print(f"Loaded instances ({perf_counter() - start_time} s)")
4853

4954
python_modules = defaultdict(list)
5055

@@ -86,6 +91,9 @@
8691
parent_path = ".".join(parts[:-1])
8792
python_modules[parent_path].append((parts[-1], class_name))
8893

94+
print(f"Processed schemas ({perf_counter() - start_time} s)")
95+
96+
8997
# Step 5 - create additional files, e.g. __init__.py
9098
openminds_modules = defaultdict(set)
9199
for path in sorted(python_modules):
@@ -151,5 +159,8 @@
151159
with open("target/codemeta.json", "w") as fp:
152160
json.dump(codemeta, fp, indent=2)
153161

162+
print(f"Generated additional files ({perf_counter() - start_time} s)")
163+
154164
# Step 6 - run formatter
155-
subprocess.call([sys.executable, "-m", "black", "--quiet", "target"])
165+
subprocess.call(["ruff", "format", "--quiet", "target"])
166+
print(f"Formatted all files ({perf_counter() - start_time} s)")

pipeline/src/pyproject_template.toml.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dev = [
3434
"setuptools",
3535
"wheel",
3636
"sphinx",
37-
"black",
37+
"ruff",
3838
"twine"
3939
]
4040

@@ -51,5 +51,5 @@ include = ["openminds*"]
5151
]
5252
build-backend = "setuptools.build_meta"
5353

54-
[tool.black]
54+
[tool.ruff]
5555
line-length = 119

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
gitpython
22
jinja2
3-
black
3+
ruff

0 commit comments

Comments
 (0)