Skip to content

Commit eb3ce16

Browse files
authored
Merge pull request #13 from sjmonson/feat/pyproject
Make Inference-Perf Package-able / Use Modern Python Tooling
2 parents 626ed75 + e962108 commit eb3ce16

File tree

8 files changed

+586
-18
lines changed

8 files changed

+586
-18
lines changed

Diff for: .github/workflows/format.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99

1010
jobs:
11-
black-format-check:
11+
format-check:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout Code

Diff for: .pre-commit-config.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pdm-project/pdm
3+
rev: 2.22.3
4+
hooks:
5+
- id: pdm-lock-check
6+
name: check lock file matches pyproject
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.9.4
9+
hooks:
10+
- id: ruff
11+
name: run the linter
12+
args: [ --fix ]
13+
- id: ruff-format
14+
name: run the formatter
15+
- repo: https://github.com/pre-commit/mirrors-mypy
16+
rev: v1.14.1
17+
hooks:
18+
- id: mypy
19+
name: run static type check
20+
args: [--strict, --ignore-missing-imports]

Diff for: Makefile

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
VENV := .venv
22

3-
# Format Python code with black
3+
# Format Python code with ruff format
44
.PHONY: format
55
format:
6-
@echo "Formatting Python files with black..."
7-
$(VENV)/bin/black .
6+
@echo "Formatting Python files with ruff format..."
7+
$(VENV)/bin/ruff format
88

9-
# Run flake8 to lint Python code in the whole repository
9+
# Run ruff check to lint Python code in the whole repository
1010
.PHONY: lint
1111
lint:
12-
@echo "Linting Python files with flake8..."
13-
# stop if there are Python syntax errors or undefined names
14-
$(VENV)/bin/flake8 ./inference_perf --count --select=E9,F63,F7,F82 --show-source --statistics
15-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
16-
$(VENV)/bin/flake8 ./inference_perf --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
12+
@echo "Linting Python files with ruff check..."
13+
$(VENV)/bin/ruff check
1714

1815
# Perform type checking
1916
.PHONY: type-check
@@ -30,7 +27,7 @@ all-deps:
3027
fi
3128
@echo "Activating virtual environment and installing dependencies..."
3229
$(VENV)/bin/pip install --upgrade pip
33-
$(VENV)/bin/pip install -r requirements.txt
30+
$(VENV)/bin/pip install -e .
3431

3532
.PHONY: check
36-
check: all-deps lint type-check
33+
check: all-deps lint type-check

Diff for: pdm.lock

+489
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[project]
2+
name = "inference-perf"
3+
version = "0.0.1"
4+
description = "A GenAI inference performance benchmarking tool."
5+
authors = []
6+
dependencies = [
7+
"aiohttp>=3.11.11",
8+
]
9+
requires-python = ">=3.12"
10+
readme = "README.md"
11+
license = {text = "Apache-2.0"}
12+
13+
14+
[dependency-groups]
15+
dev = [
16+
"mypy>=1.14.1",
17+
"ruff>=0.9.4",
18+
"pre-commit>=4.1.0",
19+
]
20+
21+
[tool.ruff]
22+
# The GitHub editor is 127 chars wide
23+
line-length = 127
24+
indent-width = 4
25+
26+
[tool.ruff.lint]
27+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
28+
# On top of the defaults (`E4`, E7`, `E9`, and `F`), enable flake8-bugbear (`B`)
29+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
30+
# McCabe complexity (`C901`) by default.
31+
select = ["E4", "E7", "E9", "F", "B"]
32+
ignore = []
33+
34+
# Allow fix for all enabled rules (when `--fix`) is provided.
35+
fixable = ["ALL"]
36+
unfixable = []
37+
38+
[tool.ruff.format]
39+
# Like Black, use double quotes for strings.
40+
quote-style = "double"
41+
42+
# Like Black, indent with spaces, rather than tabs.
43+
indent-style = "space"
44+
45+
# Like Black, respect magic trailing commas.
46+
skip-magic-trailing-comma = false
47+
48+
# Like Black, automatically detect the appropriate line ending.
49+
line-ending = "auto"
50+
51+
# Enable auto-formatting of code examples in docstrings. Markdown,
52+
# reStructuredText code/literal blocks and doctests are all supported.
53+
#
54+
# This is currently disabled by default, but it is planned for this
55+
# to be opt-out in the future.
56+
docstring-code-format = false
57+
58+
# Set the line length limit used when formatting code snippets in
59+
# docstrings.
60+
#
61+
# This only has an effect when the `docstring-code-format` setting is
62+
# enabled.
63+
docstring-code-line-length = "dynamic"
64+
65+
[tool.pdm]
66+
distribution = true
67+

Diff for: requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
-r requirements/build.txt
2-
-r requirements/run.txt
1+
-e . # Install requirements from pyproject

Diff for: requirements/build.txt

-3
This file was deleted.

Diff for: requirements/run.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)