Skip to content

Commit 11704c5

Browse files
authored
CI: Add CI pipeline and pre-commit hooks (#7)
1 parent 08511eb commit 11704c5

File tree

19 files changed

+167
-26
lines changed

19 files changed

+167
-26
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,3 @@ cython_debug/
159159
# and can be added to the global gitignore or merged into this file. For a more nuclear
160160
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
161161
#.idea/
162-

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Global code owners
2+
* @slin1237 @CatherineSue
3+
4+
# Specific ownership for critical files
5+
/.github/ @slin1237 @CatherineSue
6+
/genai_bench/ @slin1237 @CatherineSue
7+
/tests/ @slin1237 @CatherineSue
8+
pyproject.toml @slin1237 @CatherineSue

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
26+
27+
- name: Update pip and install uv
28+
run: |
29+
python -m pip install -U pip hatchling
30+
python -m pip install -U uv
31+
32+
- name: Check uv version
33+
run: python -m uv version
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m uv pip install --system .
38+
python -m uv pip install --system ".[dev]"
39+
40+
- name: Run tests with coverage
41+
run: |
42+
uv run --no-reinstall pytest tests --cov --cov-report=xml --cov-config=.coveragerc -v -s
43+
44+
- name: Check coverage threshold
45+
run: |
46+
uv run --no-reinstall coverage report --show-missing --fail-under=93
47+
48+
- name: Upload coverage to Codecov
49+
uses: codecov/codecov-action@v3
50+
with:
51+
file: ./coverage.xml
52+
fail_ci_if_error: false
53+
54+
lint:
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: "3.11"
64+
65+
- name: Install uv
66+
uses: astral-sh/setup-uv@v3
67+
68+
- name: Update pip and install uv
69+
run: |
70+
python -m pip install -U pip hatchling
71+
python -m pip install -U uv
72+
73+
- name: Install dependencies
74+
run: |
75+
python -m uv pip install --system .
76+
python -m uv pip install --system ".[dev]"
77+
78+
- name: Check formatting with ruff
79+
run: |
80+
uv run --no-reinstall ruff format --diff genai_bench tests
81+
82+
- name: Lint with ruff
83+
run: |
84+
uv run --no-reinstall ruff check genai_bench tests
85+
86+
build:
87+
runs-on: ubuntu-latest
88+
needs: [test, lint]
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@v4
95+
with:
96+
python-version: "3.11"
97+
98+
- name: Install uv
99+
uses: astral-sh/setup-uv@v3
100+
101+
- name: Update pip and install uv
102+
run: |
103+
python -m pip install -U pip hatchling
104+
python -m pip install -U uv
105+
106+
- name: Install dependencies
107+
run: |
108+
python -m uv pip install --no-color -vvv .
109+
python -m uv pip install ".[dev]"
110+
111+
- name: Build package
112+
run: |
113+
python -m uv build -vvv

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ genai_bench*.log
4242
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
4343
# refer to https://docs.cursor.com/context/ignore-files
4444
.cursorignore
45-
.cursorindexingignore
45+
.cursorindexingignore

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-merge-conflict
8+
- id: check-case-conflict
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-yaml
12+
- id: debug-statements
13+
- id: check-added-large-files
14+
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.7.4
17+
hooks:
18+
- id: ruff
19+
args: [--fix]
20+
files: ^(genai_bench|tests)/
21+
- id: ruff-format
22+
files: ^(genai_bench|tests)/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class AudioSampler(Sampler):
151151
def sample(self, scenario: Scenario) -> UserRequest:
152152
# Validate scenario
153153
self._validate_scenario(scenario)
154-
154+
155155
if self.output_modality == "text":
156156
return self._create_audio_to_text_request(scenario)
157157
elif self.output_modality == "embeddings":

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ RUN apt-get clean && \
3535
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /var/log/*
3636

3737
# start poetry shell to activate the virtual environment
38-
ENTRYPOINT ["genai-bench"]
38+
ENTRYPOINT ["genai-bench"]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,5 @@ pipx: ## Install pipx package manager.
9898
$(PYTHON_CMD) -m pip install -U pipx
9999

100100
.PHONY: uv
101-
uv: pipx ## Install uv and make a virtual env with
102-
$(PYTHON_CMD) -m pipx ensurepath; $(PYTHON_CMD) -m pipx install uv; uv venv -p $(PYTHON_CMD)
101+
uv: pipx ## Install uv and make a virtual env with
102+
$(PYTHON_CMD) -m pipx ensurepath; $(PYTHON_CMD) -m pipx install uv; uv venv -p $(PYTHON_CMD)

USER_GUIDE.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ Below is a sample command you can use to start a benchmark. The command will con
166166

167167
```shell
168168
# Optional. This is required when you load the tokenizer from huggingface.co with a model-id
169-
export HF_TOKEN="<your-key>"
170-
# HF transformers will log a warning about torch not installed, since benchmark doesn't really need torch
169+
export HF_TOKEN="<your-key>"
170+
# HF transformers will log a warning about torch not installed, since benchmark doesn't really need torch
171171
# and cuda, we use this env to disable the warning
172-
export TRANSFORMERS_VERBOSITY=error
172+
export TRANSFORMERS_VERBOSITY=error
173173
174174
genai-bench benchmark --api-backend openai \
175175
--api-base "http://localhost:8082" \
@@ -182,7 +182,7 @@ genai-bench benchmark --api-backend openai \
182182
--server-engine "vLLM" \
183183
--server-gpu-type "H100" \
184184
--server-version "v0.6.0" \
185-
--server-gpu-count 4
185+
--server-gpu-count 4
186186
```
187187

188188
<!-- TOC --><a name="start-a-vision-benchmark"></a>
@@ -238,7 +238,7 @@ genai-bench benchmark --api-backend openai \
238238
--traffic-scenario "E(1024)" \
239239
--server-gpu-type "H100" \
240240
--server-version "v0.4.2" \
241-
--server-gpu-count 1
241+
--server-gpu-count 1
242242
```
243243

244244
<!-- TOC --><a name="start-a-rerank-benchmark"></a>
@@ -270,7 +270,7 @@ genai-bench benchmark --api-backend oci-cohere \
270270

271271
### Start a benchmark against OCI Cohere
272272

273-
Below is a sample command to trigger a benchmark against cohere chat API.
273+
Below is a sample command to trigger a benchmark against cohere chat API.
274274

275275
```shell
276276
genai-bench benchmark --api-backend oci-cohere \
@@ -311,7 +311,7 @@ genai-bench benchmark \
311311
--max-requests-per-run 300 \
312312
--num-concurrency 1 --num-concurrency 2 --num-concurrency 4 \
313313
--num-concurrency 8 --num-concurrency 16 --num-concurrency 32 \
314-
--traffic-scenario "N(480,240)/(300,150)" --traffic-scenario "D(100,100)"
314+
--traffic-scenario "N(480,240)/(300,150)" --traffic-scenario "D(100,100)"
315315
```
316316

317317
<!-- TOC --><a name="notes-on-specific-options"></a>
@@ -350,7 +350,7 @@ For heavier traffic scenarios, like `D(16000,200)` or `D(128000,200)`, use the f
350350
If you see the message below in the genai-bench logs, it indicates that a single process is insufficient to generate the desired load.
351351

352352
```log
353-
CPU usage above 90%! This may constrain your throughput and may even give inconsistent response time measurements!
353+
CPU usage above 90%! This may constrain your throughput and may even give inconsistent response time measurements!
354354
```
355355

356356
To address this, you can increase the number of worker processes using the `--num-workers` option. For example, to spin up 4 worker processes, use:
@@ -364,9 +364,9 @@ This distributes the load across multiple processes on a single machine, improvi
364364

365365
#### Notes on Usage
366366

367-
1. This feature is experimental, so monitor the system’s behavior when enabling multiple workers.
367+
1. This feature is experimental, so monitor the system’s behavior when enabling multiple workers.
368368
2. Recommended Limit: Do **not** set the number of workers to more than 16, as excessive worker processes can lead to resource contention and diminished performance.
369-
3. Ensure your system has sufficient CPU and memory resources to support the desired number of workers.
369+
3. Ensure your system has sufficient CPU and memory resources to support the desired number of workers.
370370
4. Adjust the number of workers based on your target load and system capacity to achieve optimal results.
371371

372372
<!-- TOC --><a name="using-dataset-configurations"></a>

examples/dataset_configs/config_llava-bench-in-the-wild.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
},
99
"prompt_column": "question",
1010
"image_column": "image"
11-
}
11+
}

0 commit comments

Comments
 (0)