Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-ISSUE: chore(pyproject.toml): migrate from poetry to uv #917

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions .github/workflows/build-notebooks-TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ jobs:
TRIVY_VULNDB: "/home/runner/.local/share/containers/trivy_db"
# Targets (and their folder) that should be scanned using FS instead of IMAGE scan due to resource constraints
TRIVY_SCAN_FS_JSON: '{}'
# Poetry version for use in running tests
POETRY_VERSION: '2.0.0'

steps:

Expand Down Expand Up @@ -273,33 +271,26 @@ jobs:

# region Pytest image tests

- name: Install poetry
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
run: pipx install poetry==${{ env.POETRY_VERSION }}
env:
PIPX_HOME: /home/runner/.local/pipx
PIPX_BIN_DIR: /home/runner/.local/bin

- name: Check poetry is installed correctly
run: poetry env info

- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
# https://github.com/astral-sh/setup-uv
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
cache: 'poetry'
version: "latest"
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
pyproject-file: "pyproject.toml"

- name: Configure poetry
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
- name: Check uv is installed correctly
run: uv version

- name: Install deps
run: poetry install --sync
run: uv sync --locked

- name: Run Testcontainers container tests (in PyTest)
run: |
set -Eeuxo pipefail
poetry run pytest --capture=fd tests/containers -m 'not openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
uv run pytest --capture=fd tests/containers -m 'not openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
env:
DOCKER_HOST: "unix:///var/run/podman/podman.sock"
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/podman/podman.sock"
Expand Down Expand Up @@ -469,7 +460,7 @@ jobs:
if: ${{ steps.have-tests.outputs.tests == 'true' }}
run: |
set -Eeuxo pipefail
poetry run pytest --capture=fd tests/containers -m 'openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
uv run pytest --capture=fd tests/containers -m 'openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
env:
# TODO(jdanek): this Testcontainers stuff should not be necessary but currently it has to be there
DOCKER_HOST: "unix:///var/run/podman/podman.sock"
Expand Down
47 changes: 12 additions & 35 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,26 @@ jobs:

pytest-tests:
runs-on: ubuntu-latest
env:
poetry_version: '1.8.3'
steps:
- uses: actions/checkout@v4

- name: Cache poetry in ~/.local
uses: actions/cache/restore@v4
id: cache-poetry-restore
# https://github.com/astral-sh/setup-uv
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
path: ~/.local
key: "${{ runner.os }}-local-${{ env.poetry_version }}"

- name: Install poetry
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
run: pipx install poetry==${{ env.poetry_version }}
env:
PIPX_HOME: /home/runner/.local/pipx
PIPX_BIN_DIR: /home/runner/.local/bin

- name: Check poetry is installed correctly
run: poetry env info

- name: Save cache
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.local
key: ${{ steps.cache-poetry-restore.outputs.cache-primary-key }}

- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'poetry'
version: "latest"
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
pyproject-file: "pyproject.toml"

- name: Configure poetry
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
- name: Check uv is installed correctly
run: uv version

- name: Install deps
run: poetry install --sync
run: uv sync --locked

- run: poetry run pytest
- run: uv run pytest

code-static-analysis:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,24 @@ Note: To ensure the GitHub Action runs successfully, users must add a `GH_ACCESS

### Deploy & Test

#### Prepare Python + poetry + pytest env
#### Prepare Python + uv + pytest env

```shell
# Linux
sudo dnf install python3.12
pip install --user poetry
pip install --user uv
# MacOS
brew install [email protected] poetry
brew install [email protected] uv

poetry env use $(which python3.12)
poetry config virtualenvs.in-project true
poetry env info
poetry install --sync
uv venv --python $(which python3.12)
uv sync --locked
```

#### Running Python selftests in Pytest
By completing configuration in previous section, you are able to run any tests that don't need to start a container using following command:

```
poetry run pytest
uv run pytest
```

##### Container selftests
Expand All @@ -105,15 +103,15 @@ sudo dnf install podman
systemctl --user start podman.service
systemctl --user status podman.service
systemctl --user status podman.socket
DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock poetry run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock uv run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4

# Mac OS
brew install podman
podman machine init
podman machine set --rootful=false
sudo podman-mac-helper install
podman machine start
poetry run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
uv run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
```

When using lima on macOS, it might be useful to give yourself access to rootful podman socket
Expand Down
Loading