Skip to content

Commit 63b3185

Browse files
committed
Migrate to uv, lint fixes
1 parent 123e26c commit 63b3185

File tree

16 files changed

+2934
-5104
lines changed

16 files changed

+2934
-5104
lines changed

.github/workflows/code_checks.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- .pre-commit-config.yaml
1010
- .github/workflows/code_checks.yml
1111
- '**.py'
12-
- poetry.lock
12+
- uv.lock
1313
- pyproject.toml
1414
- '**.ipynb'
1515
pull_request:
@@ -20,29 +20,30 @@ on:
2020
- .pre-commit-config.yaml
2121
- .github/workflows/code_checks.yml
2222
- '**.py'
23-
- poetry.lock
23+
- uv.lock
2424
- pyproject.toml
2525
- '**.ipynb'
2626

2727
jobs:
2828
run-code-check:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v4.1.1
32-
- name: Install and configure Poetry
33-
uses: snok/install-poetry@v1
31+
- uses: actions/checkout@v4.2.2
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v5
3434
with:
35-
virtualenvs-create: true
36-
virtualenvs-in-project: true
37-
- uses: actions/[email protected]
35+
# Install a specific version of uv.
36+
version: "0.5.21"
37+
enable-cache: true
38+
- name: "Set up Python"
39+
uses: actions/setup-python@v5
3840
with:
39-
python-version: '3.10'
40-
cache: 'poetry'
41+
python-version-file: ".python-version"
42+
- name: Install the project
43+
run: uv sync --dev
4144
- name: Install dependencies and check code
4245
run: |
43-
poetry env use '3.10'
4446
source .venv/bin/activate
45-
poetry install --with test --all-extras
4647
pre-commit run --all-files
4748
- name: pip-audit (gh-action-pip-audit)
4849
uses: pypa/[email protected]

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ target/
8181
profile_default/
8282
ipython_config.py
8383

84-
# pyenv
85-
.python-version
86-
8784
# pipenv
8885
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8986
# However, in case of collaboration, if having platform-specific dependencies or dependencies

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

examples/inference/llm/chat_completions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"""Example of how to use the OpenAI API to generate chat completions."""
2+
13
from openai import OpenAI
24

3-
# The url is located in the .vLLM_model-variant_url file in the corresponding model directory.
5+
6+
# The url is located in the .vLLM_model-variant_url file in the corresponding
7+
# model directory.
48
client = OpenAI(base_url="http://gpuXXX:XXXX/v1", api_key="EMPTY")
59

610
# Update the model path accordingly

examples/inference/llm/completions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"""Example of how to use the OpenAI API to generate completions."""
2+
13
from openai import OpenAI
24

3-
# The url is located in the .vLLM_model-variant_url file in the corresponding model directory.
5+
6+
# The url is located in the .vLLM_model-variant_url file in the corresponding
7+
# model directory.
48
client = OpenAI(base_url="http://gpuXXX:XXXX/v1", api_key="EMPTY")
59

610
# Update the model path accordingly

examples/inference/vlm/vision_completions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"""Example of using the OpenAI API to generate completions for vision tasks."""
2+
13
from openai import OpenAI
24

3-
# The url is located in the .vLLM_model-variant_url file in the corresponding model directory.
5+
6+
# The url is located in the .vLLM_model-variant_url file in the corresponding
7+
# model directory.
48
client = OpenAI(base_url="http://gpuXXX:XXXX/v1", api_key="EMPTY")
59

610
# Update the model path accordingly

examples/logits/logits.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"""Example of how to get logits from the model."""
2+
13
from openai import OpenAI
24

3-
# The url is located in the .vLLM_model-variant_url file in the corresponding model directory.
5+
6+
# The url is located in the .vLLM_model-variant_url file in the corresponding
7+
# model directory.
48
client = OpenAI(base_url="http://gpuXXX:XXXXX/v1", api_key="EMPTY")
59

610
completion = client.completions.create(

poetry.lock

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

profile/avg_throughput.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
"""Calculate the average prompt and generation throughput from a log file."""
2+
13
import argparse
24
import re
35

46

5-
def filter_throughput(log_file_path):
7+
def filter_throughput(log_file_path: str) -> None:
8+
"""Filter log file for non-zero entries and calculate the avg throughput."""
69
avg_prompt_throughput = []
710
avg_generation_throughput = []
811
# Define a regular expression pattern to extract throughput values
@@ -33,7 +36,8 @@ def filter_throughput(log_file_path):
3336
)
3437

3538

36-
def main():
39+
def main() -> None:
40+
"""Run the main function."""
3741
# Create the parser
3842
parser = argparse.ArgumentParser(
3943
description="Filter log file for non-zero throughput entries."

profile/gen.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
"""Testing script."""
2+
13
import time
4+
from typing import List, Union
25

36
import requests
47

8+
59
# Change the ENDPOINT and MODEL_PATH to match your setup
610
ENDPOINT = "http://gpuXXX:XXXX/v1"
711
MODEL_PATH = "Meta-Llama-3-70B"
@@ -71,19 +75,20 @@
7175
]
7276

7377

74-
def send_request(prompt):
78+
def send_request(prompt: List[str]) -> Union[float, None]:
79+
"""Send a request to the API."""
7580
data = {"model": f"{MODEL_PATH}", "prompt": prompt, "max_tokens": 100}
7681
start_time = time.time()
7782
response = requests.post(f"{ENDPOINT}/completions", headers=HEADERS, json=data)
7883
duration = time.time() - start_time
7984
if response.status_code == 200:
8085
return duration
81-
else:
82-
return None
86+
return None
8387

8488

85-
def main():
86-
for i in range(10):
89+
def main() -> None:
90+
"""Run main function."""
91+
for _ in range(10):
8792
print("Sending 20x requests 0-52...")
8893
send_request(PROMPTS * 20)
8994
print("Done!")

0 commit comments

Comments
 (0)