Add version and latest commit id to ONNX Runtime Server (#1078)

* Add version and latest commit id to ORT Server

* Update cmake

* Change build id to build number

* Use target_compile_definitions instead of add_definitions
This commit is contained in:
Klein Hu 2019-05-24 17:30:40 -07:00 committed by Pranav Sharma
parent ea29a664cd
commit b54a292ba2
3 changed files with 41 additions and 1 deletions

View file

@ -108,6 +108,14 @@ if(NOT WIN32)
endif()
endif()
set(onnxruntime_SERVER_VERSION "local-build" CACHE STRING "Sever version")
target_compile_definitions(${SERVER_APP_NAME} PUBLIC SRV_VERSION="${onnxruntime_SERVER_VERSION}")
message(STATUS "ONNX Runtime Server version set to: ${onnxruntime_SERVER_VERSION}")
set(onnxruntime_LATEST_COMMIT_ID "default" CACHE STRING "The latest commit id")
target_compile_definitions(${SERVER_APP_NAME} PUBLIC LATEST_COMMIT_ID="${onnxruntime_LATEST_COMMIT_ID}")
message(STATUS "ONNX Runtime Server latest commit id is: ${onnxruntime_LATEST_COMMIT_ID}")
onnxruntime_add_include_to_target(${SERVER_APP_NAME} onnxruntime_session onnxruntime_server_lib gsl onnx onnx_proto server_proto)
target_include_directories(${SERVER_APP_NAME} PRIVATE

View file

@ -6,11 +6,43 @@
#include "predict_request_handler.h"
#include "server_configuration.h"
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
#define LOCAL_BUILD_VERSION "local_build"
#if !defined(SRV_VERSION)
#define SRV_VERSION LOCAL_BUILD_VERSION
#endif
#pragma message(VAR_NAME_VALUE(SRV_VERSION))
#define DEFAULT_COMMIT_ID "default"
#if !defined(LATEST_COMMIT_ID)
#define LATEST_COMMIT_ID DEFAULT_COMMIT_ID
#endif
#pragma message(VAR_NAME_VALUE(LATEST_COMMIT_ID))
namespace beast = boost::beast;
namespace http = beast::http;
namespace server = onnxruntime::server;
int main(int argc, char* argv[]) {
// Here we use std::cout print out the version and latest commit id,
// to make sure in case even logger has problem, we still have the version information and commit id.
std::string version = SRV_VERSION;
if (version.empty()){
version = LOCAL_BUILD_VERSION;
}
std::string commit_id = LATEST_COMMIT_ID;
if (commit_id.empty()){
commit_id = DEFAULT_COMMIT_ID;
}
std::cout << "Version: " << version << std::endl;
std::cout << "Commit ID: " << commit_id << std::endl;
std::cout << std::endl;
server::ServerConfiguration config{};
auto res = config.ParseInput(argc, argv);

View file

@ -30,7 +30,7 @@ jobs:
pythonInterpreter: '/usr/bin/python3'
workingDirectory: $(Build.BinariesDirectory)
- script: 'tools/ci_build/github/linux/run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -x "--config Debug --build_server --use_openmp --use_full_protobuf --enable_server_model_tests"'
- script: 'tools/ci_build/github/linux/run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -x "--config RelWithDebInfo --build_server --use_openmp --use_full_protobuf --enable_server_model_tests --cmake_extra_defines onnxruntime_SERVER_VERSION=$(cat ./VERSION_NUMBER)-$(Build.BuildNumber) onnxruntime_LATEST_COMMIT_ID=$(Build.SourceVersion)"'
displayName: 'Run build script with model tests'
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0