diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d48c1f1c2ff527e92ce5de304b134a8d2f45d6f..b1aca9f8175829f5e9846d5087ef0fccd0371c8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER}, version: " message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: " "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") - + find_package(Git REQUIRED) find_package(Threads REQUIRED) find_package(CUDA QUIET) @@ -62,17 +62,20 @@ if (NOT DEFINED WITH_MKLDNN) endif() endif() +if (NOT CLIENT_ONLY) include(external/jsoncpp) -include(external/leveldb) include(external/rocksdb) +include(external/gtest) +endif() + +include(external/snappy) +include(external/leveldb) include(external/zlib) include(external/boost) include(external/protobuf) include(external/brpc) include(external/gflags) include(external/glog) -include(external/snappy) -include(external/gtest) include(external/pybind11) include(external/python) include(generic) @@ -87,36 +90,54 @@ endif() include_directories(${PADDLE_SERVING_SOURCE_DIR}) include_directories(${PADDLE_SERVING_BINARY_DIR}) +if(NOT CLIENT_ONLY) + set(EXTERNAL_LIBS + jsoncpp + gflags + rocksdb + glog + protobuf + paddlepaddle + brpc) +endif() + set(EXTERNAL_LIBS - jsoncpp - gflags - rocksdb - glog - protobuf - paddlepaddle - brpc + gflags + glog + protobuf + brpc ) +if(NOT CLIENT_ONLY) if(WITH_MKLML) list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB}) endif() +endif() +if(NOT CLIENT_ONLY) if(WITH_MKLDNN) list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB}) endif() +endif() if (NOT CLIENT_ONLY) list(APPEND EXTERNAL_LIBS paddlepaddle) list(APPEND EXTERNAL_LIBS opencv) endif() +if(NOT CLIENT_ONLY) add_subdirectory(cube) +add_subdirectory(demo-client) +add_subdirectory(kvdb) +endif() add_subdirectory(configure) add_subdirectory(pdcodegen) add_subdirectory(sdk-cpp) -add_subdirectory(demo-client) -add_subdirectory(kvdb) +if(CLIENT_ONLY) +add_subdirectory(general-client) +add_subdirectory(python) +endif() if (NOT CLIENT_ONLY) add_subdirectory(predictor) @@ -128,6 +149,8 @@ add_subdirectory(demo-serving) endif() # Paddle Serving Solutions +if(NOT CLIENT_ONLY) if (WITH_ELASTIC_CTR) add_subdirectory(elastic-ctr) endif() +endif() diff --git a/configure/CMakeLists.txt b/configure/CMakeLists.txt index 19e1e8f01d76bb09e81324944c8d968262a2b458..0f7271b1452144353c8b239989927ea2e9e16138 100644 --- a/configure/CMakeLists.txt +++ b/configure/CMakeLists.txt @@ -26,3 +26,12 @@ install(FILES ${CMAKE_CURRENT_LIST_DIR}/include/configure_parser.h FILE(GLOB inc ${CMAKE_CURRENT_BINARY_DIR}/*.pb.h) install(FILES ${inc} DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/include/configure) + +py_proto_compile(sdk_configure_py_proto SRCS proto/sdk_configure.proto) +add_custom_target(sdk_configure_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py) +add_dependencies(sdk_configure_py_proto sdk_configure_py_proto_init) +add_custom_command(TARGET sdk_configure_py_proto POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/proto + COMMAND cp *.py ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/proto + COMMENT "Copy generated python proto into directory paddle_serving/proto." + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/configure/proto/sdk_configure.proto b/configure/proto/sdk_configure.proto index 7658a9b609a50cdc90b70b85198086293bf19dc4..83099daf1fcfef8e3ae6564d1aa78f637253d0d6 100644 --- a/configure/proto/sdk_configure.proto +++ b/configure/proto/sdk_configure.proto @@ -16,27 +16,27 @@ syntax = "proto2"; package baidu.paddle_serving.configure; message ConnectionConf { - required int32 connect_timeout_ms = 1; - required int32 rpc_timeout_ms = 2; - required int32 connect_retry_count = 3; - required int32 max_connection_per_host = 4; - required int32 hedge_request_timeout_ms = 5; - required int32 hedge_fetch_retry_count = 6; - required string connection_type = 7; + required int32 connect_timeout_ms = 1 [default = 2000]; + required int32 rpc_timeout_ms = 2 [default = 20000]; + required int32 connect_retry_count = 3 [default = 2]; + required int32 max_connection_per_host = 4 [default = 100]; + required int32 hedge_request_timeout_ms = 5 [default = -1]; + required int32 hedge_fetch_retry_count = 6 [default = 2]; + required string connection_type = 7 [default = "pooled"]; }; message NamingConf { - optional string cluster_filter_strategy = 1; - optional string load_balance_strategy = 2; + optional string cluster_filter_strategy = 1 [default="Default"]; + optional string load_balance_strategy = 2 [default = "la"]; optional string cluster = 3; }; message RpcParameter { // 0-NONE, 1-SNAPPY, 2-GZIP, 3-ZLIB, 4-LZ4 - required int32 compress_type = 1; - required int32 package_size = 2; - required string protocol = 3; - required int32 max_channel_per_request = 4; + required int32 compress_type = 1 [default = 0]; + required int32 package_size = 2 [default = 20]; + required string protocol = 3 [default = "baidu_std"]; + required int32 max_channel_per_request = 4 [default = 3]; }; message SplitConf { @@ -53,12 +53,12 @@ message VariantConf { optional string variant_router = 6; }; -message WeightedRandomRenderConf { required string variant_weight_list = 1; }; +message WeightedRandomRenderConf { required string variant_weight_list = 1 [default= "50" ]; }; message Predictor { - required string name = 1; - required string service_name = 2; - required string endpoint_router = 3; + required string name = 1 [default="general_model"]; + required string service_name = 2 [default="baidu.paddle_serving.predictor.general_model.GeneralModelService"]; + required string endpoint_router = 3 [default="WeightedRandomRender"]; required WeightedRandomRenderConf weighted_random_render_conf = 4; repeated VariantConf variants = 5; }; diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 83676bd1f52810098d898763bc917c247c38eae7..0a89d9180ab2ef47ff48e3625b14d49307d66b3c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -17,7 +17,7 @@ add_custom_command( COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel DEPENDS ${SERVING_CLIENT_CORE} sdk_configure_py_proto ${PY_FILES}) -add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp) +add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINARY_DIR}/.timestamp) set(SERVING_CLIENT_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/) diff --git a/python/paddle_serving/serving_client/__init__.py b/python/paddle_serving/serving_client/__init__.py index 404dde2a6ecf056702a3dc7cf45d3036909f292c..c113dd9a05dc101fd506f7322309cbf8113a5c4f 100644 --- a/python/paddle_serving/serving_client/__init__.py +++ b/python/paddle_serving/serving_client/__init__.py @@ -34,7 +34,7 @@ class SDKConfig(object): variant_desc = sdk.VariantConf() variant_desc.tag = "var1" - variant_desc.naming_conf.cluster = "list://%s".format(":".join(self.endpoints)) + variant_desc.naming_conf.cluster = "list://{}".format(":".join(self.endpoints)) predictor_desc.variants.extend([variant_desc])