Skip to content

Commit e8fb390

Browse files
mgumowskCopilot
andauthored
feat: restructure repository in model_api and model_converter projects (#551)
* split model_api and model_converter * fix bandit scan * fix zizmor complain * update contributing document Co-authored-by: Copilot <copilot@github.com> --------- Co-authored-by: Copilot <copilot@github.com>
1 parent a272f60 commit e8fb390

194 files changed

Lines changed: 3132 additions & 991 deletions

File tree

Some content is hidden

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

.github/labeler.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
python:
44
- changed-files:
55
- any-glob-to-any-file:
6-
- src/**
6+
- model_api/src/**
7+
- model_converter/src/**
78

89
tests:
910
- changed-files:
1011
- any-glob-to-any-file:
11-
- tests/**
12+
- model_api/tests/**
13+
- model_converter/tests/**
1214

1315
docs:
1416
- changed-files:
1517
- any-glob-to-any-file:
16-
- docs/**
18+
- model_api/docs/**
19+
- model_converter/docs/**
1720
- "**/*.md"
1821
- "LICENSE"
1922

@@ -22,10 +25,14 @@ build:
2225
- any-glob-to-any-file:
2326
- ".github/**/*"
2427
- ".pre-commit-config.yaml"
25-
- "pyproject.toml"
28+
- "model_api/pyproject.toml"
29+
- "model_api/uv.lock"
30+
- "model_converter/pyproject.toml"
31+
- "model_converter/uv.lock"
2632
- "**/CMakeLists.txt"
2733

2834
samples:
2935
- changed-files:
3036
- any-glob-to-any-file:
31-
- examples/**
37+
- model_api/examples/**
38+
- model_converter/examples/**

.github/workflows/docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ jobs:
3131

3232
- name: Install dependencies
3333
run: |
34-
uv sync --locked --extra docs
34+
uv --directory model_api sync --locked --group docs
3535
3636
- name: Build Docs
37-
working-directory: docs
38-
run: uv run make html
37+
working-directory: model_api
38+
run: uv run make -C docs html
3939

4040
- name: Branch name
4141
id: branch_name
@@ -82,7 +82,7 @@ jobs:
8282
git fetch
8383
git checkout gh-pages
8484
mkdir -p /tmp/docs_build
85-
cp -r docs/build/html/* /tmp/docs_build/
85+
cp -r model_api/docs/build/html/* /tmp/docs_build/
8686
rm -rf "$RELEASE_VERSION"/*
8787
echo '<html><head><meta http-equiv="refresh" content="0; url=latest/" /></head></html>' > index.html
8888
mkdir -p "$RELEASE_VERSION"

.github/workflows/pre_commit.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ jobs:
3535
version: "0.11.3"
3636

3737
- name: Install dependencies
38-
run: uv sync --locked --all-extras
38+
run: |
39+
uv --directory model_api sync --locked --all-extras --group docs
40+
uv --directory model_converter sync --locked
3941
4042
- name: Run pre-commit checks
4143
run: uvx pre-commit run --all-files
@@ -69,13 +71,13 @@ jobs:
6971

7072
- &install-dependencies
7173
name: Install dependencies
72-
run: uv sync --locked --extra tests --extra-index-url https://download.pytorch.org/whl/cpu
74+
run: uv --directory model_api sync --locked --group tests --extra-index-url https://download.pytorch.org/whl/cpu
7375

7476
- name: Prepare test data
75-
run: uv run python tests/accuracy/download_models.py -d data -j tests/accuracy/public_scope.json -l
77+
run: uv --directory model_api run python tests/accuracy/download_models.py -d data -j tests/accuracy/public_scope.json -l
7678

7779
- name: Run Python Test
78-
run: uv run pytest --data=./data tests/accuracy/test_accuracy.py
80+
run: uv --directory model_api run pytest --data=./data tests/accuracy/test_accuracy.py
7981

8082
unit-functional-tests:
8183
strategy:
@@ -99,16 +101,16 @@ jobs:
99101
- *install-dependencies
100102

101103
- name: Run python unit tests
102-
run: uv run pytest tests/unit --cov
104+
run: uv --directory model_api run pytest tests/unit --cov
103105

104106
- &prepare-test-data
105107
name: Prepare test data
106108
run: |
107-
uv run python tests/accuracy/download_models.py -d data -j tests/precommit/public_scope.json -l
109+
uv --directory model_api run python tests/accuracy/download_models.py -d data -j tests/precommit/public_scope.json -l
108110
109111
- name: Run test
110112
run: |
111-
uv run pytest --data=./data tests/functional
113+
uv --directory model_api run pytest --data=./data tests/functional
112114
113115
serving_api-tests:
114116
strategy:
@@ -134,15 +136,15 @@ jobs:
134136
- *matrix-setup-uv
135137

136138
- name: Install dependencies
137-
run: uv sync --locked --extra tests --extra ovms --extra-index-url https://download.pytorch.org/whl/cpu
139+
run: uv --directory model_api sync --locked --group tests --extra ovms --extra-index-url https://download.pytorch.org/whl/cpu
138140

139141
- *prepare-test-data
140142

141143
- name: serving_api
142144
run: |
143-
uv run python -c "from model_api.models import Model; Model.create_model('./data/otx_models/ssd-card-detection.xml').save('ovms_models/ssd-card-detection/1/ssd-card-detection.xml')"
144-
docker run -d --rm -v $GITHUB_WORKSPACE/ovms_models/:/models -p 8000:8000 openvino/model_server:latest --model_path /models/ssd-card-detection/ --model_name ssd-card-detection --rest_port 8000 --log_level DEBUG --target_device CPU
145-
uv run python examples/serving_api/run.py data/coco128/images/train2017/000000000009.jpg # detects 4 objects
145+
uv --directory model_api run python -c "from model_api.models import Model; Model.create_model('./data/otx_models/ssd-card-detection.xml').save('ovms_models/ssd-card-detection/1/ssd-card-detection.xml')"
146+
docker run -d --rm -v $GITHUB_WORKSPACE/model_api/ovms_models/:/models -p 8000:8000 openvino/model_server:latest --model_path /models/ssd-card-detection/ --model_name ssd-card-detection --rest_port 8000 --log_level DEBUG --target_device CPU
147+
uv --directory model_api run python examples/serving_api/run.py data/coco128/images/train2017/000000000009.jpg # detects 4 objects
146148
147149
pre-commit-result:
148150
runs-on: ubuntu-latest

.github/workflows/publish.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions: {} # No permissions by default on workflow level
99

1010
jobs:
1111
build:
12-
name: Build
12+
name: Build model_api
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout code
@@ -26,23 +26,23 @@ jobs:
2626
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
2727

2828
- name: Install pypa/build
29-
run: uv sync --locked
29+
run: uv --directory model_api sync --locked
3030

3131
- name: Build sdist
32-
run: uv build --sdist
32+
run: uv --directory model_api build --sdist
3333

3434
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
3535
with:
36-
name: artifact-sdist
37-
path: dist/*.tar.gz
36+
name: artifact-model_api-sdist
37+
path: model_api/dist/*.tar.gz
3838

3939
- name: Build wheel
40-
run: uv build --wheel
40+
run: uv --directory model_api build --wheel
4141

4242
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
4343
with:
44-
name: artifact-wheel
45-
path: dist/*.whl
44+
name: artifact-model_api-wheel
45+
path: model_api/dist/*.whl
4646

4747
publish_package:
4848
name: Publish package

.github/workflows/security-scan.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ jobs:
4444
confidence-level: "LOW"
4545
fail-on-findings: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'true' || 'false' }}
4646

47-
bandit-scan:
47+
bandit-scan-project:
4848
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
project:
53+
- model_api
54+
- model_converter
4955
permissions:
5056
contents: read
5157
security-events: write # Needed to upload the results to code-scanning dashboard
@@ -58,9 +64,22 @@ jobs:
5864
scan-scope: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'changed' || 'all' }}
5965
severity-level: "LOW"
6066
confidence-level: "LOW"
61-
config_file: "pyproject.toml"
67+
config_file: "${{ matrix.project }}/pyproject.toml"
6268
fail-on-findings: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'true' || 'false' }}
6369

70+
bandit-scan:
71+
runs-on: ubuntu-latest
72+
needs: [bandit-scan-project]
73+
if: always()
74+
steps:
75+
- name: Check bandit scan results
76+
env:
77+
RESULT: ${{ needs.bandit-scan-project.result }}
78+
run: |
79+
if [[ "$RESULT" == "failure" ]]; then
80+
exit 1
81+
fi
82+
6483
trivy-scan:
6584
runs-on: ubuntu-latest
6685
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'

.pre-commit-config.yaml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,36 @@ repos:
1919
hooks:
2020
# Run the linter.
2121
- id: ruff
22-
args: ["--fix"]
22+
name: ruff (model_api)
23+
args: ["--fix", "--config=model_api/pyproject.toml"]
24+
files: ^model_api/
25+
- id: ruff
26+
name: ruff (model_converter)
27+
args: ["--fix", "--config=model_converter/pyproject.toml"]
28+
files: ^model_converter/
2329
# Run the formatter
2430
- id: ruff-format
31+
name: ruff-format (model_api)
32+
args: ["--config=model_api/pyproject.toml"]
33+
files: ^model_api/
34+
- id: ruff-format
35+
name: ruff-format (model_converter)
36+
args: ["--config=model_converter/pyproject.toml"]
37+
files: ^model_converter/
2538

2639
# python static type checking
2740
- repo: https://github.com/pre-commit/mirrors-mypy
2841
rev: "v1.11.2"
2942
hooks:
3043
- id: mypy
44+
name: mypy (model_api)
45+
args: ["--config-file=model_api/pyproject.toml"]
46+
files: ^model_api/(src|tests|examples)/.*\.py$
47+
additional_dependencies: [types-PyYAML, types-setuptools]
48+
- id: mypy
49+
name: mypy (model_converter)
50+
args: ["--config-file=model_converter/pyproject.toml"]
51+
files: ^model_converter/(src|tests)/.*\.py$
3152
additional_dependencies: [types-PyYAML, types-setuptools]
3253

3354
- repo: https://github.com/rbubley/mirrors-prettier
@@ -52,13 +73,28 @@ repos:
5273
rev: 1.8.3
5374
hooks:
5475
- id: bandit
76+
name: bandit (model_api)
77+
args:
78+
[
79+
"-c",
80+
"model_api/pyproject.toml",
81+
"--severity-level",
82+
"all",
83+
"--confidence-level",
84+
"all",
85+
]
86+
files: ^model_api/.*\.py$
87+
additional_dependencies: ["bandit[toml]"]
88+
- id: bandit
89+
name: bandit (model_converter)
5590
args:
5691
[
5792
"-c",
58-
"pyproject.toml",
93+
"model_converter/pyproject.toml",
5994
"--severity-level",
6095
"all",
6196
"--confidence-level",
6297
"all",
6398
]
99+
files: ^model_converter/.*\.py$
64100
additional_dependencies: ["bandit[toml]"]

CONTRIBUTING.md

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

38-
1. Create a new python environment and install the development requirements:
38+
Install only the subproject(s) you are working on. Each step is independent.
39+
40+
1. **`model_api`** — Create the environment and install the development requirements:
41+
42+
```bash
43+
uv --directory model_api sync --all-extras --group tests --group docs
44+
```
45+
46+
The optional YOLOv8 accuracy tests need the heavier `yolo-tests` group:
47+
48+
```bash
49+
uv --directory model_api sync --group tests --group yolo-tests --extra-index-url https://download.pytorch.org/whl/cpu
50+
```
51+
52+
2. **`model_converter`** — Create the environment and install the development requirements:
3953

4054
```bash
41-
uv sync --all-extras
55+
uv --directory model_converter sync --group tests
4256
```
4357

4458
</details>
4559

4660
### Making Changes
4761

48-
1. **Write Code:** Follow the project's coding standards and write your code with clear intent. Ensure your code is well-documented and includes examples where appropriate. For code quality we use ruff, whose configuration is in [`pyproject.toml`](pyproject.toml) file.
62+
1. **Write Code:** Follow the project's coding standards and write your code with clear intent. Ensure your code is well-documented and includes examples where appropriate. For code quality we use ruff, whose configuration is in each subproject's `pyproject.toml` file: [`model_api/pyproject.toml`](model_api/pyproject.toml) and [`model_converter/pyproject.toml`](model_converter/pyproject.toml).
4963

5064
2. **Add Tests:** If your code includes new functionality, add corresponding tests using [pytest](https://docs.pytest.org/en/7.4.x/) to maintain coverage and reliability.
5165

@@ -55,11 +69,12 @@ Set up your development environment to start contributing. This involves install
5569

5670
```bash
5771
uvx pre-commit run --all-files
58-
uv run pytest tests/unit
59-
uv run python tests/accuracy/download_models.py -d data -j tests/precommit/public_scope.json -l
60-
uv run pytest --data=./data tests/functional
61-
uv run python tests/accuracy/download_models.py -d data -j tests/accuracy/public_scope.json -l
62-
uv run pytest --data=./data tests/accuracy/test_accuracy.py
72+
uv --directory model_api run pytest tests/unit
73+
uv --directory model_api run python tests/accuracy/download_models.py -d data -j tests/precommit/public_scope.json -l
74+
uv --directory model_api run pytest --data=./data tests/functional
75+
uv --directory model_api run python tests/accuracy/download_models.py -d data -j tests/accuracy/public_scope.json -l
76+
uv --directory model_api run pytest --data=./data tests/accuracy/test_accuracy.py
77+
uv --directory model_converter run model-converter examples/config.json --list
6378
```
6479

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

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ Training Extensions embed all the metadata required for inference into model fil
3636

3737
`pip install openvino-model-api`
3838

39+
## Repository layout
40+
41+
This repository contains two independently installable Python subprojects:
42+
43+
- `model_api/` — the inference library published as `openvino-model-api` with a minimal runtime dependency set.
44+
- `model_converter/` — conversion tooling published as `openvino-model-converter`, with conversion-time dependencies such as PyTorch, TorchVision, OpenVINO, ONNX, and NNCF.
45+
46+
Each subproject owns its own `pyproject.toml` and `uv.lock`.
47+
Shared repository files, including this `README.md`, `LICENSE`, `CONTRIBUTING.md`, `SECURITY.md`, and CI workflows, remain at the repository root.
48+
3949
## Usage
4050

4151
```python
@@ -89,4 +99,4 @@ print(f"Inference result: {result}")
8999
model.save("serialized_with_metadata.xml")
90100
```
91101

92-
For more details please refer to the [examples](https://github.com/openvinotoolkit/model_api/tree/master/examples) of this project.
102+
For more details please refer to the [examples](https://github.com/openvinotoolkit/model_api/tree/master/model_api/examples) of this project.

docs/source/models/action_classification.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/source/models/visual_prompting.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)