Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Dockerfile.redhat
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ RUN rm -f /usr/lib64/cmake/OpenSSL/OpenSSLConfig.cmake
# Builds unit tests together with ovms server in one step
# It speeds up CI when tests are executed outside of the image building
# hadolint ignore=SC2046
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} ${minitrace_flags} //src:ovms $(if [ "$OPTIMIZE_BUILDING_TESTS" == "1" ] ; then echo -n //src:ovms_test; fi)
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} ${minitrace_flags} //src:ovms $(if [ "$OPTIMIZE_BUILDING_TESTS" == "1" ] ; then echo -n "//src:ovms_test //src:python_runtime_library_test"; fi)

# Tests execution
COPY ci/check_coverage.bat /ovms/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ ARG OPTIMIZE_BUILDING_TESTS=0
# Builds unit tests together with ovms server in one step
# It speeds up CI when tests are executed outside of the image building
# hadolint ignore=SC2046
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${debug_bazel_flags} ${minitrace_flags} //src:ovms $(if [ "${OPTIMIZE_BUILDING_TESTS}" == "1" ] ; then echo -n //src:ovms_test; fi); fi;
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${debug_bazel_flags} ${minitrace_flags} //src:ovms $(if [ "${OPTIMIZE_BUILDING_TESTS}" == "1" ] ; then echo -n "//src:ovms_test //src:python_runtime_library_test"; fi); fi;

ARG RUN_TESTS=0
RUN if [ "$RUN_TESTS" == "1" ] ; then mkdir -p demos/common/export_models/ && mv export_model.py demos/common/export_models/ && ./prepare_llm_models.sh /ovms/src/test/llm_testing docker && ./run_unit_tests.sh ; fi
Expand Down
9 changes: 8 additions & 1 deletion create_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ if [ -f /ovms_release/lib/libsrc_Slibovms_Ushared.so ] ; then \
fi

# Add Python bindings for pyovms, openvino, openvino_tokenizers and openvino_genai, so they are all available for OVMS Python servables
if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then
if [ ! -f /ovms_release/lib/libovmspython.so ]; then
echo "Missing libovmspython.so in package staging. Ensure //src/python:libovmspython is built."
exit 1
fi
fi

if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then cp -r /opt/intel/openvino/python /ovms_release/lib/python ; fi
if ! [[ $debug_bazel_flags == *"_py_off"* ]] && [ "$FUZZER_BUILD" == "0" ]; then mv /ovms_release/lib/pyovms.so /ovms_release/lib/python ; fi
if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then mv /ovms_release/lib/python/bin/convert_tokenizer /ovms_release/bin/convert_tokenizer ; \
Expand Down Expand Up @@ -106,7 +113,7 @@ ls -lahR /ovms_release/

# removing 29MB of cpython packages for unsupported python versions
rls_python=cpython-"$(python3 --version 2>&1 | awk '{gsub(/\./, "", $2); print $2}' | cut -c1-3)"
find /ovms_release/ovms/lib/python/openvino -name *cpython* | grep -vZ $rls_python | xargs rm -rf --
find /ovms_release/lib/python/openvino -name *cpython* | grep -vZ $rls_python | xargs rm -rf --

mkdir -p /ovms_pkg/${BASE_OS}
cd /ovms_pkg/${BASE_OS}
Expand Down
7 changes: 4 additions & 3 deletions run_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FAIL_LOG=${FAIL_LOG:-"fail.log"}
if [ -f /etc/redhat-release ] ; then dist="--//:distro=redhat" ; fi
debug_bazel_flags=${debug_bazel_flags:-"--config=mp_on_py_on $dist"}
TEST_FILTER="--test_filter=*"
UNIT_TEST_TARGETS="//src:ovms_test //src:python_runtime_library_test"
SHARED_OPTIONS=" \
--jobs=$JOBS \
${debug_bazel_flags} \
Expand Down Expand Up @@ -93,7 +94,7 @@ if [ "$RUN_TESTS" == "1" ] ; then
if [ "$CHECK_COVERAGE" == "1" ] ; then
if bazel coverage --instrumentation_filter="-src/test" --combined_report=lcov \
${SHARED_OPTIONS} ${TEST_FILTER} \
//src:ovms_test ${SHARED_OPTIONS} > ${TEST_LOG} 2>&1 ; then
${UNIT_TEST_TARGETS} ${SHARED_OPTIONS} > ${TEST_LOG} 2>&1 ; then
if ! generate_coverage_report ; then
compress_logs
exit 1
Expand All @@ -104,12 +105,12 @@ if [ "$RUN_TESTS" == "1" ] ; then
fi
fi
bazel test ${SHARED_OPTIONS} "${TEST_FILTER}" //src/python/binding:test_python_binding || exit 1
bazel build ${SHARED_OPTIONS} //src:ovms_test || exit 1
bazel build ${SHARED_OPTIONS} ${UNIT_TEST_TARGETS} || exit 1
echo "Executing unit tests"
failed=0

# For RH UBI and Ubuntu
if ! bazel test --jobs=$JOBS ${debug_bazel_flags} ${SHARED_OPTIONS} --test_summary=detailed --test_output=streamed --test_filter="*" //src:ovms_test > ${TEST_LOG} 2>&1 ; then
if ! bazel test --jobs=$JOBS ${debug_bazel_flags} ${SHARED_OPTIONS} --test_summary=detailed --test_output=streamed --test_filter="*" ${UNIT_TEST_TARGETS} > ${TEST_LOG} 2>&1 ; then
failed=1
fi
cat ${TEST_LOG} | tail -500
Expand Down
64 changes: 58 additions & 6 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ ovms_cc_library(
],
deps = select({
"//:not_disable_python": [
"//src/python:libovmspythonmodule",
"//src/python:pythonnoderesources",
"//src/python:pythonexecutorcalculator",
"//src/python:pytensorovtensorconvertercalculator",
],
"//:disable_python": []
}) + select({
Expand Down Expand Up @@ -950,10 +952,13 @@ ovms_cc_library(
"//conditions:default": ["-lOpenCL"], # TODO make as direct dependency
"//src:windows" : ["/DEFAULTLIB:Rpcrt4.lib"],}),
data = select({
"//:not_disable_python": [
"//:is_windows_and_python_is_enabled": [
"//src/python/binding:pyovms.pyd",
],
"//:disable_python": [],
"//conditions:default": [
"//src/python/binding:pyovms.so",
],
"//:disable_python": []
}) + select({
"//:is_windows_and_python_is_enabled": [
"//src/python/binding:copy_pyovms",
Expand Down Expand Up @@ -2256,10 +2261,13 @@ cc_binary(
"//:disable_mediapipe" : [],
}),
data = select({
"//:not_disable_python": [
"//:is_windows_and_python_is_enabled": [
"//src/python/binding:pyovms.pyd",
],
"//:disable_python": [],
"//conditions:default": [
"//src/python/binding:pyovms.so",
],
"//:disable_python": []
}),
# linkstatic = False, # Use for dynamic linking when necessary
)
Expand Down Expand Up @@ -2513,7 +2521,15 @@ cc_test(
"//src:libcustom_node_image_transformation.so",
"//src:libcustom_node_add_one.so",
"//src:libcustom_node_horizontal_ocr.so",
],
] + select({
"//:is_windows_and_python_is_enabled": [
"//src/python:libovmspython.dll",
],
"//:disable_python": [],
"//conditions:default": [
"//src/python:libovmspython.so",
],
}),
deps = [
"optimum-cli",
"//src:ovms_lib",
Expand Down Expand Up @@ -2567,6 +2583,11 @@ cc_test(
[
"serialization_common",
],
}) + select({
"//:not_disable_python": [
"//src/python:libovmspythonmodule",
],
"//:disable_python": [],
}),
copts = COPTS_TESTS,
local_defines = COMMON_LOCAL_DEFINES,
Expand All @@ -2587,6 +2608,34 @@ cc_library(
copts = COPTS_TESTS,
linkopts = COMMON_STATIC_LIBS_LINKOPTS,
)

cc_test(
name = "python_runtime_library_test",
srcs = [
"test/python_runtime_library_test.cpp",
],
copts = ["-Wno-format-security"],
data = select({
"//src:windows": [
"//src/python:libovmspython.dll",
"//src/python/binding:pyovms.pyd",
],
"//:disable_python": [],
"//conditions:default": [
"//src/python:libovmspython.so",
"//src/python/binding:pyovms.so",
],
}),
linkopts = select({
"//src:windows": [],
"//conditions:default": ["-ldl"],
}),
visibility = ["//visibility:public"],
deps = [
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "test_test_models",
hdrs = ["test/test_models.hpp",],
Expand Down Expand Up @@ -2746,6 +2795,9 @@ cc_library(
srcs = ["test/python_environment.cpp",],
linkopts = [],
deps = PYBIND_DEPS + [
"//src/python:libovmspythonmodule",
"//src:cpp_headers",
"libovmsstatus",
"@com_google_googletest//:gtest",
],
local_defines = COMMON_LOCAL_DEFINES,
Expand Down
5 changes: 5 additions & 0 deletions src/kfs_frontend/kfs_graph_executor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,11 @@ static Status deserializeTensor(const std::string& requestedName, const KFSReque

#if (PYTHON_DISABLE == 0)
static Status deserializeTensor(const std::string& requestedName, const KFSRequest& request, std::unique_ptr<PyObjectWrapper<py::object>>& outTensor, PythonBackend* pythonBackend) {
if (pythonBackend == nullptr) {
const std::string details = "Python backend is not available. Ensure libovmspython runtime library is accessible when using Python tensor inputs.";
SPDLOG_DEBUG("[servable name: {} version: {}] {}", request.model_name(), request.model_version(), details);
return Status(StatusCode::MEDIAPIPE_EXECUTION_ERROR, details);
}
auto requestInputItr = request.inputs().begin();
auto status = getRequestInput(requestInputItr, requestedName, request);
if (!status.ok()) {
Expand Down
8 changes: 8 additions & 0 deletions src/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace ovms {
class Config;
class Status;
class PythonBackend;
enum class ModuleState {
NOT_INITIALIZED,
STARTED_INITIALIZE,
Expand All @@ -34,6 +35,13 @@ class Module {
public:
virtual Status start(const ovms::Config& config) = 0;
virtual void shutdown() = 0;
virtual PythonBackend* getPythonBackend() const {
return nullptr;
}
virtual bool ownsPythonInterpreter() const {
return false;
}
virtual void releaseGILFromThisThread() const {}
virtual ~Module() = default;
ModuleState getState() const;
};
Expand Down
Loading