Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ovms versions for windows #2920

Merged
merged 8 commits into from
Dec 30, 2024
Merged
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
6 changes: 2 additions & 4 deletions Dockerfile.redhat
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ ENV PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src/python/binding
WORKDIR /ovms

ARG PROJECT_VERSION="2025.0"
ARG PROJECT_NAME="OpenVINO Model Server"
LABEL description=${PROJECT_NAME}
LABEL description="OpenVINO Model Server"
ARG minitrace_flags

# Test Coverage
Expand All @@ -319,8 +318,7 @@ COPY run_unit_tests.sh prepare_llm_models.sh prepare_gpu_models.sh /ovms/
RUN if [ "$RUN_TESTS" == "1" ] ; then ./prepare_llm_models.sh /ovms/src/test/llm_testing docker && ./run_unit_tests.sh ; fi

# Set OVMS version strings
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp" && \
bash -c "sed -i -e 's|REPLACE_PROJECT_VERSION|${PROJECT_VERSION}|g' /ovms/src/version.hpp" && \
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_VERSION|${PROJECT_VERSION}|g' /ovms/src/version.hpp" && \
if [ "$ov_use_binary" = "1" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(find /opt/intel/ -maxdepth 1 -mindepth 1 -type d | grep openvino | grep -Eo '[0-9]{4}.[0-9].[0-9].[^_]+')#g" /ovms/src/version.hpp ; fi && \
if [ "$ov_use_binary" == "0" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(git --git-dir /openvino/.git log -n 1 | head -n 1 | cut -d' ' -f2 | head -c 12)#g" /ovms/src/version.hpp ; fi && \
bash -c "sed -i -e 's|REPLACE_BAZEL_BUILD_FLAGS|${debug_bazel_flags}${minitrace_flags}|g' /ovms/src/version.hpp"
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,11 @@ RUN if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ;
WORKDIR /ovms

ARG PROJECT_VERSION="2025.0"
ARG PROJECT_NAME="OpenVINO Model Server"
LABEL description=${PROJECT_NAME}
LABEL description="OpenVINO Model Server"
ARG minitrace_flags
ENV PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src/python/binding
# Set OVMS version strings
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp" && \
bash -c "sed -i -e 's|REPLACE_PROJECT_VERSION|${PROJECT_VERSION}|g' /ovms/src/version.hpp" && \
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_VERSION|${PROJECT_VERSION}|g' /ovms/src/version.hpp" && \
if [ "$ov_use_binary" == "1" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(find /opt/intel/ -maxdepth 1 -mindepth 1 -type d | grep openvino | grep -Eo '[0-9]{4}.[0-9].[0-9].[^_]+')#g" /ovms/src/version.hpp ; fi && \
if [ "$ov_use_binary" == "0" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(git --git-dir /openvino/.git log -n 1 | head -n 1 | cut -d' ' -f2 | head -c 12)#g" /ovms/src/version.hpp ; fi && \
bash -c "sed -i -e 's|REPLACE_BAZEL_BUILD_FLAGS|${debug_bazel_flags}${minitrace_flags}|g' /ovms/src/version.hpp"
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ endif

OVMS_PYTHON_IMAGE_TAG ?= py

PRODUCT_NAME = "OpenVINO Model Server"
PRODUCT_VERSION ?= "2025.0"
PROJECT_VER_PATCH =

$(eval PROJECT_VER_PATCH:=`git rev-parse --short HEAD`)
$(eval PROJECT_NAME:=${PRODUCT_NAME})
$(eval PROJECT_VERSION:=${PRODUCT_VERSION}.${PROJECT_VER_PATCH})

OVMS_CPP_CONTAINER_NAME ?= "server-test-${PROJECT_VER_PATCH}-$(shell date +%Y-%m-%d-%H.%M.%S)"
Expand Down
1 change: 0 additions & 1 deletion ci/lib_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#No header files detected
# Copyright (c) 2020-2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//*****************************************************************************
#ifndef SRC_VERSION_HPP_
#define SRC_VERSION_HPP_
#define PROJECT_NAME "REPLACE_PROJECT_NAME"
#define PROJECT_NAME "OpenVINO Model Server"
#define PROJECT_VERSION "REPLACE_PROJECT_VERSION"
#define OPENVINO_NAME "REPLACE_OPENVINO_NAME"
#define BAZEL_BUILD_FLAGS "REPLACE_BAZEL_BUILD_FLAGS"
Expand Down
8 changes: 6 additions & 2 deletions windows_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ IF "%~1"=="" (
set "bazelStartupCmd=--output_user_root=%BAZEL_SHORT_PATH%"
set "openvino_dir=C:/%1/openvino/runtime/cmake"

set "buildCommand=bazel %bazelStartupCmd% build --config=windows --action_env OpenVINO_DIR=%openvino_dir% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures //src:ovms 2>&1 | tee win_build.log"
set "buildTestCommand=bazel %bazelStartupCmd% build --config=windows --action_env OpenVINO_DIR=%openvino_dir% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures //src:ovms_test 2>&1 | tee win_build_test.log"
set "bazelBuildArgs=--config=windows --action_env OpenVINO_DIR=%openvino_dir%"
set "buildCommand=bazel %bazelStartupCmd% build %bazelBuildArgs% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures //src:ovms 2>&1 | tee win_build.log"
set "buildTestCommand=bazel %bazelStartupCmd% build %bazelBuildArgs% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures //src:ovms_test 2>&1 | tee win_build_test.log"
set "changeConfigsCmd=windows_change_test_configs.py"
set "setOvmsVersionCmd=windows_set_ovms_version.py"
set "runTest=%cd%\bazel-bin\src\ovms_test.exe --gtest_filter=* 2>&1 | tee win_full_test.log"

:: Setting PATH environment variable based on default windows node settings: Added ovms_windows specific python settings and c:/opt and removed unused Nvidia and OCL specific tools.
Expand Down Expand Up @@ -82,6 +84,8 @@ if !errorlevel! neq 0 exit /b !errorlevel!
set > %envPath%
if !errorlevel! neq 0 exit /b !errorlevel!

:: Set ovms.exe --version parameters
%setOvmsVersionCmd% "%bazelBuildArgs%" %BAZEL_SHORT_PATH%
:: Start bazel build
%buildCommand%
if !errorlevel! neq 0 exit /b !errorlevel!
Expand Down
90 changes: 90 additions & 0 deletions windows_set_ovms_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import sys
import re
import subprocess

WIN_OV_VERSION_REGEX = re.compile(r'[0-9]{4}.[0-9].[0-9].[^_]+')
VERSION_FILE = "src\\version.hpp"
OVMS_PROJECT_VERSION="2025.0"

def help():
print("Usage:\n\
Two arguments required: BAZEL_BUILD_FLAGS PATH_TO_OPENVINO_INSTALL\n\
for example: \n\
python windows_set_ovms_version.py \"--config=windows\" c:\opt\ \n\
")

def replace_in_file(file_path, old_string, new_string):
with open(file_path, 'r+') as file:
contents = file.read()
contents = contents.replace(old_string, new_string)
file.seek(0)
file.write(contents)
file.truncate()

def get_openvino_name(openvino_dir):
openvino_name = "Unknown"
for root, dirs, files in os.walk(openvino_dir):
for dir in dirs:
matches = WIN_OV_VERSION_REGEX.findall(dir)
if len(matches) > 1:
print("[ERROR] Multiple openvino versions detected in " + os.path.join(root, dir))
exit(-1)
if len(matches) == 1:
print("[INFO] Openvino detected in " + os.path.join(root, dir))
openvino_name = matches[0]
break

# we search only 1 directory level deep
break

if openvino_name == "Unknown":
print("[WARNING] Openvino versions not detected in " + openvino_dir)

return openvino_name

def get_ovms_sha():
command = "git rev-parse --short HEAD"
output = subprocess.check_output(command, shell=True, text=True)
return output.rstrip()

def main():
if len(sys.argv) < 2:
print('Provide bazel build flags!')
help()
exit(-1)
else:
bazel_bld_flags = sys.argv[1]
print('Provided bazel build flags: ' + bazel_bld_flags)

if len(sys.argv) < 3:
print('Provide openvino directory!')
help()
exit(-1)
else:
openvino_dir = sys.argv[2]
print('Provided openvino directory: ' + openvino_dir)

openvino_name = get_openvino_name(openvino_dir)
version_file_path = os.path.join(os.getcwd(), VERSION_FILE)
replace_in_file(version_file_path, "REPLACE_PROJECT_VERSION", OVMS_PROJECT_VERSION + "." + get_ovms_sha())
replace_in_file(version_file_path, "REPLACE_OPENVINO_NAME", openvino_name)
replace_in_file(version_file_path, "REPLACE_BAZEL_BUILD_FLAGS", bazel_bld_flags)

if __name__ == '__main__':
main()