Skip to content

Commit 48d8daa

Browse files
committed
[chg] Switch to uv
1 parent 091325e commit 48d8daa

25 files changed

+3085
-5131
lines changed

.gitlab-ci.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,59 +55,61 @@ test:lint-and-test:
5555
- echo -e "${TXT_HEAD}Prepare docker containers${TXT_CLEAR}"
5656
- $DOCKER_COMPOSE up --detach --wait --wait-timeout 120
5757

58+
- $DOCKER_COMPOSE exec opsiserver43-dev ping -c1 opsiserver43-cs
59+
5860
- echo -e "${TXT_HEAD}Run linters${TXT_CLEAR}"
59-
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run ruff check opsiconfd tests perftest
60-
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run mypy opsiconfd tests perftest
61+
- $DOCKER_COMPOSE exec opsiserver43-dev uv run ruff check opsiconfd tests perftest
62+
- $DOCKER_COMPOSE exec opsiserver43-dev uv run mypy opsiconfd tests perftest
6163

6264
- echo -e "${TXT_HEAD}Run pytest${TXT_CLEAR}"
63-
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run pytest -x --tb=short -o junit_family=xunit2 --junitxml=testreport.xml --cov-append --cov opsiconfd --cov-report term --cov-report xml -v tests
65+
- $DOCKER_COMPOSE exec opsiserver43-dev uv run pytest -x --tb=short -o junit_family=xunit2 --junitxml=testreport.xml --cov-append --cov opsiconfd --cov-report term --cov-report xml -v tests
6466

6567
- echo -e "${TXT_HEAD}Run perftests${TXT_CLEAR}"
66-
- $DOCKER_COMPOSE exec opsiserver43-dev poetry run opsiconfd -c tests/data/default-opsiconfd.conf --workers=1 --log-level-file=5 --log-file=opsiconfd-perftest.log --max-session-per-ip=20000 &
68+
- $DOCKER_COMPOSE exec opsiserver43-dev uv run opsiconfd -c tests/data/default-opsiconfd.conf --workers=1 --log-level-file=5 --log-file=opsiconfd-perftest.log --max-session-per-ip=20000 &
6769
- sleep 10
6870

6971
- echo -e "${TXT_HEAD}Run opsiconfd-perftest${TXT_CLEAR}"
7072
# Average request time has to be faster than 10 ms
7173
- |
72-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/opsiconfd-perftest.py -l perftest/tests/test_session_loading.json --max-errors 0 --max-avg-seconds-per-request 0.01 --bencher-results bencher-results.json || (
74+
$DOCKER_COMPOSE exec opsiserver43-dev uv run ./perftest/opsiconfd-perftest.py -l perftest/tests/test_session_loading.json --max-errors 0 --max-avg-seconds-per-request 0.01 --bencher-results bencher-results.json || (
7375
echo -e "${TXT_ERROR}opsiconfd-perftest.py failed${TXT_CLEAR}"
7476
cat opsiconfd-perftest.log
7577
exit 1
7678
)
7779
7880
- echo -e "${TXT_HEAD}Run opsiconfd-backend-perftest${TXT_CLEAR}"
7981
- |
80-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/opsiconfd-backend-perftest.py --products 100 --clients 100 --iterations 5 --max-real 30000 || (
82+
$DOCKER_COMPOSE exec opsiserver43-dev uv run ./perftest/opsiconfd-backend-perftest.py --products 100 --clients 100 --iterations 5 --max-real 30000 || (
8183
echo -e "${TXT_ERROR}opsiconfd-backend-perftest.py failed${TXT_CLEAR}"
8284
cat opsiconfd-perftest.log
8385
exit 1
8486
)
8587
8688
- echo -e "${TXT_HEAD}Run file-download memory test${TXT_CLEAR}"
8789
- |
88-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run python ./perftest/file-download.py --clients=5 --file-size=500 --min-download-time=20 --memory-usage-limit 20 || (
90+
$DOCKER_COMPOSE exec opsiserver43-dev uv run python ./perftest/file-download.py --clients=5 --file-size=500 --min-download-time=20 --memory-usage-limit 20 || (
8991
echo -e "${TXT_ERROR}file-download.py failed${TXT_CLEAR}"
9092
cat opsiconfd-perftest.log
9193
exit 1
9294
)
9395
- |
94-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run python ./perftest/file-download.py --clients=10 --file-size=200 --min-download-time=20 --memory-usage-limit 20 --range-requests || (
96+
$DOCKER_COMPOSE exec opsiserver43-dev uv run python ./perftest/file-download.py --clients=10 --file-size=200 --min-download-time=20 --memory-usage-limit 20 --range-requests || (
9597
echo -e "${TXT_ERROR}file-download.py failed (range-requests)${TXT_CLEAR}"
9698
cat opsiconfd-perftest.log
9799
exit 1
98100
)
99101
100102
- echo -e "${TXT_HEAD}Run messagebus websocket load test${TXT_CLEAR}"
101103
- |
102-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/messagebus-clients.py --clients 1000 --event-interval 30 --start-gap 20 || (
104+
$DOCKER_COMPOSE exec opsiserver43-dev uv run ./perftest/messagebus-clients.py --clients 1000 --event-interval 30 --start-gap 20 || (
103105
echo -e "${TXT_ERROR}messagebus-clients.py failed${TXT_CLEAR}"
104106
cat opsiconfd-perftest.log
105107
exit 1
106108
)
107109
108110
- echo -e "${TXT_HEAD}Run opsiconfd get-config duration test${TXT_CLEAR}"
109111
- |
110-
$DOCKER_COMPOSE exec opsiserver43-dev poetry run ./perftest/bencher-command.py -r bencher-results.json -m opsiconfd-get-config-duration -x 1.0 -i 6 poetry run opsiconfd get-config || (
112+
$DOCKER_COMPOSE exec opsiserver43-dev uv run ./perftest/bencher-command.py -r bencher-results.json -m opsiconfd-get-config-duration -x 1.0 -i 6 uv run opsiconfd get-config || (
111113
echo -e "${TXT_ERROR}bencher-command.py failed${TXT_CLEAR}"
112114
exit 1
113115
)
@@ -130,11 +132,14 @@ build:linux-pyinstaller:
130132
tags:
131133
- linux-docker-x64-hetzner
132134
script:
135+
- export UV_PYTHON_PREFERENCE="only-managed"
136+
- export UV_PYTHON="3.13"
133137
- TRANSIFEX_MIN_REVIEW_RATE=0.0
134138
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
135139
- opsi-dev-cli self upgrade
136-
- poetry install
137-
- poetry run opsi-dev-cli -l debug pyinstaller build
140+
- rm -rf .venv
141+
- uv sync --frozen
142+
- uv run opsi-dev-cli -l debug pyinstaller build
138143
- mv opsiconfd opsiconfd.src
139144
- mv dist/opsiconfd ./opsiconfd-amd64
140145
# Check if binary is working
@@ -150,11 +155,14 @@ build:arm64-pyinstaller:
150155
tags:
151156
- linux-arm64
152157
script:
158+
- export UV_PYTHON_PREFERENCE="only-managed"
159+
- export UV_PYTHON="3.13"
153160
- TRANSIFEX_MIN_REVIEW_RATE=0.0
154161
- '[ "$CI_COMMIT_TAG" = "" ] || TRANSIFEX_MIN_REVIEW_RATE=1.0'
155162
- opsi-dev-cli self upgrade
156-
- poetry install
157-
- poetry run opsi-dev-cli -l debug pyinstaller build
163+
- rm -rf .venv
164+
- uv sync --frozen
165+
- uv run opsi-dev-cli -l debug pyinstaller build
158166
- mv opsiconfd opsiconfd.src
159167
- mv dist/opsiconfd ./opsiconfd-arm64
160168
# Check if binary is working

.vscode/tasks.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"label": "DB load sql file",
88
"type": "shell",
9-
"command": "cat ${input:sql-file} | sed 's/${input:sql-old-hostname}/'$OPSI_HOSTNAME'/g' | mariadb -h localhost -u $MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE",
9+
"command": "cat ${input:sql-file} | sed 's/${input:sql-old-hostname}/'$OPSI_HOSTNAME'/g' | mariadb -h localhost -u $MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE",
1010
"presentation": {
1111
"reveal": "always",
1212
"panel": "dedicated"
@@ -16,7 +16,7 @@
1616
{
1717
"label": "Redis clean",
1818
"type": "shell",
19-
"command": "poetry run python ${workspaceFolder}/scripts/clean-redis.py",
19+
"command": "uv run ${workspaceFolder}/scripts/clean-redis.py",
2020
"presentation": {
2121
"reveal": "always",
2222
"panel": "dedicated"
@@ -36,7 +36,7 @@
3636
{
3737
"label": "PyInstaller build",
3838
"type": "shell",
39-
"command": "sudo poetry run opsi-dev-cli -l debug pyinstaller build --skip-transifex",
39+
"command": "sudo uv run opsi-dev-cli -l debug pyinstaller build --skip-transifex",
4040
"presentation": {
4141
"reveal": "always",
4242
"panel": "dedicated"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Thus, long runinng JSON-RPC requests could block other requests.
2828
* You can use the default debug settings or you can set the number of worker and the log level by selecting opsiconfd in the debug/run tab.
2929

3030
## Run Tests
31-
* Select "Run Tests" on the Status Bar, use the Test Explorer or run `poetry run pytest --cov-append --cov opsiconfd --cov-report term --cov-report xml -vv tests` in a terminal
31+
* Select "Run Tests" on the Status Bar, use the Test Explorer or run `uv run pytest --cov-append --cov opsiconfd --cov-report term --cov-report xml -vv tests` in a terminal
3232

3333

3434
# Performance
@@ -42,7 +42,7 @@ Thus, long runinng JSON-RPC requests could block other requests.
4242

4343
### valgrind
4444
```
45-
PYTHONMALLOC=malloc sudo -E valgrind --tool=memcheck --trace-children=yes --dsymutil=yes --leak-check=full --show-leak-kinds=all --log-file=/tmp/valgrind-out poetry run opsiconfd --workers=1 --log-level-stderr=5
45+
PYTHONMALLOC=malloc sudo -E valgrind --tool=memcheck --trace-children=yes --dsymutil=yes --leak-check=full --show-leak-kinds=all --log-file=/tmp/valgrind-out uv run opsiconfd --workers=1 --log-level-stderr=5
4646
```
4747
* PYTHONMALLOC=debug
4848
* PYTHONMALLOC=malloc_debug

docker/opsiconfd-dev/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ RUN apt-get update \
3232
&& git clone https://github.com/zsh-users/zsh-autosuggestions /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
3333
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /root/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
3434
&& git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /root/.oh-my-zsh/custom/themes/powerlevel10k \
35-
&& usermod -s /bin/zsh root
35+
&& usermod -s /bin/zsh root \
36+
&& sed -i 's#secure_path=.*#secure_path=/root/.local/bin:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin#' /etc/sudoers
3637

3738
COPY files/ /
3839

docker/opsiconfd-dev/common.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ GF_INSTALL_PLUGINS=simpod-json-datasource
1717
GF_SERVER_ROOT_URL="%(protocol)s://%(domain)s:%(http_port)s/grafana"
1818

1919
OPSI_ADMIN_PASSWORD=adminuser
20+
21+
UV_PYTHON_PREFERENCE=only-managed
22+
UV_PYTHON=3.13

docker/opsiconfd-dev/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ services:
9696
env_file:
9797
- .env
9898
- opsiserver43-cs.env
99-
command: poetry run opsiconfd
99+
command: uv run opsiconfd
100100

101101
mysql-cs:
102102
image: mariadb:10.7

docker/opsiconfd-dev/files/entrypoint.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ if [ -d $OPSICONFD_BASE_DIR ]; then
5555
stat $state_file || true
5656

5757
if [ "$state" = "ready" ]; then
58-
echo "* opsiconfd poetry venv is ready"
58+
echo "* opsiconfd venv is ready"
5959
echo "release state lock: $state_lock ($(date +"%Y-%m-%d %H:%M:%S.%N"))"
6060
rmdir "$state_lock"
6161
elif [ "$state" = "setup" ]; then
6262
echo "release state lock: $state_lock ($(date +"%Y-%m-%d %H:%M:%S.%N"))"
6363
rmdir "$state_lock"
64-
echo "* Waiting until opsiconfd poetry venv is set up"
64+
echo "* Waiting until opsiconfd venv is set up"
6565
start_time=$(date +%s)
6666
i=1
6767
while [ "$i" -le 60 ]; do
@@ -78,20 +78,21 @@ if [ -d $OPSICONFD_BASE_DIR ]; then
7878
echo "timed out waiting for venv after ${diff} seconds"
7979
fi
8080
else
81-
echo "* Setup opsiconfd poetry venv"
81+
echo "* Setup opsiconfd venv"
8282
echo -n "setup" > $state_file
8383
sleep 2
8484
echo "release state lock: $state_lock ($(date +"%Y-%m-%d %H:%M:%S.%N"))"
8585
rmdir "$state_lock"
8686
cd $OPSICONFD_BASE_DIR
87-
poetry lock --no-update
88-
poetry install --no-interaction --no-ansi
87+
uv sync --frozen
8988
[ -n "$DEV_USER" ] && chown -R $DEV_USER $OPSICONFD_BASE_DIR
9089
echo -n "ready" > $state_file
9190
echo "venv created"
9291
fi
9392
fi
9493

9594
touch /run/.docker-healthy
95+
9696
# Run CMD
97+
echo "Running: $@"
9798
exec "$@"
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
: 1700000000:0;git commit -av
22
: 1700000000:0;git push -o ci.skip
3-
: 1700000000:0;sudo -E poetry run pytest --tb=short -x -o junit_family=xunit2 --junitxml=testreport.xml --cov-append --cov opsiconfd --cov-report term --cov-report xml -v tests
4-
: 1700000000:0;sudo -E poetry run pytest --tb=short -x -vv -s tests/test_config.py -k test_cmdline
5-
: 1700000000:0;sudo -E poetry run pytest --tb=short -x -vv -s tests
6-
: 1700000000:0;sudo -E poetry run opsiconfd restore --no-hw-audit --server-id local opsiconfd-backup.msgpack.lz4
7-
: 1700000000:0;sudo -E poetry run opsiconfd --config-file tests/data/default-opsiconfd.conf --log-level-stderr=5 --max-session-per-ip=20000
8-
: 1700000000:0;sudo -E poetry run opsiconfd --zeroconf=false --workers=1 --log-level-stderr=5
3+
: 1700000000:0;sudo -E uv run pytest --tb=short -x -o junit_family=xunit2 --junitxml=testreport.xml --cov-append --cov opsiconfd --cov-report term --cov-report xml -v tests
4+
: 1700000000:0;sudo -E uv run pytest --tb=short -x -vv -s tests/test_config.py -k test_cmdline
5+
: 1700000000:0;sudo -E uv run pytest --tb=short -x -vv -s tests
6+
: 1700000000:0;sudo -E uv run opsiconfd restore --no-hw-audit --server-id local opsiconfd-backup.msgpack.lz4
7+
: 1700000000:0;sudo -E uv run opsiconfd --config-file tests/data/default-opsiconfd.conf --log-level-stderr=5 --max-session-per-ip=20000
8+
: 1700000000:0;sudo -E uv run opsiconfd --zeroconf=false --workers=1 --log-level-stderr=5

opsi-dev-tool.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ git:
1111
hooks:
1212
pre-push: |
1313
echo "Running ruff..."
14-
poetry run ruff check opsiconfd tests perftest
14+
uv run ruff check opsiconfd tests perftest
1515
echo "Running mypy..."
16-
poetry run mypy opsiconfd tests perftest
16+
uv run mypy opsiconfd tests perftest
1717
1818
transifex:
1919
upload_resources:
@@ -34,20 +34,17 @@ transifex:
3434
pyinstaller:
3535
one_file: no
3636
strip: yes
37+
# TODO: opsi-dev-cli 1.30.0 supports collect_all
38+
extra_args:
39+
- --collect-all
40+
- opsiconfd_data
3741
hidden_imports:
3842
all:
3943
- ipaddress
4044
- colorsys
41-
# UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''.
42-
# Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied.
43-
# Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification.
44-
# Many valid certificate/hostname mappings may be rejected.
45-
- service_identity
4645
- OPSI.Util.WIM
47-
- opsiconfd.application.utils
48-
- opsiconfd.rest
49-
- opsiconfd.utils.fastapi
5046
collect_submodules:
47+
- opsiconfd
5148
- pydantic_core
5249
- pydantic
5350
- uvicorn
@@ -58,12 +55,9 @@ pyinstaller:
5855
- websockets
5956
- wsproto
6057
scripts:
61-
- script: opsiconfd/__main__.py
58+
- script: run-opsiconfd
6259
binaries:
6360
- opsiconfd
64-
data_files:
65-
- src: opsiconfd_data/**/*
66-
dst: opsiconfd_data
6761
dirname: opsiconfd
6862
after_script: |
6963
find dist/opsiconfd/_internal -iname "*.c" -delete

opsiconfd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from __future__ import annotations
1313

14-
__version__ = "4.3.26.0"
14+
__version__ = "4.3.29.16"
1515

1616

1717
from contextlib import contextmanager

0 commit comments

Comments
 (0)