Skip to content

Commit

Permalink
Merge commit for internal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirilg committed Nov 22, 2017
2 parents a82e7d0 + ddcce34 commit ab960a3
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tensorflow
Submodule tensorflow updated 1595 files
9 changes: 9 additions & 0 deletions tensorflow_serving/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ filegroup(
)

load("//tensorflow_serving:serving.bzl", "serving_proto_library")
load("//tensorflow_serving:serving.bzl", "serving_proto_library_py")

serving_proto_library(
name = "model_server_config_proto",
Expand All @@ -32,6 +33,12 @@ serving_proto_library(
],
)

serving_proto_library_py(
name = "model_server_config_proto_py_pb2",
srcs = ["model_server_config.proto"],
proto_library = "model_server_config_proto",
)

serving_proto_library(
name = "platform_config_proto",
srcs = ["platform_config.proto"],
Expand All @@ -46,6 +53,7 @@ serving_proto_library(
srcs = ["log_collector_config.proto"],
cc_api_version = 2,
go_api_version = 2,
java_api_version = 2,
deps = [
],
)
Expand All @@ -55,6 +63,7 @@ serving_proto_library(
srcs = ["logging_config.proto"],
cc_api_version = 2,
go_api_version = 2,
java_api_version = 2,
deps = [
":log_collector_config_proto",
],
Expand Down
13 changes: 8 additions & 5 deletions tensorflow_serving/core/server_request_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,28 @@ class ServerRequestLogger {
request_logger_creator,
std::unique_ptr<ServerRequestLogger>* server_request_logger);

~ServerRequestLogger() = default;
virtual ~ServerRequestLogger() = default;

// Updates the logger with the new 'logging_config_map'.
//
// If the ServerRequestLogger was created using an empty
// request_logger_creator, this will return an error if a non-empty
// logging_config_map is passed in.
Status Update(const std::map<string, LoggingConfig>& logging_config_map);
virtual Status Update(
const std::map<string, LoggingConfig>& logging_config_map);

// Similar to RequestLogger::Log().
Status Log(const google::protobuf::Message& request, const google::protobuf::Message& response,
const LogMetadata& log_metadata);
virtual Status Log(const google::protobuf::Message& request,
const google::protobuf::Message& response,
const LogMetadata& log_metadata);

private:
protected:
explicit ServerRequestLogger(
const std::function<Status(const LoggingConfig& logging_config,
std::unique_ptr<RequestLogger>*)>&
request_logger_creator);

private:
// A map from model_name to its corresponding RequestLogger.
using RequestLoggerMap =
std::unordered_map<string, std::unique_ptr<RequestLogger>>;
Expand Down
11 changes: 11 additions & 0 deletions tensorflow_serving/core/test_util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ cc_library(
],
)

cc_library(
name = "mock_server_request_logger",
testonly = 1,
hdrs = ["mock_server_request_logger.h"],
visibility = ["//visibility:public"],
deps = [
"//tensorflow_serving/core:server_request_logger",
"@com_google_googletest//:gtest",
],
)

cc_library(
name = "mock_session",
testonly = 1,
Expand Down
45 changes: 45 additions & 0 deletions tensorflow_serving/core/test_util/mock_server_request_logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright 2017 Google Inc. 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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_CORE_TEST_UTIL_MOCK_SERVER_REQUEST_LOGGER_H_
#define TENSORFLOW_SERVING_CORE_TEST_UTIL_MOCK_SERVER_REQUEST_LOGGER_H_

#include <string>

#include <gmock/gmock.h>
#include "tensorflow_serving/core/server_request_logger.h"

namespace tensorflow {
namespace serving {
namespace test_util {

class MockServerRequestLogger : public ServerRequestLogger {
public:
MockServerRequestLogger() : ServerRequestLogger({}) {}

MOCK_METHOD1(
Update,
Status(const std::map<string, LoggingConfig>& logging_config_map));

MOCK_METHOD3(Log, Status(const google::protobuf::Message& request,
const google::protobuf::Message& response,
const LogMetadata& log_metadata));
};

} // namespace test_util
} // namespace serving
} // namespace tensorflow

#endif // TENSORFLOW_SERVING_CORE_TEST_UTIL_MOCK_SERVER_REQUEST_LOGGER_H_
12 changes: 5 additions & 7 deletions tensorflow_serving/model_servers/server_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ Status ValidateModelConfigList(const ModelConfigList& config_list,
"model_config_list_root_dir=",
*options.model_config_list_root_dir));
}
for (const ModelConfig& config : config_list.config()) {
if (!UriIsRelativePath(config.base_path())) {
return errors::InvalidArgument(strings::StrCat(
"Expected model ", config.name(),
" to have a relative path; got base_path()=", config.base_path()));
}
}
} else {
// All base-paths must be absolute.
for (const ModelConfig& config : config_list.config()) {
Expand Down Expand Up @@ -200,6 +193,11 @@ Status UpdateModelConfigListRelativePaths(
std::vector<string> updated_paths;
updated_paths.reserve(config_list->config_size());
for (const ModelConfig& config : config_list->config()) {
// Don't modify absolute paths.
if (!UriIsRelativePath(config.base_path())) {
updated_paths.push_back(config.base_path());
continue;
}
updated_paths.emplace_back(
io::JoinPath(model_config_list_root_dir, config.base_path()));
if (UriIsRelativePath(updated_paths.back())) {
Expand Down
17 changes: 13 additions & 4 deletions tensorflow_serving/model_servers/server_core_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,28 @@ TEST_P(RelativePathsServerCoreTest, RelativePathFails) {
CreateServerCore(relative, &server_core).code());
}

TEST_P(RelativePathsServerCoreTest, AbsolutePathWithOptionsFails) {
TEST_P(RelativePathsServerCoreTest,
AbsoluteAndRelativePathsWithOptionsSucceed) {
std::unique_ptr<ServerCore> server_core;
ModelServerConfig absolute_and_relative;
ModelServerConfig absolute = GetTestModelServerConfigForFakePlatform();
ServerCore::Options options = GetDefaultOptions();
{
string model_config_list_root_dir;
ModelServerConfig relative =
GetTestModelServerConfigWithRelativePath(&model_config_list_root_dir);
// Add the absolute and relative config to absolute. We'll check that both
// paths can be interleaved in the same model config list.
CHECK_GT(relative.model_config_list().config_size(), 0);
CHECK_GT(absolute.model_config_list().config_size(), 0);
*absolute_and_relative.mutable_model_config_list()->add_config() =
absolute.model_config_list().config(0);
*absolute_and_relative.mutable_model_config_list()->add_config() =
relative.model_config_list().config(0);
options.model_config_list_root_dir = std::move(model_config_list_root_dir);
}
EXPECT_EQ(
error::INVALID_ARGUMENT,
CreateServerCore(absolute, std::move(options), &server_core).code());
TF_ASSERT_OK(CreateServerCore(absolute_and_relative, std::move(options),
&server_core));
}

TEST_P(RelativePathsServerCoreTest, AbsolutePathWithEmptyPathFails) {
Expand Down
7 changes: 7 additions & 0 deletions tensorflow_serving/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def tf_serving_workspace():
name = "zlib",
actual = "@zlib_archive//:zlib",
)

# gRPC wants the existence of a cares dependence but its contents are not
# actually important since we have set GRPC_ARES=0 in tools/bazel.rc
native.bind(
name = "cares",
actual = "@grpc//third_party/nanopb:nanopb",
)
2 changes: 1 addition & 1 deletion tf_models
Submodule tf_models updated 272 files
2 changes: 2 additions & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ run --define PYTHON_BIN_PATH=/usr/bin/python
build --spawn_strategy=standalone --genrule_strategy=standalone
test --spawn_strategy=standalone --genrule_strategy=standalone
run --spawn_strategy=standalone --genrule_strategy=standalone

build --define=grpc_no_ares=true

0 comments on commit ab960a3

Please sign in to comment.