Skip to content

Commit 1a19652

Browse files
committed
Bump python to 3.14 and ruff to latest
1 parent fc24e51 commit 1a19652

11 files changed

Lines changed: 474 additions & 1210 deletions

File tree

.github/workflows/pre_commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ jobs:
4848
- "ubuntu-latest"
4949
- "windows-latest"
5050
python-version:
51-
- "3.10"
5251
- "3.11"
5352
- "3.12"
5453
- "3.13"
54+
- "3.14"
5555
runs-on: ${{ matrix.os }}
5656
steps:
5757
- *checkout
@@ -82,10 +82,10 @@ jobs:
8282
- "ubuntu-24.04"
8383
- "windows-2022"
8484
python-version:
85-
- "3.10"
8685
- "3.11"
8786
- "3.12"
8887
- "3.13"
88+
- "3.14"
8989
name: unit & functional tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
9090
runs-on: ${{ matrix.os }}
9191
steps:

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ repos:
1414
- id: detect-private-key
1515

1616
# Ruff version.
17-
- repo: https://github.com/charliermarsh/ruff-pre-commit
18-
rev: "v0.6.2"
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
rev: "v0.15.2"
1919
hooks:
2020
# Run the linter.
2121
- id: ruff

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10
1+
3.14

pyproject.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "hatchling.build"
1010
[project]
1111
name = "openvino_model_api"
1212
version = "0.4.0.0"
13-
requires-python = ">=3.10"
13+
requires-python = ">=3.11"
1414
authors = [
1515
{name = "Intel(R) Corporation"},
1616
]
@@ -20,13 +20,17 @@ maintainers = [
2020
description = "Model API: model wrappers and pipelines for inference with OpenVINO"
2121
readme = "README.md"
2222
classifiers = [
23-
"License :: OSI Approved :: Apache Software License",
24-
"Programming Language :: Python :: 3.10"
23+
"License :: OSI Approved :: Apache Software License",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
2528
]
2629
dependencies = [
2730
"numpy>=1.16.6",
31+
"onnxruntime",
2832
"opencv-python-headless",
29-
"openvino>=2025.3",
33+
"openvino==2025.4.1",
3034
"pillow",
3135
]
3236

@@ -220,8 +224,8 @@ line-length = 120
220224
# Allow unused variables when underscore-prefixed.
221225
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
222226

223-
# Assume Python 3.10.
224-
target-version = "py310"
227+
# Assume Python 3.14.
228+
target-version = "py314"
225229

226230
# Allow imports relative to the "src" and "tests" directories.
227231
src = ["src", "tests"]

src/model_api/models/classification.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import copy
99
import json
10-
from itertools import starmap
1110
from pathlib import Path
1211
from typing import TYPE_CHECKING
1312

@@ -251,21 +250,21 @@ def get_multilabel_predictions(self, logits: np.ndarray) -> list[Label]:
251250
labels_list = self.params.labels
252251
labels = [labels_list[i] if labels_list else "" for i in indices]
253252

254-
return list(starmap(Label, zip(indices, labels, scores)))
253+
return list(map(Label, indices, labels, scores))
255254

256255
def get_multiclass_predictions(self, outputs: dict) -> list[Label]:
257256
axis = 1
258257
logits = outputs[self.out_layer_names[0]]
259258
if not is_softmaxed(logits, axis=axis):
260259
logits = softmax(logits, axis=axis)
261260
top_k_result = top_k(logits, self.params.topk, axis=axis)
262-
scores = top_k_result.values[0] # noqa: PD011 # silencing false positive - it's not pandas code
261+
scores = top_k_result.values[0]
263262
indices = top_k_result.indices[0]
264263

265264
labels_list = self.params.labels
266265
labels = [labels_list[i] if labels_list else "" for i in indices]
267266

268-
return list(starmap(Label, zip(indices, labels, scores)))
267+
return list(map(Label, indices, labels, scores))
269268

270269

271270
def sigmoid_numpy(x: np.ndarray) -> np.ndarray:

src/model_api/models/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __dir__(self) -> list[str]:
4545
try:
4646
parameters = self._model.get_cached_parameters()
4747
return list(parameters.keys())
48-
except (AttributeError, TypeError, ValueError):
48+
except AttributeError, TypeError, ValueError:
4949
return []
5050

5151

src/model_api/models/yolo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@ def parameters(cls):
761761
{
762762
"agnostic_nms": BooleanValue(
763763
description=(
764-
"If True, the model is agnostic to the number of classes, "
765-
"and all classes are considered as one"
764+
"If True, the model is agnostic to the number of classes, and all classes are considered as one"
766765
),
767766
default_value=False,
768767
),

tests/accuracy/download_models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ async def stream_file(client, url, filename, semaphore):
3737

3838
async def download_single_image(client, url, filename):
3939
image = await client.get(url)
40-
with Path(filename).open("wb") as im:
41-
im.write(image.content)
40+
Path(filename).write_bytes(image.content)
4241

4342

4443
async def download_images(data_dir):

tests/accuracy/test_accuracy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ def compare_detection_result(outputs: DetectionResult, reference: dict) -> None:
223223
if expected_bboxes.size == 0 and outputs.bboxes.size == 0:
224224
expected_bboxes = expected_bboxes.reshape(0, 4)
225225

226-
assert (
227-
outputs.bboxes.shape == expected_bboxes.shape
228-
), f"bboxes shape mismatch: {outputs.bboxes.shape} vs {expected_bboxes.shape}"
226+
assert outputs.bboxes.shape == expected_bboxes.shape, (
227+
f"bboxes shape mismatch: {outputs.bboxes.shape} vs {expected_bboxes.shape}"
228+
)
229229

230230
# Sort both outputs and expected by bbox coordinates (x1, y1, x2, y2) for deterministic comparison
231231
output_sort_indices = np.lexsort((

tools/model_converter/model_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ def create_model(
189189
elif "state_dict" in checkpoint:
190190
# Cannot reconstruct architecture from state_dict alone
191191
error_msg = (
192-
"Checkpoint contains only state_dict. "
193-
"Please specify the model class instead of torch.nn.Module"
192+
"Checkpoint contains only state_dict. Please specify the model class instead of torch.nn.Module"
194193
)
195194
raise ValueError(error_msg)
196195
else:

0 commit comments

Comments
 (0)