Skip to content

Commit 846d939

Browse files
authored
Replace Poetry with UV (#1199)
* replace poetry with uv * use uv for tests * install wheel for python 3.12 installations * resolved several versioning issues for unit tests * bump vcrpy to version 6.x * CI * CI * CI * formatting * CI * update CI nightly tests * CI * CI * CI * convert cluster_tools to UV * update cluster tools docker file with uv * uv in "docs" sub project * update changelog * remove poetry lock files * cleanup * re-add typing-extensions to cluster_tools * CI * updated slurm docker image tag * CI * CI * CI * CI * CI * CI * Ci * Apply PR feedback
1 parent 3b07223 commit 846d939

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6271
-7571
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
webknossos/testdata
22
webknossos/testoutput
3+
.venv

.github/workflows/ci.yml

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ jobs:
4444
working-directory: cluster_tools
4545
steps:
4646
- uses: actions/checkout@v3
47-
- name: Set up Python ${{ matrix.python-version }}
48-
uses: actions/setup-python@v4
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v3
4949
with:
50-
python-version: ${{ matrix.python-version }}
51-
architecture: "x64"
50+
version: "0.4.19"
51+
52+
- name: Set up Python ${{ matrix.python-version }}
53+
run: uv python install ${{ matrix.python-version }}
5254
- name: Build/pull dockered-slurm image
5355
if: ${{ matrix.executors == 'slurm' }}
5456
run: |
@@ -70,9 +72,9 @@ jobs:
7072
docker logs c2
7173
7274
# Run setup.py on all three nodes
73-
docker exec -w /cluster_tools slurmctld bash -c "poetry install" &
74-
docker exec -w /cluster_tools c1 bash -c "poetry install" &
75-
docker exec -w /cluster_tools c2 bash -c "poetry install" &
75+
docker exec -w /cluster_tools slurmctld bash -c "uv sync --frozen" &
76+
docker exec -w /cluster_tools c1 bash -c "uv sync --frozen" &
77+
docker exec -w /cluster_tools c2 bash -c "uv sync --frozen" &
7678
wait
7779
7880
- name: Setup Kubernetes-in-Docker
@@ -84,21 +86,18 @@ jobs:
8486
./kind create cluster --config=tests/cluster-config.yaml
8587
./kind export kubeconfig
8688
87-
cp ../requirements.txt .
8889
docker build -f tests/Dockerfile -t scalableminds/cluster-tools:latest .
8990
./kind load docker-image scalableminds/cluster-tools:latest
9091
9192
- name: Install dependencies (without docker)
9293
if: ${{ matrix.executors == 'multiprocessing' }}
9394
run: |
94-
pip install -r ../requirements.txt
95-
poetry install
95+
uv sync --frozen
9696
9797
- name: Install dependencies (without docker)
9898
if: ${{ matrix.executors == 'kubernetes' || matrix.executors == 'dask' }}
9999
run: |
100-
pip install -r ../requirements.txt
101-
poetry install --all-extras
100+
uv sync --all-extras --frozen
102101
103102
- name: Check typing
104103
if: ${{ matrix.executors == 'multiprocessing' && matrix.python-version == '3.11' }}
@@ -117,7 +116,7 @@ jobs:
117116
run: |
118117
cd tests
119118
PYTEST_EXECUTORS=multiprocessing,sequential,test_pickling,debug_sequential \
120-
poetry run python -m pytest -sv test_all.py test_multiprocessing.py
119+
uv run --frozen python -m pytest -sv test_all.py test_multiprocessing.py
121120
122121
- name: Run slurm tests
123122
if: ${{ matrix.executors == 'slurm' }}
@@ -126,22 +125,22 @@ jobs:
126125
docker exec \
127126
-w /cluster_tools/tests \
128127
-e PYTEST_EXECUTORS=slurm \
129-
slurmctld bash -c "poetry run python -m pytest -sv test_all.py test_slurm.py"
128+
slurmctld bash -c "uv run --frozen python -m pytest -sv test_all.py test_slurm.py"
130129
docker exec \
131130
-w /cluster_tools/tests \
132-
slurmctld bash -c "poetry run python test_deref_main.py"
131+
slurmctld bash -c "uv run --frozen python test_deref_main.py"
133132
134133
- name: Run kubernetes tests
135134
if: ${{ matrix.executors == 'kubernetes' }}
136135
run: |
137136
cd tests
138-
PYTEST_EXECUTORS=kubernetes poetry run python -m pytest -sv test_all.py test_kubernetes.py
137+
PYTEST_EXECUTORS=kubernetes uv run --frozen python -m pytest -sv test_all.py test_kubernetes.py
139138
140139
- name: Run dask tests
141140
if: ${{ matrix.executors == 'dask' }}
142141
run: |
143142
cd tests
144-
PYTEST_EXECUTORS=dask poetry run python -m pytest -sv test_all.py test_dask.py
143+
PYTEST_EXECUTORS=dask uv run --frozen python -m pytest -sv test_all.py test_dask.py
145144
146145
webknossos_linux:
147146
needs: changes
@@ -161,17 +160,16 @@ jobs:
161160

162161
steps:
163162
- uses: actions/checkout@v3
164-
- name: Set up Python ${{ matrix.python-version }}
165-
uses: actions/setup-python@v4
166-
with:
167-
python-version: ${{ matrix.python-version }}
168-
architecture: "x64"
169-
170-
- name: Install dependencies
171-
run: |
172-
pip install -r ../requirements.txt
173-
poetry install --extras all --with examples --with dev
174163

164+
- name: Install uv
165+
uses: astral-sh/setup-uv@v3
166+
with:
167+
# Install a specific version of uv.
168+
version: "0.4.19"
169+
170+
- name: Set up Python ${{ matrix.python-version }}
171+
run: uv python install ${{ matrix.python-version }}
172+
175173
- name: Check formatting
176174
if: ${{ matrix.group == 1 && matrix.python-version == '3.11' }}
177175
run: ./format.sh check
@@ -192,7 +190,7 @@ jobs:
192190

193191
- name: Check if git is dirty
194192
run: |
195-
git diff --no-ext-diff --quiet --exit-code
193+
git diff --no-ext-diff --exit-code
196194
[[ -z $(git status -s) ]]
197195
198196
webknossos_cli_docker:
@@ -205,21 +203,20 @@ jobs:
205203
runs-on: ubuntu-latest
206204
steps:
207205
- uses: actions/checkout@v3
208-
- name: Set up Python
209-
uses: actions/setup-python@v4
206+
- name: Install uv
207+
uses: astral-sh/setup-uv@v3
210208
with:
211-
python-version: "3.10"
212-
209+
# Install a specific version of uv.
210+
version: "0.4.19"
213211
- name: Write version file
214212
run: |
215-
pip install -r requirements.txt
216213
pushd webknossos
217214
218-
PKG_VERSION="$(dunamai from git)"
215+
PKG_VERSION="$(uvx dunamai from git)"
219216
echo "__version__ = '$PKG_VERSION'" > ./webknossos/version.py
220-
poetry version "$PKG_VERSION"
217+
sed -i 's/version = "0.0.0"/version = "'"${PKG_VERSION}"'"/g' pyproject.toml
221218
222-
popd
219+
popd
223220
224221
- name: Build docker image
225222
run: docker build -t scalableminds/webknossos-cli:$GITHUB_SHA -f webknossos/Dockerfile .
@@ -283,16 +280,11 @@ jobs:
283280
with:
284281
repository: scalableminds/webknossos
285282
path: docs/wk-repo
286-
- name: Set up Python 3.8
287-
uses: actions/setup-python@v4
283+
- name: Install uv
284+
uses: astral-sh/setup-uv@v3
288285
with:
289-
python-version: 3.8
290-
architecture: "x64"
291-
292-
- name: Install dependencies
293-
run: |
294-
pip3 install -r requirements.txt
295-
286+
# Install a specific version of uv.
287+
version: "0.4.19"
296288
- name: Build Docs
297289
run: |
298290
cd docs
@@ -325,7 +317,7 @@ jobs:
325317
SLACK_HOOK: ${{ secrets.LINK_CHECKER_SLACK_HOOK }}
326318
run: |
327319
cd docs
328-
poetry run linkchecker --config linkcheckerrc https://docs.webknossos.org > link_status || \
320+
uv run --frozen linkchecker --config linkcheckerrc https://docs.webknossos.org > link_status || \
329321
curl -X POST --data-urlencode "payload={\"text\": \":warning: Broken Links on doc.webknossos.org :warning:\n"'```'"\n$(cat link_status)\n"'```"}' \
330322
"$SLACK_HOOK"
331323
@@ -340,20 +332,18 @@ jobs:
340332
runs-on: ubuntu-latest
341333
steps:
342334
- uses: actions/checkout@v3
343-
- name: Set up Python 3.8
344-
uses: actions/setup-python@v4
335+
- name: Install uv
336+
uses: astral-sh/setup-uv@v3
345337
with:
346-
python-version: 3.8
347-
architecture: "x64"
348-
- name: Install dependencies
349-
run: pip3 install -r requirements.txt
338+
# Install a specific version of uv.
339+
version: "0.4.19"
350340
- name: Publish python packages
351341
env:
352-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PASSWORD }}
342+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_PASSWORD }}
353343
run: _tooling/publish.sh
354344
- name: Prepare github release
355345
run: |
356-
VERSION="$(dunamai from git)"
346+
VERSION="$(uvx dunamai from git)"
357347
_tooling/changelog_for_version.sh $VERSION > Changelog.md
358348
- name: Publish github release
359349
id: create_release

.github/workflows/nightly.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v3
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
2526
with:
26-
python-version: ${{ matrix.python-version }}
27-
architecture: 'x64'
28-
29-
- name: Install dependencies
30-
run: |
31-
pip install poetry
32-
poetry install --extras all --with examples --with dev
27+
version: "0.4.19"
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
run: uv python install ${{ matrix.python-version }}
3331

3432
- name: Check if git is dirty
3533
run: |

.github/workflows/publish_docs.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ jobs:
1515
with:
1616
repository: scalableminds/webknossos
1717
path: docs/wk-repo
18-
- name: Set up Python 3.10
19-
uses: actions/setup-python@v1
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
2020
with:
21-
python-version: "3.10"
22-
architecture: 'x64'
23-
24-
- name: Install dependencies
25-
run: |
26-
pip install -r requirements.txt
21+
# Install a specific version of uv.
22+
version: "0.4.19"
2723

2824
- name: Build Docs
2925
run: |
@@ -45,6 +41,6 @@ jobs:
4541
SLACK_HOOK: ${{ secrets.LINK_CHECKER_SLACK_HOOK }}
4642
run: |
4743
cd docs
48-
poetry run linkchecker --config linkcheckerrc https://docs.webknossos.org > link_status || \
44+
uv run --frozen linkchecker --config linkcheckerrc https://docs.webknossos.org > link_status || \
4945
curl -X POST --data-urlencode "payload={\"text\": \":warning: Broken Links on doc.webknossos.org :warning:\n"'```'"\n$(cat link_status)\n"'```"}' \
5046
"$SLACK_HOOK"

CONTRIBUTING.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,11 @@ The [WEBKNOSSOS-libs repository](https://github.com/scalableminds/webknossos-lib
102102

103103
See below for specifics of the different packages. Let's have a look at the common tooling first:
104104

105-
* [**poetry**](https://python-poetry.org) is used for dependency management and publishing.
106-
Use `poetry install --all-extras` in each package folder to install all dependencies for development.
105+
* [**uv**](https://docs.astral.sh/uv) is used for dependency management and publishing.
106+
Use `uv sync --all-extras` in each package folder to install all dependencies for development.
107107
By default, this creates a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for each package.
108-
To run commands inside this package, prefix them with `poetry run`, e.g. `poetry run python myscript.py`,
109-
or enter the virtual environment with `poetry shell`.
110-
The creation of a separate environment can be disabled (e.g. if you want to manage this manually),
111-
[see here for details](https://python-poetry.org/docs/configuration/#virtualenvscreate).
112-
To install the preferred version for this repository, run
113-
[`pip install -f requirements.txt`](https://github.com/scalableminds/webknossos-libs/blob/master/requirements.txt)
108+
To run commands inside this package, prefix them with `uv run`, e.g. `uv run python myscript.py`,
109+
or enter the virtual environment with `source .venv/bin/activate`.
114110

115111
To install the dependencies for all sub-projects, run `make install`.
116112

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@ endef
1515
list_packages_by_priority:
1616
@echo $(packages_by_priority)
1717

18-
update:
19-
$(call in_each_pkg_by_dependency, poetry update --without dev)
20-
21-
update-internal:
22-
$(call in_each_pkg_by_dependency, poetry update $(packages_by_dependency))
23-
2418
install:
25-
$(call in_each_pkg_by_dependency, poetry install --all-extras)
19+
$(call in_each_pkg_by_dependency, uv sync --all-extras)
2620

2721
format:
2822
$(call in_each_code_pkg, ./format.sh)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/webknossos.svg)](https://pypi.python.org/pypi/webknossos)
44
[![Build Status](https://img.shields.io/github/actions/workflow/status/scalableminds/webknossos-libs/.github/workflows/ci.yml?branch=master)](https://github.com/scalableminds/webknossos-libs/actions?query=workflow%3A%22CI%22)
55
[![Documentation](https://img.shields.io/badge/docs-passing-brightgreen.svg)](https://docs.webknossos.org/webknossos-py/index.html)
6+
[![Package Manager](https://img.shields.io/pypi/pyversions/uv.svg)](https://pypi.python.org/pypi/uv)
67
[![Code Style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/)
78

89
<img align="right" src="https://static.webknossos.org/logos/webknossos-icon-only.svg" alt="WEBKNOSSOS Logo" width="100" height="100"/>

_tooling/publish.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ for PKG in {cluster_tools,webknossos}/pyproject.toml; do
99
pushd "$PKG" > /dev/null
1010

1111
cp pyproject.toml pyproject.toml.bak
12-
PKG_VERSION="$(dunamai from git)"
12+
PKG_VERSION="$(uvx dunamai from git)"
1313

1414
echo "__version__ = '$PKG_VERSION'" > ./"$PKG"/version.py
1515

16-
poetry version "$PKG_VERSION"
17-
# replace all relative path dependencies with the current version:
18-
sed -i 's/\(.*\) = .* path \= \"\.\..*/\1 = "'"$PKG_VERSION"'"/g' pyproject.toml
19-
poetry publish --build
16+
# Update version number in pyproject.toml
17+
sed -i 's/version = "0.0.0"/version = "'"${PKG_VERSION}"'"/g' pyproject.toml
18+
19+
# replace relative path dependencies (i.e. cluster-tools) with the current version:
20+
sed -i 's/"cluster-tools"/"cluster-tools=='"${PKG_VERSION}"'"/g' pyproject.toml
21+
22+
uv build
23+
uv publish
2024

2125
# Restore files
2226
mv pyproject.toml.bak pyproject.toml

cluster_tools/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1414
### Added
1515

1616
### Changed
17+
- Replaced the Python package manager `poetry` with `uv`. [#1199](https://github.com/scalableminds/webknossos-libs/pull/1199)
1718

1819
### Fixed
1920

cluster_tools/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ docker exec -it slurmctld bash
8181
docker exec -it c1 bash
8282
```
8383

84-
Make sure to install all extra dependencies, such as Kubernetes, with `poetry install --all-extras`.
84+
Make sure to install all extra dependencies, such as Kubernetes, with `uv sync --all-extras`.
8585

86-
Tests can be executed with `cd tests && poetry run pytest -s tests.py` after entering the container.
86+
Tests can be executed with `cd tests && uv run pytest -s tests.py` after entering the container.
8787
Linting can be run with `./lint.sh`.
8888
Code formatting (black) can be run with `./format.sh`.
8989

0 commit comments

Comments
 (0)