Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 685168880
  • Loading branch information
tensorflower-gardener authored and tensorflow-copybara committed Oct 12, 2024
1 parent afe660d commit d35f71f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
24 changes: 12 additions & 12 deletions tensorflow_serving/model_servers/tfrt_http_rest_api_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TFRTHttpRestApiHandler::TFRTHttpRestApiHandler(int timeout_in_ms,

TFRTHttpRestApiHandler::~TFRTHttpRestApiHandler() {}

Status TFRTHttpRestApiHandler::ProcessRequest(
absl::Status TFRTHttpRestApiHandler::ProcessRequest(
const absl::string_view http_method, const absl::string_view request_path,
const absl::string_view request_body,
std::vector<std::pair<std::string, std::string>>* headers,
Expand All @@ -72,8 +72,8 @@ Status TFRTHttpRestApiHandler::ProcessRequest(
AddHeaders(headers);

std::string model_subresource;
Status status = errors::InvalidArgument("Malformed request: ", http_method,
" ", request_path);
absl::Status status = errors::InvalidArgument(
"Malformed request: ", http_method, " ", request_path);
absl::optional<int64_t> model_version;
absl::optional<std::string> model_version_label;
bool parse_successful;
Expand Down Expand Up @@ -114,7 +114,7 @@ Status TFRTHttpRestApiHandler::ProcessRequest(
return status;
}

Status TFRTHttpRestApiHandler::ProcessClassifyRequest(
absl::Status TFRTHttpRestApiHandler::ProcessClassifyRequest(
const absl::string_view model_name,
const absl::optional<int64_t>& model_version,
const absl::optional<absl::string_view>& model_version_label,
Expand All @@ -135,10 +135,10 @@ Status TFRTHttpRestApiHandler::ProcessClassifyRequest(
TF_RETURN_IF_ERROR(servable->Classify(run_options, *request, response));
TF_RETURN_IF_ERROR(
MakeJsonFromClassificationResult(response->result(), output));
return Status();
return absl::Status();
}

Status TFRTHttpRestApiHandler::ProcessRegressRequest(
absl::Status TFRTHttpRestApiHandler::ProcessRegressRequest(
const absl::string_view model_name,
const absl::optional<int64_t>& model_version,
const absl::optional<absl::string_view>& model_version_label,
Expand All @@ -160,7 +160,7 @@ Status TFRTHttpRestApiHandler::ProcessRegressRequest(
return MakeJsonFromRegressionResult(response->result(), output);
}

Status TFRTHttpRestApiHandler::ProcessPredictRequest(
absl::Status TFRTHttpRestApiHandler::ProcessPredictRequest(
const absl::string_view model_name,
const absl::optional<int64_t>& model_version,
const absl::optional<absl::string_view>& model_version_label,
Expand Down Expand Up @@ -190,10 +190,10 @@ Status TFRTHttpRestApiHandler::ProcessPredictRequest(
TF_RETURN_IF_ERROR(servable->Predict(run_options, *request, response));

TF_RETURN_IF_ERROR(MakeJsonFromTensors(response->outputs(), format, output));
return Status();
return absl::Status();
}

Status TFRTHttpRestApiHandler::ProcessModelStatusRequest(
absl::Status TFRTHttpRestApiHandler::ProcessModelStatusRequest(
const absl::string_view model_name,
const absl::optional<int64_t>& model_version,
const absl::optional<absl::string_view>& model_version_label,
Expand All @@ -217,7 +217,7 @@ Status TFRTHttpRestApiHandler::ProcessModelStatusRequest(
return ToJsonString(*response, output);
}

Status TFRTHttpRestApiHandler::ProcessModelMetadataRequest(
absl::Status TFRTHttpRestApiHandler::ProcessModelMetadataRequest(
const absl::string_view model_name,
const absl::optional<int64_t>& model_version,
const absl::optional<absl::string_view>& model_version_label,
Expand All @@ -242,7 +242,7 @@ Status TFRTHttpRestApiHandler::ProcessModelMetadataRequest(
return ToJsonString(*response, output);
}

Status TFRTHttpRestApiHandler::GetInfoMap(
absl::Status TFRTHttpRestApiHandler::GetInfoMap(
const ModelSpec& model_spec, const std::string& signature_name,
::google::protobuf::Map<std::string, tensorflow::TensorInfo>* infomap) {
ServableHandle<Servable> servable;
Expand All @@ -257,7 +257,7 @@ Status TFRTHttpRestApiHandler::GetInfoMap(
"\" not found in signature def");
}
*infomap = iter->second.inputs();
return Status();
return absl::Status();
}

} // namespace serving
Expand Down
21 changes: 11 additions & 10 deletions tensorflow_serving/model_servers/tfrt_http_rest_api_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class TFRTHttpRestApiHandlerTest : public ::testing::Test {
TFRTHttpRestApiHandlerTest()
: handler_(/*timeout_in_ms=*/10000, GetServerCore()) {}

static Status CreateServerCore(std::unique_ptr<ServerCore>* server_core) {
static absl::Status CreateServerCore(
std::unique_ptr<ServerCore>* server_core) {
ModelServerConfig config;
auto model_config = config.mutable_model_config_list()->add_config();
model_config->set_name(kTestModelName);
Expand Down Expand Up @@ -158,7 +159,7 @@ class TFRTHttpRestApiHandlerTest : public ::testing::Test {

std::unique_ptr<ServerCore> TFRTHttpRestApiHandlerTest::server_core_;

Status CompareJson(const string& json1, const string& json2) {
absl::Status CompareJson(const string& json1, const string& json2) {
rapidjson::Document doc1;
if (doc1.Parse(json1.c_str()).HasParseError()) {
return errors::InvalidArgument(
Expand All @@ -175,7 +176,7 @@ Status CompareJson(const string& json1, const string& json2) {
return errors::InvalidArgument("JSON Different. JSON1: ", json1,
"JSON2: ", json2);
}
return Status();
return absl::Status();
}

TEST_F(TFRTHttpRestApiHandlerTest, kPathRegex) {
Expand All @@ -187,7 +188,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, kPathRegex) {
TEST_F(TFRTHttpRestApiHandlerTest, UnsupportedApiCalls) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
status = handler_.ProcessRequest("GET", "/v1/foo", "", &headers, &model_name,
&method, &output);
EXPECT_TRUE(errors::IsInvalidArgument(status));
Expand Down Expand Up @@ -264,7 +265,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, UnsupportedApiCalls) {
TEST_F(TFRTHttpRestApiHandlerTest, PredictModelNameVersionErrors) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
// 'foo' is not a valid model name.
status = handler_.ProcessRequest("POST", "/v1/models/foo:predict",
R"({ "instances": [1] })", &headers,
Expand All @@ -287,7 +288,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, PredictModelNameVersionErrors) {
TEST_F(TFRTHttpRestApiHandlerTest, PredictRequestErrors) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
const string& req_path =
absl::StrCat("/v1/models/", kTestModelName, ":predict");

Expand Down Expand Up @@ -334,7 +335,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, PredictRequestErrors) {
TEST_F(TFRTHttpRestApiHandlerTest, Predict) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
// Query latest version.
TF_EXPECT_OK(handler_.ProcessRequest(
"POST", absl::StrCat("/v1/models/", kTestModelName, ":predict"),
Expand Down Expand Up @@ -391,7 +392,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, Predict) {
TEST_F(TFRTHttpRestApiHandlerTest, Regress) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
// Query latest version.
TF_EXPECT_OK(handler_.ProcessRequest(
"POST", absl::StrCat("/v1/models/", kTestModelName, ":regress"),
Expand Down Expand Up @@ -427,7 +428,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, Regress) {
TEST_F(TFRTHttpRestApiHandlerTest, Classify) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;
// Query latest version.
TF_EXPECT_OK(handler_.ProcessRequest(
"POST", absl::StrCat("/v1/models/", kTestModelName, ":classify"),
Expand All @@ -452,7 +453,7 @@ TEST_F(TFRTHttpRestApiHandlerTest, Classify) {
TEST_F(TFRTHttpRestApiHandlerTest, GetStatus) {
HeaderList headers;
string model_name, method, output;
Status status;
absl::Status status;

// Get status for all versions.
TF_EXPECT_OK(handler_.ProcessRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ::grpc::Status TfrtPredictionServiceImpl::Predict(
::grpc::Status TfrtPredictionServiceImpl::GetModelMetadata(
::grpc::ServerContext *context, const GetModelMetadataRequest *request,
GetModelMetadataResponse *response) {
const ::tensorflow::Status tf_status =
const absl::Status tf_status =
TFRTGetModelMetadataImpl::GetModelMetadata(core_, *request, response);
const ::grpc::Status status = ToGRPCStatus(tf_status);
if (!status.ok()) {
Expand Down

0 comments on commit d35f71f

Please sign in to comment.