Skip to content

Commit 815bcf2

Browse files
author
ks6088ts
committed
use uv instead of poetry
1 parent e9acc5b commit 815bcf2

File tree

12 files changed

+6039
-7642
lines changed

12 files changed

+6039
-7642
lines changed

.devcontainer/devcontainer.json

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
{
2-
"name": "Python 3.10",
3-
"image": "mcr.microsoft.com/devcontainers/python:3.10-bookworm",
4-
"customizations": {
5-
"vscode": {
6-
"settings": {
7-
"python.defaultInterpreterPath": "/usr/local/bin/python",
8-
"python.testing.pytestEnabled": true,
9-
"python.testing.unittestEnabled": false,
10-
"files.exclude": {
11-
".coverage": true,
12-
".pytest_cache": true,
13-
"__pycache__": true
14-
}
15-
},
16-
"extensions": [
17-
"ms-python.python",
18-
"ms-python.vscode-pylance",
19-
"charliermarsh.ruff",
20-
"ms-python.black-formatter"
21-
]
2+
"name": "Python 3.10",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.10-bookworm",
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"python.defaultInterpreterPath": "/usr/local/bin/python",
8+
"python.testing.pytestEnabled": true,
9+
"python.testing.unittestEnabled": false,
10+
"files.exclude": {
11+
".coverage": true,
12+
".pytest_cache": true,
13+
"__pycache__": true
2214
}
23-
},
24-
"forwardPorts": [
25-
8501
26-
],
27-
"postCreateCommand": "pipx install poetry && make install-deps-dev",
28-
"remoteUser": "vscode"
15+
},
16+
"extensions": [
17+
"ms-python.python",
18+
"ms-python.vscode-pylance",
19+
"charliermarsh.ruff",
20+
"ms-python.black-formatter"
21+
]
22+
}
23+
},
24+
"forwardPorts": [8501],
25+
"postCreateCommand": "pipx install uv && make install-deps-dev",
26+
"remoteUser": "vscode"
2927
}

.github/workflows/test.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ jobs:
2323
runs-on: ${{ matrix.platform }}
2424
steps:
2525
- uses: actions/checkout@v4
26-
- name: Set up Poetry
26+
- name: Set up uv
2727
shell: bash
28-
run: pipx install poetry
28+
run: pipx install uv
2929
- name: Set up Python ${{ matrix.python-version }}
3030
uses: actions/setup-python@v5
3131
with:
3232
python-version: ${{ matrix.python-version }}
33-
cache: "poetry"
3433
- name: Run CI tests
3534
shell: bash
3635
run: |

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM python:3.11.8-slim-bookworm AS requirements-stage
22

33
WORKDIR /tmp
44

5-
RUN pip install --no-cache-dir poetry==1.8.2
5+
RUN pip install --no-cache-dir uv==0.5.12
66

7-
COPY ./pyproject.toml ./poetry.lock* /tmp/
7+
COPY ./pyproject.toml ./uv.lock /tmp/
88

9-
RUN poetry export --without=dev -f requirements.txt --output requirements.txt --without-hashes
9+
RUN uv export --format requirements-txt --no-dev --no-hashes --output-file requirements.txt
1010

1111
FROM python:3.11.8-slim-bookworm
1212

Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,32 @@ info: ## show information
1414

1515
.PHONY: install-deps-dev
1616
install-deps-dev: ## install dependencies for development
17-
poetry install
18-
poetry run pre-commit install
17+
uv sync --all-extras
18+
uv run pre-commit install
1919

2020
.PHONY: install-deps
2121
install-deps: ## install dependencies for production
22-
poetry install --without dev
22+
uv sync --no-dev
2323

2424
.PHONY: format-check
2525
format-check: ## format check
26-
poetry run black . --check --verbose
26+
uv run ruff format --check --verbose
2727

2828
.PHONY: format
2929
format: ## format code
30-
poetry run isort .
31-
poetry run black . --verbose
30+
uv run ruff format --verbose
3231

3332
.PHONY: fix
3433
fix: format ## apply auto-fixes
35-
poetry run ruff check --fix
34+
uv run ruff check --fix
3635

3736
.PHONY: lint
3837
lint: ## lint
39-
poetry run ruff check .
38+
uv run ruff check .
4039

4140
.PHONY: test
4241
test: ## run tests
43-
poetry run pytest --capture=no
42+
uv run pytest --capture=no -vv
4443

4544
.PHONY: ci-test
4645
ci-test: install-deps-dev format-check lint test ## run CI tests
@@ -87,11 +86,11 @@ ci-test-docker: docker-lint docker-build docker-run ## run CI test for Docker
8786

8887
.PHONY: docs
8988
docs: ## build documentation
90-
poetry run mkdocs build
89+
uv run mkdocs build
9190

9291
.PHONY: docs-serve
9392
docs-serve: ## serve documentation
94-
poetry run mkdocs serve
93+
uv run mkdocs serve
9594

9695
.PHONY: ci-test-docs
9796
ci-test-docs: docs ## run CI test for documentation

docs/apps/13_langchain_toolkits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ $ npx playwright codegen --target=python
4747
##### [PlayWright Browser Toolkit](https://python.langchain.com/docs/integrations/tools/playwright/)
4848

4949
```shell
50-
$ poetry run playwright install
50+
$ uv run playwright install
5151

52-
$ poetry run python apps/13_langchain_toolkits/playwright_tool.py
52+
$ uv run python apps/13_langchain_toolkits/playwright_tool.py
5353
```
5454

5555
Sample output:

docs/apps/14_streamlit_azure_ai_speech.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ This app demonstrates how to use Azure AI Speech Service for realtime transcript
1212

1313
```shell
1414
# Speech to Text script
15-
poetry run python apps/14_streamlit_azure_ai_speech/speech_to_text.py --help
15+
uv run python apps/14_streamlit_azure_ai_speech/speech_to_text.py --help
1616

1717
# WIP: Streamlit app
18-
poetry run python -m streamlit run apps/14_streamlit_azure_ai_speech/main.py
18+
uv run python -m streamlit run apps/14_streamlit_azure_ai_speech/main.py
1919
```
2020

2121
# References

docs/apps/15_streamlit_chat_slm.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ $ ollama serve
1010
$ ollama pull phi3
1111

1212
# Run a simple chat with Ollama
13-
$ poetry run python apps/15_streamlit_chat_slm/chat.py
13+
$ uv run python apps/15_streamlit_chat_slm/chat.py
1414

1515
# Run summarization with SLM
16-
$ poetry run python apps/15_streamlit_chat_slm/summarize.py
16+
$ uv run python apps/15_streamlit_chat_slm/summarize.py
1717

1818
# Run streamlit app
19-
$ poetry run python -m streamlit run apps/15_streamlit_chat_slm/main.py
19+
$ uv run python -m streamlit run apps/15_streamlit_chat_slm/main.py
2020

2121
# List models
2222
$ ollama list
@@ -34,7 +34,7 @@ phi4:latest ac896e5b8b34 9.1 GB 55 minutes ago
3434
$ ollama pull phi3
3535

3636
# Measure time to run the chat
37-
$ time poetry run python apps/15_streamlit_chat_slm/chat.py \
37+
$ time uv run python apps/15_streamlit_chat_slm/chat.py \
3838
--model phi3 \
3939
--prompt "hello"
4040
{
@@ -68,7 +68,7 @@ $ time poetry run python apps/15_streamlit_chat_slm/chat.py \
6868
"total_tokens": 32
6969
}
7070
}
71-
poetry run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.57s user 0.16s system 68% cpu 2.515 total
71+
uv run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.57s user 0.16s system 68% cpu 2.515 total
7272
```
7373

7474
### Use Phi4 model
@@ -78,7 +78,7 @@ poetry run python apps/15_streamlit_chat_slm/chat.py --model phi3 --prompt 1.5
7878
$ ollama pull phi4
7979

8080
# Measure time to run the chat
81-
$ time poetry run python apps/15_streamlit_chat_slm/chat.py \
81+
$ time uv run python apps/15_streamlit_chat_slm/chat.py \
8282
--model phi4 \
8383
--prompt "hello"
8484
{
@@ -112,7 +112,7 @@ $ time poetry run python apps/15_streamlit_chat_slm/chat.py \
112112
"total_tokens": 51
113113
}
114114
}
115-
poetry run python apps/15_streamlit_chat_slm/chat.py --model phi4 --prompt 1.48s user 0.12s system 12% cpu 12.455 total
115+
uv run python apps/15_streamlit_chat_slm/chat.py --model phi4 --prompt 1.48s user 0.12s system 12% cpu 12.455 total
116116
```
117117

118118
Note:

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To run all the projects in this repository, you need the followings.
1414

1515
Here are the preferred tools for development.
1616

17-
- [Poetry](https://python-poetry.org/docs/#installation)
17+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
1818
- [GNU Make](https://www.gnu.org/software/make/)
1919

2020
## Setup

0 commit comments

Comments
 (0)