|
| 1 | +# Integration Tests |
| 2 | + |
| 3 | +## Scope |
| 4 | + |
| 5 | +Integration tests in this directory validate end-to-end model loading and inference through Model API wrappers. |
| 6 | +Result is not compared against reference outputs, but rather we check that the model can be loaded and run without exceptions on a sample, random input. |
| 7 | + |
| 8 | +Current coverage is centered on `tests/integration/test_model.py`, which: |
| 9 | + |
| 10 | +- Resolves model targets from CLI options (`--model-path` or HF Hub `--author`/`--collection`) |
| 11 | +- Loads models via: |
| 12 | + - `Model.create_model(...)` for local paths |
| 13 | + - `Model.from_pretrained(...)` for `hf://...` references |
| 14 | +- Runs inference on a deterministic random RGB image (`640x640x3`, `uint8`) |
| 15 | +- Passes if no exception is raised during load + single inference call |
| 16 | + |
| 17 | +In short, this is a smoke/integration check for model usability, not an accuracy benchmark. |
| 18 | + |
| 19 | +## Inputs and Parametrization |
| 20 | + |
| 21 | +`pytest_generate_tests` in `tests/integration/test_model.py` dynamically parametrizes `path`: |
| 22 | + |
| 23 | +1. If `--model-path` is provided: |
| 24 | + - `hf://...` => treated as a single HF model |
| 25 | + - file path => single local model |
| 26 | + - directory => recursively collects all `*.xml` files |
| 27 | +2. Else, if `--author` is set: |
| 28 | + - fetches model repos from HF Hub |
| 29 | + - optionally filtered by `--collection` |
| 30 | +3. If no paths are resolved: |
| 31 | + - test is skipped |
| 32 | + |
| 33 | +## CLI Options |
| 34 | + |
| 35 | +Defined in `tests/integration/conftest.py`: |
| 36 | + |
| 37 | +- `--model-path` (default: `None`) |
| 38 | + Local file, local directory, or `hf://repo_id` |
| 39 | +- `--device` (default: `AUTO`) |
| 40 | + Target inference device, e.g. `CPU`, `GPU`, `AUTO` |
| 41 | +- `--author` (default: `OpenVINO`) |
| 42 | + HF Hub author/organization used when `--model-path` is not passed |
| 43 | +- `--collection` (default: `vision`) |
| 44 | + HF Hub collection under `author` |
| 45 | + |
| 46 | +> Note: because `author`/`collection` have defaults, running this test without args attempts HF Hub discovery [OpenVINO/vision](https://huggingface.co/collections/OpenVINO/vision) unless you explicitly pass `--model-path`. |
| 47 | +
|
| 48 | +## Usage |
| 49 | + |
| 50 | +Run from the `model_api` repository root. |
| 51 | + |
| 52 | +### Default usage |
| 53 | + |
| 54 | +When executed without any CLI options, the test will attempt to discover models from HF Hub [OpenVINO/vision](https://huggingface.co/collections/OpenVINO/vision) collection and run inference on all of those. |
| 55 | + |
| 56 | +```bash |
| 57 | +uv --directory model_api run pytest tests/integration/test_model.py |
| 58 | +``` |
| 59 | + |
| 60 | +### All models from HF Hub author |
| 61 | + |
| 62 | +```bash |
| 63 | +uv --directory model_api run pytest tests/integration/test_model.py --author hf_author_name |
| 64 | +``` |
| 65 | + |
| 66 | +### All models from HF Hub author and collection |
| 67 | + |
| 68 | +```bash |
| 69 | +uv --directory model_api run pytest tests/integration/test_model.py --author hf_author_name --collection collection_name |
| 70 | +``` |
| 71 | + |
| 72 | +### Single model from HF Hub |
| 73 | + |
| 74 | +```bash |
| 75 | +uv --directory model_api run pytest tests/integration/test_model.py --model-path hf://OpenVINO/resnet50-int8-ov |
| 76 | +``` |
| 77 | + |
| 78 | + |
| 79 | +### Single local model with absolute path |
| 80 | + |
| 81 | +```bash |
| 82 | +uv --directory model_api run pytest tests/integration/test_model.py --model-path /absolute/path/to/model.xml |
| 83 | +``` |
| 84 | + |
| 85 | +### Single local model with path relative to `model_api` package root |
| 86 | + |
| 87 | +```bash |
| 88 | +uv --directory model_api run pytest tests/integration --model-path data/anomalib_models/padim.xml |
| 89 | +``` |
| 90 | + |
| 91 | +### Multiple local models from a directory |
| 92 | + |
| 93 | +```bash |
| 94 | +uv --directory model_api run pytest tests/integration --model-path data/anomalib_models |
| 95 | +``` |
0 commit comments