Skip to content

Add list live model names endpoint #1552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tensorflow_serving/apis/get_model_status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ message GetModelStatusRequest {
ModelSpec model_spec = 1;
}

//request to get all live model names
message ListModelNamesRequest{
}

//response contains all live model names
message ListModelNamesResponse{
repeated string model_names = 1;
}


// Version number, state, and status for a single version of a model.
message ModelVersionStatus {
// Model version.
Expand Down
3 changes: 3 additions & 0 deletions tensorflow_serving/apis/model_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ service ModelService {
// longer served.
rpc HandleReloadConfigRequest(ReloadConfigRequest)
returns (ReloadConfigResponse);

// Lists the live model names
rpc ListModelNames(ListModelNamesRequest) returns (ListModelNamesResponse);
}
17 changes: 17 additions & 0 deletions tensorflow_serving/model_servers/get_model_status_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ void AddModelVersionStatusToResponse(GetModelStatusResponse* response,

} // namespace

// Add model name to ListModelNamesResponse
void AddModelNameToResponse(ListModelNamesResponse* response,
const string& name){
response->add_model_names(name);
}

Status GetModelStatusImpl::GetModelStatus(ServerCore* core,
const GetModelStatusRequest& request,
GetModelStatusResponse* response) {
Expand Down Expand Up @@ -106,5 +112,16 @@ Status GetModelStatusImpl::GetModelStatusWithModelSpec(
return tensorflow::Status::OK();
}

Status GetModelStatusImpl::ListModelNames(ServerCore* core,
const ListModelNamesRequest& request,
ListModelNamesResponse* response) {

const ServableStateMonitor& monitor = *core->servable_state_monitor();
for(const auto& servable: monitor.GetAllServableStates()) {
AddModelNameToResponse(response, servable.first);
}
return tensorflow::Status::OK();
}

} // namespace serving
} // namespace tensorflow
6 changes: 5 additions & 1 deletion tensorflow_serving/model_servers/get_model_status_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ class GetModelStatusImpl {
static Status GetModelStatusWithModelSpec(
ServerCore* core, const ModelSpec& model_spec,
const GetModelStatusRequest& request, GetModelStatusResponse* response);
};

// List all live model names
static Status ListModelNames(ServerCore* core,
const ListModelNamesRequest& request,
ListModelNamesResponse* response);
};
} // namespace serving
} // namespace tensorflow

Expand Down
11 changes: 11 additions & 0 deletions tensorflow_serving/model_servers/get_model_status_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ TEST_F(GetModelStatusImplTest, SingleVersionSuccess) {
EXPECT_EQ("", response.model_version_status(0).status().error_message());
}

TEST_F(GetModelStatusImplTest, Success) {
ListModelsRequest request;
ListModelsResponse response;
// If two versions of model are managed by ServerCore, succesfully get model
// status for both versions of the model.
TF_EXPECT_OK(
GetModelStatusImpl::ListModels(GetServerCore(), request, &response)
);
EXPECT_EQ(1, response.model_names_size());
}

// Verifies that GetModelStatusWithModelSpec() uses the model spec override
// rather than the one in the request.
TEST_F(GetModelStatusImplTest, ModelSpecOverride) {
Expand Down