diff --git a/Dockerfile.redhat b/Dockerfile.redhat index b04ce3b1a9..043e1e736f 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -243,6 +243,7 @@ RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; \ cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_CXX_FLAGS=" ${SDL_OPS} ${LTO_CXX_FLAGS} " -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_SYSTEM_ICU="True" -DBUILD_TOKENIZERS=OFF -DENABLE_SAMPLES=OFF -DENABLE_TOOLS=OFF -DENABLE_TESTS=OFF -DENABLE_XGRAMMAR=ON -S ./ -B ./build/ ; \ cmake --build ./build/ --parallel $JOBS && cp /openvino_genai/build/openvino_genai/lib*.so* /opt/intel/openvino/runtime/lib/intel64/ ; \ cp -r /openvino_genai/src/cpp/include/* /opt/intel/openvino/runtime/include/ ; \ + cp /openvino_genai/build/src/cpp/openvino/genai/version.hpp /opt/intel/openvino/runtime/include/openvino/genai/ ; \ if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \ cp -r /openvino_genai/build/openvino_genai/*py* /opt/intel/openvino/python/ ; \ fi @@ -306,8 +307,6 @@ ARG minitrace_flags # Set OVMS version strings 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" # Custom Nodes @@ -336,7 +335,7 @@ RUN /ovms/bazel-bin/src/ovms --version && /ovms/bazel-bin/src/ovms COPY release_files/thirdparty-licenses/ /ovms/release_files/thirdparty-licenses/ COPY release_files/LICENSE /ovms/release_files/LICENSE COPY client /client -RUN python3.12 -c "import json; m={'PROJECT_VERSION':'${PROJECT_VERSION}','OPENVINO backend':'$(/ovms/bazel-bin/src/ovms --version | grep backend | cut -d' ' -f3)', \ +RUN python3.12 -c "import json; m={'PROJECT_VERSION':'${PROJECT_VERSION}','OPENVINO backend':'$(/ovms/bazel-bin/src/ovms --version | grep 'OpenVINO backend' | cut -d' ' -f3)', \ 'BAZEL_BUILD_FLAGS':'${debug_bazel_flags}${minitrace_flags}}','BASE_IMAGE':'${BASE_IMAGE}' }; \ print(json.dumps(m,indent=4))" > /ovms/release_files/metadata.json diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 4a212ba959..f3883cf986 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -229,6 +229,7 @@ RUN if [ "$ov_use_binary" == "0" ]; then \ cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_CXX_FLAGS="${SDL_OPS}" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_SYSTEM_ICU="True" -DBUILD_TOKENIZERS=OFF -DENABLE_SAMPLES=OFF -DENABLE_TOOLS=OFF -DENABLE_TESTS=OFF -DENABLE_XGRAMMAR=ON -S ./ -B ./build/ ; \ cmake --build ./build/ --parallel $JOBS && cp /openvino_genai/build/openvino_genai/lib*.so* /opt/intel/openvino/runtime/lib/intel64/ ; \ cp -r /openvino_genai/src/cpp/include/* /opt/intel/openvino/runtime/include/ ; \ + cp /openvino_genai/build/src/cpp/openvino/genai/version.hpp /opt/intel/openvino/runtime/include/openvino/genai/ ; \ if ! [[ $debug_bazel_flags == *"py_off"* ]]; then \ cp -r /openvino_genai/build/openvino_genai/*py* /opt/intel/openvino/python/ ; \ fi ; \ @@ -301,8 +302,6 @@ 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_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" WORKDIR /patchelf @@ -337,7 +336,7 @@ RUN if [ "$FUZZER_BUILD" == "0" ]; then /ovms/bazel-bin/src/ovms --version && /o COPY release_files/thirdparty-licenses/ /ovms/release_files/thirdparty-licenses/ COPY release_files/LICENSE /ovms/release_files/LICENSE COPY client /client -RUN python3 -c "import json; m={'PROJECT_VERSION':'${PROJECT_VERSION}','OPENVINO backend':'$(/ovms/bazel-bin/src/ovms --version | grep backend | cut -d' ' -f3)', \ +RUN python3 -c "import json; m={'PROJECT_VERSION':'${PROJECT_VERSION}','OPENVINO backend':'$(/ovms/bazel-bin/src/ovms --version | grep 'OpenVINO backend' | cut -d' ' -f3)', \ 'BAZEL_BUILD_FLAGS':'${debug_bazel_flags}${minitrace_flags}','BASE_IMAGE':'${BASE_IMAGE}' }; \ print(json.dumps(m,indent=4))" > /ovms/release_files/metadata.json # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # diff --git a/src/BUILD b/src/BUILD index 71321ca7ee..d3e5af3861 100644 --- a/src/BUILD +++ b/src/BUILD @@ -255,7 +255,7 @@ ovms_cc_library( name = "libovms_version", hdrs = ["version.hpp"], srcs = [], - deps = [], + deps = ["//third_party:openvino",], visibility = ["//visibility:public",], ) ovms_cc_library( diff --git a/src/capi_frontend/capi.cpp b/src/capi_frontend/capi.cpp index 6bdc385c2a..521c86ae17 100644 --- a/src/capi_frontend/capi.cpp +++ b/src/capi_frontend/capi.cpp @@ -334,7 +334,9 @@ DLL_PUBLIC OVMS_Status* OVMS_ServerMetadata(OVMS_Server* server, OVMS_Metadata** doc->SetObject(); doc->AddMember("name", PROJECT_NAME, doc->GetAllocator()); doc->AddMember("version", PROJECT_VERSION, doc->GetAllocator()); - doc->AddMember("ov_version", OPENVINO_NAME, doc->GetAllocator()); + rapidjson::Value ovVersion; + ovVersion.SetString(OPENVINO_NAME, doc->GetAllocator()); + doc->AddMember("ov_version", std::move(ovVersion), doc->GetAllocator()); *metadata = reinterpret_cast(doc); return nullptr; } diff --git a/src/cli_parser.cpp b/src/cli_parser.cpp index d0c0d89634..dd7141b1ce 100644 --- a/src/cli_parser.cpp +++ b/src/cli_parser.cpp @@ -57,7 +57,7 @@ std::variant> CLIParser::parse(int argc, char* std::stringstream ss; try { options = std::make_unique(argv[0], "OpenVINO Model Server"); - auto configOptions = std::make_unique("ovms --model_name --add_to_config --model_repository_path \n ovms --model_path --model_name --add_to_config \n ovms --remove_from_config --model_name ", "config management commands:"); + auto configOptions = std::make_unique("ovms --model_name --add_to_config --config_path --model_repository_path \n ovms --model_path --model_name --add_to_config --config_path \n ovms --remove_from_config --config_path --model_name ", "config management commands:"); // Adding this option to parse unrecognised options in another parser options->allow_unrecognised_options(); @@ -444,6 +444,7 @@ std::variant> CLIParser::parse(int argc, char* std::string project_version(PROJECT_VERSION); ss << project_name + " " + project_version << std::endl; ss << "OpenVINO backend " << OPENVINO_NAME << std::endl; + ss << "OpenVINO GenAI backend " << GENAI_NAME << std::endl; ss << "Bazel build flags: " << BAZEL_BUILD_FLAGS << std::endl; #pragma warning(pop) return std::make_pair(OVMS_EX_OK, ss.str()); diff --git a/src/version.hpp b/src/version.hpp index fbebc03710..d45581aba2 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -13,10 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. //***************************************************************************** + +#include +#include + #ifndef SRC_VERSION_HPP_ #define SRC_VERSION_HPP_ #define PROJECT_NAME "OpenVINO Model Server" #define PROJECT_VERSION "REPLACE_PROJECT_VERSION" -#define OPENVINO_NAME "REPLACE_OPENVINO_NAME" +#define OPENVINO_NAME ov::get_openvino_version().buildNumber +#define GENAI_NAME ov::genai::get_version().buildNumber #define BAZEL_BUILD_FLAGS "REPLACE_BAZEL_BUILD_FLAGS" -#endif // SRC_VERSION_HPP_" +#endif // SRC_VERSION_HPP_ diff --git a/windows_install_build_dependencies.bat b/windows_install_build_dependencies.bat index 30bae830b9..5e3bc0058a 100644 --- a/windows_install_build_dependencies.bat +++ b/windows_install_build_dependencies.bat @@ -248,6 +248,7 @@ git checkout %OV_SOURCE_BRANCH% if !errorlevel! neq 0 exit /b !errorlevel! git submodule update --init --recursive if !errorlevel! neq 0 exit /b !errorlevel! +git pull --recurse-submodules IF /I NOT EXIST build ( mkdir build ) @@ -271,6 +272,7 @@ cd %BAZEL_SHORT_PATH%\openvino_tokenizers_src git fetch origin git checkout %TOKENIZER_SOURCE_BRANCH% if !errorlevel! neq 0 exit /b !errorlevel! +git pull --recurse-submodules IF /I NOT EXIST build ( mkdir build ) @@ -292,6 +294,7 @@ cd %BAZEL_SHORT_PATH%\openvino_genai_src git fetch origin git checkout %GENAI_SOURCE_BRANCH% if !errorlevel! neq 0 exit /b !errorlevel! +git pull --recurse-submodules IF /I NOT EXIST build ( mkdir build ) @@ -302,6 +305,8 @@ cmake --build . --config Release --verbose -j if !errorlevel! neq 0 exit /b !errorlevel! cmake --install . --config Release --prefix %BAZEL_SHORT_PATH%\openvino if !errorlevel! neq 0 exit /b !errorlevel! +copy src\cpp\openvino\genai\version.hpp %BAZEL_SHORT_PATH%\openvino\runtime\include\openvino\genai\ +if !errorlevel! neq 0 exit /b !errorlevel! echo [INFO] OpenVINO from source installed: %BAZEL_SHORT_PATH%\openvino cd !BACK_CWD! diff --git a/windows_set_ovms_version.py b/windows_set_ovms_version.py index b31be99f8a..744b344296 100644 --- a/windows_set_ovms_version.py +++ b/windows_set_ovms_version.py @@ -42,26 +42,7 @@ def replace_in_file(file_path, old_string, new_string): file.seek(0) file.write(contents) file.truncate() - -def get_openvino_name_bin(openvino_dir): - openvino_name = "Unknown" - # read file openvino_dir\openvino\runtime\version.txt - version_file_path = os.path.join(openvino_dir, "openvino", "runtime", "version.txt") - if os.path.exists(version_file_path): - with open(version_file_path, 'r') as version_file: - for line in version_file: - match = WIN_OV_VERSION_REGEX.search(line) - if match: - openvino_name = line.strip('\n') - break - return openvino_name - -def get_openvino_name_src(openvino_dir): - src_dir = os.path.join(openvino_dir, "openvino_src") - # get version using git - command = "git -C {} rev-parse --short HEAD".format(src_dir) - output = subprocess.check_output(command, shell=True, text=True) - return output.rstrip() + def get_ovms_sha(): command = "git rev-parse --short HEAD" output = subprocess.check_output(command, shell=True, text=True) @@ -88,15 +69,9 @@ def main(): openvino_dir = sys.argv[2] print('Provided openvino directory: ' + openvino_dir) - if os.environ.get('OV_USE_BINARY', '1') == '1': - print('Getting openvino version from binary package') - openvino_name = get_openvino_name_bin(openvino_dir) - else: - openvino_name = get_openvino_name_src(openvino_dir) - print('Using openvino source build, setting version to ' + openvino_name) + version_file_path = os.path.join(os.getcwd(), VERSION_FILE) replace_in_file(version_file_path, "REPLACE_PROJECT_VERSION", check_get_product_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__':