Skip to content

Commit 7147687

Browse files
authored
Build with uv (#366)
1 parent 1ed9ec5 commit 7147687

13 files changed

Lines changed: 3773 additions & 92 deletions

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ jobs:
2020
- name: Set up Python
2121
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2222
with:
23-
python-version: "3.10"
23+
python-version-file: ".python-version"
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
2426
- name: Install dependencies
25-
run: pip install 'src/.[docs]'
27+
run: |
28+
uv sync --locked --extra docs
2629
- name: Install and Generate Doxygen
2730
uses: mattnotmitt/doxygen-action@b84fe17600245bb5db3d6c247cc274ea98c15a3b # v1.12.0
2831
- name: Build Docs

.github/workflows/pre_commit.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ jobs:
2424
- name: Set up Python
2525
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2626
with:
27-
python-version: "3.10"
27+
python-version-file: ".python-version"
2828
- name: Set up Node.js
2929
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3030
with:
3131
node-version: 22
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
3234
- name: Install dependencies
33-
run: pip install 'src/.[full]'
35+
run: |
36+
uv sync --locked --all-extras
3437
- name: Run pre-commit checks
35-
run: pre-commit run --all-files
38+
run: |
39+
uv run pre-commit run --all-files
3640
Unit-Tests:
3741
runs-on: ubuntu-22.04
3842
steps:
@@ -43,11 +47,15 @@ jobs:
4347
- name: Set up Python
4448
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
4549
with:
46-
python-version: "3.10"
50+
python-version-file: ".python-version"
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
4753
- name: Install dependencies
48-
run: pip install 'src/.[tests,ovms]'
54+
run: |
55+
uv sync --locked --extra tests --extra ovms
4956
- name: Run python unit tests
50-
run: pytest tests/unit
57+
run: |
58+
uv run pytest tests/unit
5159
Zizmor-Scan-PR:
5260
runs-on: ubuntu-latest
5361
permissions:
@@ -79,5 +87,5 @@ jobs:
7987
scan-scope: "changed"
8088
severity-level: "LOW"
8189
confidence-level: "LOW"
82-
config_file: "src/pyproject.toml"
90+
config_file: "./pyproject.toml"
8391
fail-on-findings: true

.github/workflows/publish.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ jobs:
1616
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1717
with:
1818
persist-credentials: false
19-
- name: Set up Python 3.10
19+
- name: Set up Python
2020
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2121
with:
22-
python-version: "3.10"
22+
python-version-file: ".python-version"
2323
- name: Install pypa/build
2424
run: |
25-
python -m pip install --upgrade build
25+
uv sync --locked
2626
- name: Build sdist
2727
run: |
28-
python -m build --sdist src/
28+
uv build --sdist
2929
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3030
with:
3131
name: artifact-sdist
32-
path: src/dist/*.tar.gz
32+
path: dist/*.tar.gz
3333
- name: Build wheel
3434
run: |
35-
python -m build --wheel src/
35+
uv build --wheel
3636
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3737
with:
3838
name: artifact-wheel
39-
path: src/dist/*.whl
39+
path: dist/*.whl
4040

4141
publish_package:
4242
name: Publish package

.github/workflows/security-scan.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
scan-scope: "all"
4848
severity-level: "LOW"
4949
confidence-level: "LOW"
50-
config_file: "src/pyproject.toml"
50+
config_file: "pyproject.toml"
5151
fail-on-findings: false # reports only
5252

5353
trivy-scan:
@@ -60,15 +60,6 @@ jobs:
6060
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6161
with:
6262
persist-credentials: false
63-
- name: Set up Python
64-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
65-
with:
66-
python-version: "3.10"
67-
- name: Install pip-tools
68-
run: python -m pip install pip-tools
69-
70-
- name: Freeze dependencies
71-
run: pip-compile --extra=full -o requirements.txt $(pwd)/src/pyproject.toml
7263

7364
- name: Run Trivy scan
7465
id: trivy

.github/workflows/test_accuracy.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,15 @@ jobs:
1717
persist-credentials: false
1818
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
1919
with:
20-
python-version: "3.12"
21-
cache: pip
22-
- name: Create and start a virtual environment
23-
run: |
24-
python -m venv venv
25-
source venv/bin/activate
20+
python-version-file: ".python-version"
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
2623
- name: Install dependencies
2724
run: |
28-
source venv/bin/activate
29-
python -m pip install --upgrade pip
30-
pip install src/[tests,build] --extra-index-url https://download.pytorch.org/whl/cpu
25+
uv sync --locked --extra tests --extra build --extra-index-url https://download.pytorch.org/whl/cpu
3126
- name: Prepare test data
3227
run: |
33-
source venv/bin/activate
34-
python tests/accuracy/prepare_data.py -d data
28+
uv run python tests/accuracy/prepare_data.py -d data
3529
- name: Run Python Test
3630
run: |
37-
source venv/bin/activate
38-
pytest -v --data=./data tests/accuracy/test_accuracy.py
31+
uv run pytest --data=./data tests/accuracy/test_accuracy.py

.github/workflows/test_precommit.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,18 @@ jobs:
1919
- name: Set up Python
2020
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2121
with:
22-
python-version: "3.10"
23-
cache: pip
24-
- name: Create and start a virtual environment
25-
run: |
26-
python -m venv venv
27-
source venv/bin/activate
22+
python-version-file: ".python-version"
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
2825
- name: Install dependencies
2926
run: |
30-
source venv/bin/activate
31-
python -m pip install --upgrade pip
32-
pip install src/[tests,ovms] --extra-index-url https://download.pytorch.org/whl/cpu
27+
uv sync --locked --extra tests --extra ovms --extra-index-url https://download.pytorch.org/whl/cpu
3328
- name: Prepare test data
3429
run: |
35-
source venv/bin/activate
36-
python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
30+
uv run python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
3731
- name: Run test
3832
run: |
39-
source venv/bin/activate
40-
pytest --data=./data tests/functional
33+
uv run pytest --data=./data tests/functional
4134
serving_api:
4235
strategy:
4336
fail-fast: false
@@ -57,12 +50,12 @@ jobs:
5750
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
5851
with:
5952
python-version: ${{ matrix.python-version }}
60-
cache: pip
53+
- name: Install uv
54+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
6155
- name: serving_api
6256
run: |
63-
python -m pip install --upgrade pip
64-
python -m pip install src/[ovms,tests]
65-
python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
66-
python -c "from model_api.models import DetectionModel; DetectionModel.create_model('./data/otx_models/detection_model_with_xai_head.xml').save('ovms_models/ssd_mobilenet_v1_fpn_coco/1/ssd_mobilenet_v1_fpn_coco.xml')"
57+
uv sync --locked --extra tests --extra ovms
58+
uv run python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
59+
uv run python -c "from model_api.models import DetectionModel; DetectionModel.create_model('./data/otx_models/detection_model_with_xai_head.xml').save('ovms_models/ssd_mobilenet_v1_fpn_coco/1/ssd_mobilenet_v1_fpn_coco.xml')"
6760
docker run -d --rm -v $GITHUB_WORKSPACE/ovms_models/:/models -p 8000:8000 openvino/model_server:latest --model_path /models/ssd_mobilenet_v1_fpn_coco/ --model_name ssd_mobilenet_v1_fpn_coco --rest_port 8000 --log_level DEBUG --target_device CPU
68-
python examples/serving_api/run.py data/coco128/images/train2017/000000000009.jpg # detects 4 objects
61+
uv run python examples/serving_api/run.py data/coco128/images/train2017/000000000009.jpg # detects 4 objects

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,6 @@ docs/source/_build/
143143

144144
# vs-code
145145
.vscode/
146+
147+
data/
148+
ovms_models/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ repos:
5555
args:
5656
[
5757
"-c",
58-
"src/pyproject.toml",
58+
"pyproject.toml",
5959
"--severity-level",
6060
"all",
6161
"--confidence-level",

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

CONTRIBUTING.md

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,12 @@ Set up your development environment to start contributing. This involves install
3535
<details>
3636
<summary>Development Environment Setup Instructions</summary>
3737

38-
1. Create and activate a new python environment:
38+
1. Create a new python environment and install the development requirements:
3939

4040
```bash
41-
python -m venv .mapi
42-
source .mapi/bin/activate
41+
uv sync --all-extras
4342
```
4443

45-
2. Install the development requirements:
46-
47-
```bash
48-
pip install -e ./src[full]
49-
```
50-
51-
3. [Build](https://github.com/open-edge-platform/model_api?tab=readme-ov-file#c) C++ binaries
52-
53-
Make sure to address any pre-commit issues before finalizing your pull request.
54-
Pre-commit checks can be launched by the command:
55-
56-
```bash
57-
pre-commit run --all-files
58-
```
59-
6044
</details>
6145

6246
### Making Changes
@@ -70,12 +54,12 @@ pre-commit run --all-files
7054
4. **Pass Tests and Quality Checks:** Ensure the test suite passes and that your code meets quality standards by running:
7155

7256
```bash
73-
pre-commit run --all-files
74-
pytest tests/unit
75-
python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
76-
pytest --data=./data tests/functional
77-
python tests/accuracy/prepare_data.py -d data
78-
pytest --data=./data tests/functional
57+
uv run pre-commit run --all-files
58+
uv run pytest tests/unit
59+
uv run python tests/precommit/prepare_data.py -d data -p tests/precommit/public_scope.json
60+
uv run pytest --data=./data tests/functional
61+
uv run python tests/accuracy/prepare_data.py -d data
62+
uv run pytest --data=./data tests/accuracy/test_accuracy.py
7963
```
8064

8165
5. **Update the Changelog:** For significant changes, add a summary to the [CHANGELOG](CHANGELOG.md).

0 commit comments

Comments
 (0)