Skip to content

Make Inference-Perf Package-able / Use Modern Python Tooling #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

jobs:
black-format-check:
format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pdm-project/pdm
rev: 2.22.3
hooks:
- id: pdm-lock-check
name: check lock file matches pyproject
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.4
hooks:
- id: ruff
name: run the linter
args: [ --fix ]
- id: ruff-format
name: run the formatter
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
name: run static type check
args: [--strict, --ignore-missing-imports]
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
VENV := .venv

# Format Python code with black
# Format Python code with ruff format
.PHONY: format
format:
@echo "Formatting Python files with black..."
$(VENV)/bin/black .
@echo "Formatting Python files with ruff format..."
$(VENV)/bin/ruff format

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

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

.PHONY: check
check: all-deps lint type-check
check: all-deps lint type-check
489 changes: 489 additions & 0 deletions pdm.lock

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[project]
name = "inference-perf"
version = "0.0.1"
description = "A GenAI inference performance benchmarking tool."
authors = []
dependencies = [
"aiohttp>=3.11.11",
]
requires-python = ">=3.12"
readme = "README.md"
license = {text = "Apache-2.0"}


[dependency-groups]
dev = [
"mypy>=1.14.1",
"ruff>=0.9.4",
"pre-commit>=4.1.0",
]

[tool.ruff]
# The GitHub editor is 127 chars wide
line-length = 127
indent-width = 4

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# On top of the defaults (`E4`, E7`, `E9`, and `F`), enable flake8-bugbear (`B`)
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "B"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

[tool.pdm]
distribution = true

3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
-r requirements/build.txt
-r requirements/run.txt
-e . # Install requirements from pyproject
3 changes: 0 additions & 3 deletions requirements/build.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/run.txt

This file was deleted.