Skip to content

Commit 0ededb4

Browse files
aniketmauryaBorda
andauthored
uv for CI - faster CI (#563)
* Update CI workflow to utilize UV for Python package management and testing - Added environment variable `UV_SYSTEM_PYTHON` to enable UV integration. - Replaced direct `pip` commands with `uv pip` for installing dependencies and running tests. - Updated test and coverage commands to use `uv run` for improved execution within the UV environment. * fiix * fix * updae * upgrade uv * add env * fix * update * fix * fix * up * Update project configuration and dependencies in pyproject.toml and .gitignore - Added `uv.lock` to .gitignore to prevent lock file from being tracked. - Refactored pyproject.toml to define project metadata, including name, dynamic versioning, and Python requirements. - Specified dependencies for the project, including FastAPI, Uvicorn, and others for development. * update * Refactor project configuration by consolidating setup into pyproject.toml - Removed setup.py and requirements.txt files. - Enhanced pyproject.toml with project metadata, including description, authors, and URLs. - Updated Python version requirement to >=3.8 and added relevant classifiers. - Defined project scripts for command-line entry points. * fix * fix * fic ci * fix * update * fix * sync * fix * fix * fix azure * fix requirements * fix toml * backward compatibility * fix * fix ci * fix gpu test * fix python script subprocess * update * fix gpu test * fix gpu * Apply suggestions from code review * Apply suggestions from code review * cat requirements.txt * list before and after * echo * echo * remove min dep * Update ci-testing.yml * fixes --------- Co-authored-by: Jirka Borovec <[email protected]>
1 parent 25ef3db commit 0ededb4

File tree

14 files changed

+150
-191
lines changed

14 files changed

+150
-191
lines changed

.azure/gpu-tests.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ jobs:
4545
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${CUDA_version_mm}/torch_stable.html"
4646
displayName: "set Env. vars"
4747
48+
- bash: |
49+
pip install uv
50+
displayName: "Install uv"
51+
4852
- bash: |
4953
whoami && id
5054
lspci | egrep 'VGA|3D'
@@ -53,44 +57,43 @@ jobs:
5357
echo $CUDA_VISIBLE_DEVICES
5458
echo $TORCH_URL
5559
python --version
56-
pip --version
57-
pip cache dir
58-
pip list
60+
uv --version
61+
uv cache dir
62+
uv pip list
5963
displayName: "Image info & NVIDIA"
6064
6165
- bash: |
62-
pip install . -U --prefer-binary \
63-
-r ./_requirements/test.txt --find-links=${TORCH_URL}
66+
uv sync --all-extras --dev
6467
displayName: "Install environment"
6568
6669
- bash: |
67-
pip list
70+
uv pip list
6871
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu >= 2, f'found GPUs: {mgpu}'"
6972
displayName: "Sanity check"
7073
7174
- bash: |
72-
pip install -q py-tree
73-
py-tree /var/tmp/torch
75+
uv pip install -q py-tree
76+
uv run py-tree /var/tmp/torch
7477
displayName: "Show caches"
7578
7679
- bash: |
77-
coverage run --source litserve -m pytest src tests -v
80+
uv run coverage run --source litserve -m pytest src tests -v
7881
displayName: "Testing"
7982
8083
- bash: |
81-
python -m coverage report
82-
python -m coverage xml
83-
python -m codecov --token=$(CODECOV_TOKEN) --name="GPU-coverage" \
84+
uv run coverage report
85+
uv run coverage xml
86+
uv run codecov --token=$(CODECOV_TOKEN) --name="GPU-coverage" \
8487
--commit=$(Build.SourceVersion) --flags=gpu,unittest --env=linux,azure
8588
ls -l
8689
displayName: "Statistics"
8790
8891
- bash: |
89-
pip install torch torchvision -U -q --find-links=${TORCH_URL} -r _requirements/perf.txt
90-
export PYTHONPATH=$PWD && python tests/parity_fastapi/main.py
92+
uv pip install torch torchvision -U -q --find-links=${TORCH_URL}
93+
export PYTHONPATH=$PWD && uv run tests/parity_fastapi/main.py
9194
displayName: "Run FastAPI parity tests"
9295
9396
- bash: |
94-
pip install gpustat wget -U -q
97+
uv pip install gpustat wget -U -q
9598
bash tests/perf_test/bert/run_test.sh
9699
displayName: "Run GPU perf test"

.github/workflows/ci-minimal-dependency-check.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
21+
- name: Install uv and setup python
22+
uses: astral-sh/setup-uv@v6
2323
with:
24-
python-version: "3.11"
24+
activate-environment: true
25+
python-version: "3.12"
26+
enable-cache: true
2527

2628
- name: Install LitServe
2729
run: |
28-
pip --version
29-
pip install . psutil -U -q
30-
pip list
30+
uv sync --no-dev
31+
uv pip install . psutil -U -q
32+
uv pip list
3133
3234
- name: Tests
3335
run: python tests/minimal_run.py

.github/workflows/ci-parity.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
21+
- name: Install uv and setup python
22+
uses: astral-sh/setup-uv@v6
2323
with:
24-
python-version: "3.11"
24+
activate-environment: true
25+
python-version: "3.12"
26+
enable-cache: true
2527

2628
- name: Install LitServe
2729
run: |
28-
pip --version
29-
pip install . torchvision jsonargparse uvloop tenacity -U -q -r _requirements/test.txt -U -q
30-
pip list
30+
uv sync --all-extras --dev
31+
uv pip compile pyproject.toml -o requirements.txt
32+
uv pip install torchvision jsonargparse uvloop tenacity -U -q
33+
uv pip list
3134
3235
- name: Parity test
3336
run: export PYTHONPATH=$PWD && python tests/parity_fastapi/main.py

.github/workflows/ci-testing.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,44 @@ jobs:
2121
include:
2222
- { os: "macos-latest", python-version: "3.12" }
2323
- { os: "windows-latest", python-version: "3.11" }
24-
- { os: "ubuntu-22.04", python-version: "3.9", requires: "oldest" }
24+
#- { os: "ubuntu-22.04", python-version: "3.9", requires: "oldest" } # fixme
2525

2626
timeout-minutes: 35
2727
env:
2828
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
2929

3030
steps:
3131
- uses: actions/checkout@v4
32-
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v5
32+
- name: Install uv and setup python
33+
uses: astral-sh/setup-uv@v6
3434
with:
35+
activate-environment: true
3536
python-version: ${{ matrix.python-version }}
36-
cache: "pip"
37+
enable-cache: true
3738

38-
- name: Set min. dependencies
39-
if: matrix.requires == 'oldest'
39+
- name: Set up dependencies
4040
run: |
41-
pip install 'lightning-utilities[cli]'
42-
python -m lightning_utilities.cli requirements set-oldest --req_files='["requirements.txt", "_requirements/test.txt"]'
41+
uv pip compile pyproject.toml -o requirements.txt
42+
cat requirements.txt
4343
44-
- name: Install package & dependencies
44+
# TODO: FIX THIS TO SUPPORT PYPROJECT.TOML
45+
# - name: Set min. dependencies
46+
# if: matrix.requires == 'oldest'
47+
# run: |
48+
# uv pip install 'lightning-utilities[cli]'
49+
# uv run python -m lightning_utilities.cli requirements set-oldest --req_files='["requirements.txt"]'
50+
# cat requirements.txt
51+
52+
- name: Install package
4553
run: |
46-
pip --version
47-
pip install -e '.[test]' -U -q --find-links $TORCH_URL
48-
pip list
54+
uv pip list
55+
uv sync --all-extras --dev
56+
uv pip list
4957
5058
- name: Tests
5159
timeout-minutes: 15
5260
run: |
53-
python -m pytest --cov=litserve src/ tests/ -v -s --durations=100
61+
pytest --cov=litserve src/ tests/ -v -s --durations=100
5462
5563
- name: Statistics
5664
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ venv.bak/
130130
lightning_logs/
131131
MNIST
132132
.DS_Store
133+
uv.lock

_requirements/test.txt

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

pyproject.toml

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,63 @@
22
license_file = "LICENSE"
33
description-file = "README.md"
44

5-
[build-system]
6-
requires = [
7-
"setuptools",
8-
"wheel",
5+
[project]
6+
name = "litserve"
7+
dynamic = ["version"]
8+
description = "Lightweight AI server."
9+
readme = "README.md"
10+
license = {text = "Apache-2.0"}
11+
authors = [
12+
{name = "Lightning-AI et al.", email = "[email protected]"}
13+
]
14+
requires-python = ">=3.9"
15+
keywords = ["deep learning", "pytorch", "AI"]
16+
classifiers = [
17+
"Environment :: Console",
18+
"Natural Language :: English",
19+
"Development Status :: 4 - Beta",
20+
"Intended Audience :: Developers",
21+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
22+
"Topic :: Scientific/Engineering :: Information Analysis",
23+
"License :: OSI Approved :: Apache Software License",
24+
"Operating System :: OS Independent",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
]
32+
33+
dependencies = [
34+
"fastapi>=0.100",
35+
"pyzmq>=22.0.0",
36+
"uvicorn[standard]>=0.29.0",
937
]
1038

39+
[project.urls]
40+
Homepage = "https://github.com/Lightning-AI/litserve"
41+
"Bug Tracker" = "https://github.com/Lightning-AI/litserve/issues"
42+
Documentation = "https://lightning-ai.github.io/litserve/"
43+
"Source Code" = "https://github.com/Lightning-AI/litserve"
44+
Download = "https://github.com/Lightning-AI/litserve"
45+
46+
[project.scripts]
47+
litserve = "litserve.__main__:main"
48+
lightning = "litserve.cli:main"
49+
50+
51+
[build-system]
52+
requires = ["hatchling"]
53+
build-backend = "hatchling.build"
54+
55+
[tool.hatch.version]
56+
path = "src/litserve/__about__.py"
57+
pattern = "__version__ = \"(?P<version>.+)\""
58+
59+
60+
[tool.hatch.metadata]
61+
allow-direct-references = true
1162

1263
[tool.check-manifest]
1364
ignore = [
@@ -16,7 +67,6 @@ ignore = [
1667
".github/*"
1768
]
1869

19-
2070
[tool.pytest.ini_options]
2171
norecursedirs = [
2272
".git",
@@ -128,3 +178,30 @@ convention = "google"
128178
[tool.ruff.lint.mccabe]
129179
# Unlike Flake8, default to a complexity level of 10.
130180
max-complexity = 10
181+
182+
[dependency-groups]
183+
dev = [
184+
"asgi-lifespan>=2.1.0",
185+
"coverage[toml]>=7.5.3",
186+
"fastmcp>=2.9.2 ; python_full_version >= '3.10'",
187+
"httpx>=0.27.0",
188+
"lightning>2.0.0",
189+
"mypy==1.16.1",
190+
"numpy<3.0",
191+
"openai>=1.12.0",
192+
"pillow>=11.3.0",
193+
"psutil>=7.0.0",
194+
"pytest>=8.0",
195+
"pytest-asyncio>=1.0.0",
196+
"pytest-cov>=6.2.1",
197+
"pytest-retry>=1.6.3",
198+
"python-multipart>=0.0.20",
199+
"requests>=2.32.4",
200+
"torch>2.0.0",
201+
"transformers>=4.53.0",
202+
"uvloop>=0.21.0 ; sys_platform != 'win32'",
203+
"tenacity>=9.1.2",
204+
"jsonargparse",
205+
"rich",
206+
"torchvision>=0.22.1",
207+
]

requirements.txt

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

0 commit comments

Comments
 (0)