diff --git a/CHANGELOG.md b/CHANGELOG.md index abbed24..7234427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ > please add your unreleased change here. +## 20240524 - 0.3.1b0 + +- [Bugfix] fix tree predict base score miss +- [Bugfix] fix http adapater error msg format failed + ## 20240423 - 0.3.0b0 - [Feature] Add Trace function diff --git a/secretflow_serving/feature_adapter/http_adapter.cc b/secretflow_serving/feature_adapter/http_adapter.cc index a5c379d..c077026 100644 --- a/secretflow_serving/feature_adapter/http_adapter.cc +++ b/secretflow_serving/feature_adapter/http_adapter.cc @@ -147,7 +147,7 @@ void HttpFeatureAdapter::OnFetchFeature(const Request& request, SetSpanAttrs(span, span_option); SERVING_ENFORCE(span_option.code == errors::ErrorCode::OK, span_option.code, - span_option.msg); + "{}", span_option.msg); response->header->mutable_data()->swap( *spi_response.mutable_header()->mutable_data()); response->features = diff --git a/secretflow_serving/framework/execute_context.cc b/secretflow_serving/framework/execute_context.cc index e221b9d..87e3675 100644 --- a/secretflow_serving/framework/execute_context.cc +++ b/secretflow_serving/framework/execute_context.cc @@ -26,10 +26,9 @@ void ExecuteContext::CheckAndUpdateResponse() { void ExecuteContext::CheckAndUpdateResponse( const apis::ExecuteResponse& exec_res) { if (!CheckStatusOk(exec_res.status())) { - SERVING_THROW( - exec_res.status().code(), - fmt::format("{} exec failed: code({}), {}", target_id_, - exec_res.status().code(), exec_res.status().msg())); + SERVING_THROW(exec_res.status().code(), "{} exec failed: code({}), {}", + target_id_, exec_res.status().code(), + exec_res.status().msg()); } MergeResonseHeader(exec_res); } diff --git a/secretflow_serving/framework/execute_context.h b/secretflow_serving/framework/execute_context.h index 8150670..adbcb55 100644 --- a/secretflow_serving/framework/execute_context.h +++ b/secretflow_serving/framework/execute_context.h @@ -209,7 +209,7 @@ class RemoteExecute : public ExecuteBase, if (span_option.code == errors::ErrorCode::OK) { exec_ctx_.MergeResonseHeader(); } else { - SERVING_THROW(span_option.code, span_option.msg); + SERVING_THROW(span_option.code, "{}", span_option.msg); } } diff --git a/secretflow_serving/ops/tree_ensemble_predict.cc b/secretflow_serving/ops/tree_ensemble_predict.cc index be32b57..0ec1c15 100644 --- a/secretflow_serving/ops/tree_ensemble_predict.cc +++ b/secretflow_serving/ops/tree_ensemble_predict.cc @@ -40,6 +40,9 @@ TreeEnsemblePredict::TreeEnsemblePredict(OpKernelOptions opts) GetNodeAttr(opts_.node_def, *opts_.op_def, "algo_func"); func_type_ = ParseLinkFuncType(func_type_str); + base_score_ = + GetNodeAttr(opts_.node_def, *opts_.op_def, "base_score"); + BuildInputSchema(); BuildOutputSchema(); } @@ -65,7 +68,8 @@ void TreeEnsemblePredict::DoCompute(ComputeContext* ctx) { arrow::DoubleBuilder builder; SERVING_CHECK_ARROW_STATUS(builder.Resize(merged_array->length())); for (int64_t i = 0; i < merged_array->length(); ++i) { - auto score = ApplyLinkFunc(merged_array->Value(i), func_type_); + auto score = merged_array->Value(i) + base_score_; + score = ApplyLinkFunc(score, func_type_); SERVING_CHECK_ARROW_STATUS(builder.Append(score)); } std::shared_ptr res_array; @@ -90,7 +94,7 @@ void TreeEnsemblePredict::BuildOutputSchema() { } REGISTER_OP_KERNEL(TREE_ENSEMBLE_PREDICT, TreeEnsemblePredict) -REGISTER_OP(TREE_ENSEMBLE_PREDICT, "0.0.1", +REGISTER_OP(TREE_ENSEMBLE_PREDICT, "0.0.2", "Accept the weighted results from multiple trees (`TREE_SELECT` + " "`TREE_MERGE`), merge them, and obtain the final prediction result " "of the tree ensemble.") @@ -101,6 +105,8 @@ REGISTER_OP(TREE_ENSEMBLE_PREDICT, "0.0.1", .StringAttr("output_col_name", "The column name of tree ensemble predict score", false, false) .Int32Attr("num_trees", "The number of ensemble's tree", false, false) + .DoubleAttr("base_score", "The initial prediction score, global bias.", + false, true, 0.0) .StringAttr( "algo_func", "Optional value: " diff --git a/secretflow_serving/ops/tree_ensemble_predict.h b/secretflow_serving/ops/tree_ensemble_predict.h index 7d250f9..58f1b5a 100644 --- a/secretflow_serving/ops/tree_ensemble_predict.h +++ b/secretflow_serving/ops/tree_ensemble_predict.h @@ -37,6 +37,8 @@ class TreeEnsemblePredict : public OpKernel { int32_t num_trees_; LinkFunctionType func_type_; + + double base_score_ = 0.0; }; } // namespace secretflow::serving::op diff --git a/secretflow_serving/ops/tree_ensemble_predict_test.cc b/secretflow_serving/ops/tree_ensemble_predict_test.cc index aef5b60..1adf4bf 100644 --- a/secretflow_serving/ops/tree_ensemble_predict_test.cc +++ b/secretflow_serving/ops/tree_ensemble_predict_test.cc @@ -47,6 +47,9 @@ TEST_P(TreeEnsemblePredictParamTest, Works) { }, "output_col_name": { "s": "scores" + }, + "base_score": { + "d": 0.1 } } } @@ -96,6 +99,7 @@ TEST_P(TreeEnsemblePredictParamTest, Works) { for (size_t col = 1; col < param.tree_weights.size(); ++col) { score += param.tree_weights[col][row]; } + score += 0.1; SERVING_CHECK_ARROW_STATUS(expect_res_builder.Append( ApplyLinkFunc(score, ParseLinkFuncType(param.algo_func)))); } diff --git a/secretflow_serving_lib/version.py b/secretflow_serving_lib/version.py index 482974b..ef51f6d 100644 --- a/secretflow_serving_lib/version.py +++ b/secretflow_serving_lib/version.py @@ -13,4 +13,4 @@ # limitations under the License. -__version__ = "0.3.0b0" +__version__ = "0.3.1b0" diff --git a/version.txt b/version.txt index 482974b..ef51f6d 100644 --- a/version.txt +++ b/version.txt @@ -13,4 +13,4 @@ # limitations under the License. -__version__ = "0.3.0b0" +__version__ = "0.3.1b0"