Skip to content

Commit

Permalink
Rename ModelConfigManager -> ModelRepositoryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
David Goodwin committed Nov 19, 2018
1 parent f3a812c commit 4a0f636
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 56 deletions.
10 changes: 5 additions & 5 deletions src/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ cc_library(
)

cc_library(
name = "model_config_manager",
srcs = ["model_config_manager.cc"],
hdrs = ["model_config_manager.h"],
name = "model_repository_manager",
srcs = ["model_repository_manager.cc"],
hdrs = ["model_repository_manager.h"],
deps = [
":constants",
":logging",
Expand Down Expand Up @@ -255,8 +255,8 @@ cc_library(
":infer_header",
":logging",
":model_config",
":model_config_manager",
":model_config_proto",
":model_repository_manager",
":profile",
":request_status",
":request_status_proto",
Expand Down Expand Up @@ -287,8 +287,8 @@ cc_library(
name = "server_status_header",
hdrs = ["server_status.h"],
deps = [
":model_config_manager",
":model_config_proto",
":model_repository_manager",
":server_status_proto",
"@org_tensorflow//tensorflow/core:lib",
"@tf_serving//tensorflow_serving/core:servable_state_monitor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"

#include "src/core/constants.h"
#include "src/core/logging.h"
Expand All @@ -36,27 +36,27 @@

namespace nvidia { namespace inferenceserver {

ModelConfigManager*
ModelConfigManager::GetSingleton()
ModelRepositoryManager*
ModelRepositoryManager::GetSingleton()
{
static ModelConfigManager singleton;
static ModelRepositoryManager singleton;
return &singleton;
}

tensorflow::Status
ModelConfigManager::GetModelConfig(
ModelRepositoryManager::GetModelConfig(
const std::string& name, ModelConfig* model_config)
{
ModelConfigManager* singleton = GetSingleton();
ModelRepositoryManager* singleton = GetSingleton();
std::lock_guard<std::mutex> lock(singleton->mu_);
return singleton->GetModelConfigInternal(name, model_config);
}

tensorflow::Status
ModelConfigManager::GetModelConfigPlatform(
ModelRepositoryManager::GetModelPlatform(
const std::string& name, Platform* platform)
{
ModelConfigManager* singleton = GetSingleton();
ModelRepositoryManager* singleton = GetSingleton();
std::lock_guard<std::mutex> lock(singleton->mu_);

// Lazily initialize the platform map...
Expand All @@ -79,17 +79,17 @@ ModelConfigManager::GetModelConfigPlatform(
}

tensorflow::Status
ModelConfigManager::SetModelConfigs(const ModelConfigMap& model_configs)
ModelRepositoryManager::SetModelConfigs(const ModelConfigMap& model_configs)
{
ModelConfigManager* singleton = GetSingleton();
ModelRepositoryManager* singleton = GetSingleton();
std::lock_guard<std::mutex> lock(singleton->mu_);
singleton->configs_ = model_configs;
singleton->platforms_.clear();
return tensorflow::Status::OK();
}

tensorflow::Status
ModelConfigManager::ReadModelConfigs(
ModelRepositoryManager::ReadModelConfigs(
const std::string& model_store_path, const bool autofill,
ModelConfigMap* model_configs, tfs::ModelServerConfig* tfs_model_configs)
{
Expand Down Expand Up @@ -175,11 +175,11 @@ ModelConfigManager::ReadModelConfigs(
}

bool
ModelConfigManager::CompareModelConfigs(
ModelRepositoryManager::CompareModelConfigs(
const ModelConfigMap& next, std::set<std::string>* added,
std::set<std::string>* removed)
{
ModelConfigManager* singleton = GetSingleton();
ModelRepositoryManager* singleton = GetSingleton();
std::lock_guard<std::mutex> lock(singleton->mu_);

std::set<std::string> current_names, next_names;
Expand All @@ -206,7 +206,7 @@ ModelConfigManager::CompareModelConfigs(
}

tensorflow::Status
ModelConfigManager::GetModelConfigInternal(
ModelRepositoryManager::GetModelConfigInternal(
const std::string& name, ModelConfig* model_config)
{
const auto itr = configs_.find(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ namespace tfs = tensorflow::serving;

namespace nvidia { namespace inferenceserver {

// A singleton to manage the model configurations active in the
// server. A singleton is used because the servables have no
// connection to the server itself but they need to have access to the
// configuration.
class ModelConfigManager {
// A singleton to manage the model repository active in the server. A
// singleton is used because the servables have no connection to the
// server itself but they need to have access to the configuration.
class ModelRepositoryManager {
public:
// Map from model name to a model configuration.
using ModelConfigMap = std::unordered_map<std::string, ModelConfig>;
Expand All @@ -52,7 +51,7 @@ class ModelConfigManager {

// Get the platform for a named model. Return OK if found, NO_FOUND
// otherwise.
static tensorflow::Status GetModelConfigPlatform(
static tensorflow::Status GetModelPlatform(
const std::string& name, Platform* platform);

// Set the model configurations, removing any existing model
Expand All @@ -71,9 +70,9 @@ class ModelConfigManager {
std::set<std::string>* removed);

private:
ModelConfigManager() = default;
~ModelConfigManager() = default;
static ModelConfigManager* GetSingleton();
ModelRepositoryManager() = default;
~ModelRepositoryManager() = default;
static ModelRepositoryManager* GetSingleton();
tensorflow::Status GetModelConfigInternal(
const std::string& name, ModelConfig* model_config);

Expand Down
19 changes: 10 additions & 9 deletions src/core/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "src/core/metrics.h"
#include "src/core/model_config.h"
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/profile.h"
#include "src/core/request_status.h"
#include "src/core/server.h"
Expand Down Expand Up @@ -795,8 +795,8 @@ InferenceServer::Init(int argc, char** argv)

// Create the model configuration for all the models in the model
// store.
ModelConfigManager::ModelConfigMap model_configs;
status = ModelConfigManager::ReadModelConfigs(
ModelRepositoryManager::ModelConfigMap model_configs;
status = ModelRepositoryManager::ReadModelConfigs(
model_store_path_, !strict_model_config_, &model_configs,
&options.model_server_config);
if (!status.ok()) {
Expand All @@ -806,7 +806,7 @@ InferenceServer::Init(int argc, char** argv)
LOG_VERBOSE(1) << options.model_server_config.DebugString();

// Register the configurations with the manager.
status = ModelConfigManager::SetModelConfigs(model_configs);
status = ModelRepositoryManager::SetModelConfigs(model_configs);
if (!status.ok()) {
LogInitError(status.error_message());
return !exit_on_error;
Expand Down Expand Up @@ -898,9 +898,9 @@ InferenceServer::Wait()
if (poll_model_repository_enabled_) {
while (ready_state_ != ServerReadyState::SERVER_EXITING) {
if (ready_state_ == ServerReadyState::SERVER_READY) {
ModelConfigManager::ModelConfigMap mc;
ModelRepositoryManager::ModelConfigMap mc;
tfs::ModelServerConfig msc;
tensorflow::Status status = ModelConfigManager::ReadModelConfigs(
tensorflow::Status status = ModelRepositoryManager::ReadModelConfigs(
model_store_path_, !strict_model_config_, &mc, &msc);
if (!status.ok()) {
LOG_ERROR << "Failed to build new model configurations: "
Expand All @@ -912,8 +912,9 @@ InferenceServer::Wait()
// there is any change then need to reload the model
// configs.
std::set<std::string> added, removed;
if (ModelConfigManager::CompareModelConfigs(mc, &added, &removed)) {
ModelConfigManager::SetModelConfigs(mc);
if (ModelRepositoryManager::CompareModelConfigs(
mc, &added, &removed)) {
ModelRepositoryManager::SetModelConfigs(mc);
status = core_->ReloadConfig(msc);
if (!status.ok()) {
LOG_ERROR << "Failed to reload new model configurations: "
Expand Down Expand Up @@ -1207,7 +1208,7 @@ InferenceServer::HandleInfer(
std::function<void()> handle;

Platform platform;
status = ModelConfigManager::GetModelConfigPlatform(
status = ModelRepositoryManager::GetModelPlatform(
request_provider->ModelName(), &platform);
if (status.ok()) {
switch (platform) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/server_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ServerStatusManager::ServerStatusManager(const std::string& server_version)

tensorflow::Status
ServerStatusManager::InitModelConfigs(
const ModelConfigManager::ModelConfigMap& model_configs)
const ModelRepositoryManager::ModelConfigMap& model_configs)
{
for (const auto& p : model_configs) {
const ModelConfig& model = p.second;
Expand All @@ -106,7 +106,7 @@ ServerStatusManager::InitModelConfigs(

tensorflow::Status
ServerStatusManager::UpdateModelConfigs(
const ModelConfigManager::ModelConfigMap& model_configs,
const ModelRepositoryManager::ModelConfigMap& model_configs,
const std::set<std::string>& added, const std::set<std::string>& removed)
{
std::lock_guard<std::mutex> lock(mu_);
Expand Down
6 changes: 3 additions & 3 deletions src/core/server_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <time.h>
#include <mutex>
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/server_status.pb.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow_serving/core/servable_state_monitor.h"
Expand Down Expand Up @@ -166,12 +166,12 @@ class ServerStatusManager {

// Initialize status for a set of model configurations
tensorflow::Status InitModelConfigs(
const ModelConfigManager::ModelConfigMap& model_configs);
const ModelRepositoryManager::ModelConfigMap& model_configs);

// Update status as appropriate for a set of model configurations
// with a given set of added and removed configurations.
tensorflow::Status UpdateModelConfigs(
const ModelConfigManager::ModelConfigMap& model_configs,
const ModelRepositoryManager::ModelConfigMap& model_configs,
const std::set<std::string>& added, const std::set<std::string>& removed);

// Get the entire server status, including status for all models.
Expand Down
6 changes: 3 additions & 3 deletions src/servables/caffe2/netdef_bundle_source_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "src/core/constants.h"
#include "src/core/logging.h"
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/utils.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/platform/env.h"
Expand All @@ -51,8 +51,8 @@ CreateNetDefBundle(
const auto model_name = tensorflow::io::Basename(model_path);

ModelConfig model_config;
TF_RETURN_IF_ERROR(
ModelConfigManager::GetModelConfig(std::string(model_name), &model_config));
TF_RETURN_IF_ERROR(ModelRepositoryManager::GetModelConfig(
std::string(model_name), &model_config));

// Read all the netdef files in 'path'. GetChildren() returns all
// descendants instead for cloud storage like GCS, so filter out all
Expand Down
6 changes: 3 additions & 3 deletions src/servables/tensorflow/graphdef_bundle_source_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "src/core/constants.h"
#include "src/core/logging.h"
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/utils.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/platform/env.h"
Expand All @@ -51,8 +51,8 @@ CreateGraphDefBundle(
const auto model_name = tensorflow::io::Basename(model_path);

ModelConfig model_config;
TF_RETURN_IF_ERROR(
ModelConfigManager::GetModelConfig(std::string(model_name), &model_config));
TF_RETURN_IF_ERROR(ModelRepositoryManager::GetModelConfig(
std::string(model_name), &model_config));

// Read all the graphdef files in 'path'. GetChildren() returns all
// descendants instead for cloud storage like GCS, so filter out all
Expand Down
6 changes: 3 additions & 3 deletions src/servables/tensorflow/savedmodel_bundle_source_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "src/core/constants.h"
#include "src/core/logging.h"
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/utils.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/platform/env.h"
Expand All @@ -51,8 +51,8 @@ CreateSavedModelBundle(
const auto model_name = tensorflow::io::Basename(model_path);

ModelConfig model_config;
TF_RETURN_IF_ERROR(
ModelConfigManager::GetModelConfig(std::string(model_name), &model_config));
TF_RETURN_IF_ERROR(ModelRepositoryManager::GetModelConfig(
std::string(model_name), &model_config));

// Read all the savedmodel directories in 'path'. GetChildren()
// returns all descendants instead for cloud storage like GCS, so
Expand Down
6 changes: 3 additions & 3 deletions src/servables/tensorrt/plan_bundle_source_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "src/core/constants.h"
#include "src/core/logging.h"
#include "src/core/model_config.pb.h"
#include "src/core/model_config_manager.h"
#include "src/core/model_repository_manager.h"
#include "src/core/utils.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/platform/env.h"
Expand All @@ -51,8 +51,8 @@ CreatePlanBundle(
const auto model_name = tensorflow::io::Basename(model_path);

ModelConfig model_config;
TF_RETURN_IF_ERROR(
ModelConfigManager::GetModelConfig(std::string(model_name), &model_config));
TF_RETURN_IF_ERROR(ModelRepositoryManager::GetModelConfig(
std::string(model_name), &model_config));

// Read all the plan files in 'path'. GetChildren() returns all
// descendants instead for cloud storage like GCS, so filter out all
Expand Down
3 changes: 2 additions & 1 deletion src/servables/tensorrt/plan_bundle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ TEST_F(PlanBundleTest, ModelConfigSanity)
std::vector<std::string>{kTensorRTPlanFilename}) {
const auto plan_path = tensorflow::io::JoinPath(path, filename);
tensorflow::string blob_str;
tensorflow::ReadFileToString(tensorflow::Env::Default(), plan_path, &blob_str);
tensorflow::ReadFileToString(
tensorflow::Env::Default(), plan_path, &blob_str);
std::vector<char> blob(blob_str.begin(), blob_str.end());
plan_blobs.emplace(filename, std::move(blob));
}
Expand Down
2 changes: 1 addition & 1 deletion src/servers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ cc_binary(
"//src/core:logging",
"//src/core:metrics",
"//src/core:model_config",
"//src/core:model_config_manager",
"//src/core:model_config_proto",
"//src/core:model_repository_manager",
"//src/core:profile",
"//src/core:request_status",
"//src/core:request_status_proto",
Expand Down

0 comments on commit 4a0f636

Please sign in to comment.