Skip to content
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
5 changes: 3 additions & 2 deletions src/bindings/python/src/pyopenvino/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ std::tuple<Args...> tuple_from_py_tuple(const py::tuple& py_tuple) {
ov::Any py_object_to_any(const py::object& py_obj) {
// Python types
py::object float_32_type = py::module_::import("numpy").attr("float32");
if (py::isinstance<py::str>(py_obj)) {
return py_obj.cast<std::string>();
py::object Path = py::module_::import("pathlib").attr("Path");
if (py::isinstance<py::str>(py_obj) || py::isinstance(py_obj, Path)) {
return py::str(py_obj).cast<std::string>();
} else if (py::isinstance<py::bool_>(py_obj)) {
return py_obj.cast<bool>();
} else if (py::isinstance<py::bytes>(py_obj)) {
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/tests/test_runtime/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_read_model_as_path_with_user_config(request, tmp_path):
core_cache_dir = core.get_property("CACHE_DIR")
cache_path = tmp_path / Path("cache_as_path")

model = core.read_model(Path(xml_path), Path(bin_path), config={"CACHE_DIR": f"{cache_path}"})
model = core.read_model(Path(xml_path), Path(bin_path), config={"CACHE_DIR": cache_path})

assert isinstance(model, Model)
assert core_cache_dir == core.get_property("CACHE_DIR")
Expand Down
8 changes: 8 additions & 0 deletions src/bindings/python/tests/test_runtime/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import numpy as np
import os
from pathlib import Path

import openvino as ov
import openvino.properties as props
Expand Down Expand Up @@ -646,6 +647,13 @@ def test_single_property_setting(device):
assert isinstance(core.get_property(device, streams.num()), int)


def test_property_pathlib_path(device):
core = Core()

core.set_property(device, {"CACHE_DIR": Path("./test_cache")})
assert core.get_property(device, props.cache_dir) == str(Path("./test_cache"))


@pytest.mark.skipif(
os.environ.get("TEST_DEVICE", "CPU") != "CPU",
reason=f"Cannot run test on device {os.environ.get('TEST_DEVICE')}, Plugin specific test"
Expand Down
Loading