Skip to content

Commit 9a5a175

Browse files
authored
Merge pull request #28 from VectorInstitute/migrate_to_uv_lint_fixes
Migrate to uv, add lint fixes, improvements and some unit tests
2 parents 123e26c + b91fe1a commit 9a5a175

File tree

23 files changed

+3355
-5159
lines changed

23 files changed

+3355
-5159
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/[email protected]
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/[email protected]
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]

.github/workflows/unit_tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: unit tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
paths:
9+
- .pre-commit-config.yaml
10+
- .github/workflows/code_checks.yml
11+
- .github/workflows/docs_build.yml
12+
- .github/workflows/docs_deploy.yml
13+
- .github/workflows/unit_tests.yml
14+
- .github/workflows/integration_tests.yml
15+
- '**.py'
16+
- '**.ipynb'
17+
- uv.lock
18+
- pyproject.toml
19+
- '**.rst'
20+
- '**.md'
21+
pull_request:
22+
branches:
23+
- main
24+
- develop
25+
paths:
26+
- .pre-commit-config.yaml
27+
- .github/workflows/code_checks.yml
28+
- .github/workflows/docs_build.yml
29+
- .github/workflows/docs_deploy.yml
30+
- .github/workflows/unit_tests.yml
31+
- .github/workflows/integration_tests.yml
32+
- '**.py'
33+
- '**.ipynb'
34+
- uv.lock
35+
- pyproject.toml
36+
- '**.rst'
37+
- '**.md'
38+
39+
jobs:
40+
unit-tests:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/[email protected]
44+
45+
- name: Install uv
46+
uses: astral-sh/[email protected]
47+
with:
48+
# Install a specific version of uv.
49+
version: "0.5.21"
50+
enable-cache: true
51+
52+
- name: "Set up Python"
53+
uses: actions/[email protected]
54+
with:
55+
python-version-file: ".python-version"
56+
57+
- name: Install the project
58+
run: uv sync --all-extras --dev
59+
60+
- name: Install dependencies and check code
61+
run: |
62+
uv run pytest -m "not integration_test" --cov vec_inf --cov-report=xml tests
63+
64+
# Uncomment this once this repo is configured on Codecov
65+
- name: Upload coverage to Codecov
66+
uses: codecov/[email protected]
67+
with:
68+
token: ${{ secrets.CODECOV_TOKEN }}
69+
slug: VectorInstitute/vec-inf
70+
fail_ci_if_error: true
71+
verbose: true

.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

.pre-commit-config.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ repos:
3939
- id: nbqa-ruff
4040
args: [--fix, --exit-non-zero-on-fix]
4141

42+
- repo: local
43+
hooks:
44+
- id: pytest
45+
name: pytest
46+
entry: python3 -m pytest -m "not integration_test"
47+
language: system
48+
pass_filenames: false
49+
always_run: true
50+
4251
ci:
4352
autofix_commit_msg: |
4453
[pre-commit.ci] Add auto fixes from pre-commit.com hooks
@@ -48,5 +57,5 @@ ci:
4857
autoupdate_branch: ''
4958
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
5059
autoupdate_schedule: weekly
51-
skip: [mypy]
60+
skip: [pytest,mypy]
5261
submodules: false

.python-version

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

codecov.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
notify:
4+
after_n_builds: 2
5+
wait_for_ci: yes
6+
comment:
7+
behavior: default
8+
layout: reach,diff,flags,tree,reach
9+
show_carryforward_flags: false
10+
require_changes: true
11+
coverage:
12+
status:
13+
changes: true
14+
default_rules:
15+
flag_coverage_not_uploaded_behavior: include
16+
patch: true
17+
project: true
18+
github_checks:
19+
annotations: true

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(

0 commit comments

Comments
 (0)