diff --git a/.bazelrc b/.bazelrc index 5f3ee39f694..f2dd90ef3da 100644 --- a/.bazelrc +++ b/.bazelrc @@ -90,7 +90,7 @@ build --experimental_cc_shared_library # uses TensorFlow for all IO operations. build --define=use_tensorflow_io=1 -# TensorFlow Decision Forests need absl::anyInvocable support for new versions +# TensorFlow Decision Forests need absl::anyInvocable support for new versions # of Tensorflow. build --define use_absl_anyinvocable=1 diff --git a/WORKSPACE b/WORKSPACE index 1e598bceecd..33a3d4b4528 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -130,4 +130,3 @@ load( ) nccl_configure(name = "local_config_nccl") - diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000000..de0e609f327 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,123 @@ +line-length = 88 + +[lint] +select = [ + # pycodestyle + "E", + "W", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", + # pep8 naming + "N", + # pydocstyle + "D", + # annotations + "ANN", + # debugger + "T10", + # flake8-pytest + "PT", + # flake8-return + "RET", + # flake8-unused-arguments + "ARG", + # flake8-fixme + "FIX", + # flake8-eradicate + "ERA", + # pandas-vet + "PD", + # numpy-specific rules + "NPY", +] +ignore = [ + "D104", # Missing docstring in public package + "D100", # Missing docstring in public module + "D211", # No blank line before class + "D213", # Multiline summary second line + "PD901", # Avoid using 'df' for pandas dataframes. Perfectly fine in functions with limited scope + "ANN201", # Missing return type annotation for public function (makes no sense for NoneType return types...) + "ANN101", # Missing type annotation for `self` + "ANN102", # Missing type annotation for `cls` in classmethod + "ANN204", # Missing return type annotation for special method + "ANN206", # Missing return type annotation for classmethod + "ANN002", # Missing type annotation for `*args` + "ANN003", # Missing type annotation for `**kwargs` + "D105", # Missing docstring in magic method + "D203", # 1 blank line before after class docstring + "D204", # 1 blank line required after class docstring + "D413", # 1 blank line after parameters + "SIM108", # Simplify if/else to one line; not always clearer + "D206", # Advised to disable by ruff-format + "E501", # Advised to disable by ruff-format + "W191", # Advised to disable by ruff-format + "N802", # Function name should be lowercase; unittest uses mixed case + "D107", # Missing docstring in `__init__` + + # These are issues which remain to be fixed + "D102", # Missing docstring in public method + "D103", # Missing docstring in public function + "D401", # First line of docstring should be in imperative mood + "D404", # First word of the docstring should not be "This" + "ANN001", # Missing type annotation for function argument + "ANN202", # Missing return type for private function + "ANN205", # Missing return type for staticmethod + "B024", # is an abstract base class, but it has no abstract methods + "FIX002", # Line contains TODO, consider resolving the issue + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed + "UP008", # Use `super()` instead of `super(__class__, self)` + "SIM102", # Use a single `if` statement instead of nested `if` statements + "UP031", # Use format specifiers instead of percent format + "SIM115", # Use context handler for opening files + "B008", # Do not perform function call in argument defaults + "ARG001", # Unused function argument + "F841", # Local variable is assigned to but never used + "ERA001", # Found commented-out code + "RET505", # Unnecessary `else` after `return` statement + "RET503", # Missing explicit `return` at the end of function able to return non-`None` value + "UP029", # Unnecessary builtin import + "ARG005", # Unused lambda argument + "E402", # Module level import not at top of file + "F403", # Wildcard import + "NPY002", # Replace legacy numpy call + "D200", # One-line docstring should fit on one line + "D205", # 1 blank line required between summary line and description + "RET504", # Unnecessary assignment before return + "ARG002", # Unused method argument +] + +[lint.per-file-ignores] +"__init__.py" = [ + "F401", # Unused import +] +"*_test_base.py" = [ + "ANN001", # Type annotations aren't needed for tests; these are fixtures or parametrizations + "PT009", # Use a regular `assert` instead of a unittest-style `assertEqual` + "PT027", # Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + + # Missing docstrings; probably want to fill these out for tests. For now, we just disable + "D101", # Missing docstring in public class + "D102", # Missing docstring in public method + +] +"*_test.py" = [ + "ANN001", # Type annotations aren't needed for tests; these are fixtures or parametrizations + "PT009", # Use a regular `assert` instead of a unittest-style `assertEqual` + "PT027", # Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + + # Missing docstrings; probably want to fill these out for tests. For now, we just disable + "D101", # Missing docstring in public class + "D102", # Missing docstring in public method + +] + +[lint.pydocstyle] +convention = "google" diff --git a/tensorflow_serving/apis/model_service_pb2.py b/tensorflow_serving/apis/model_service_pb2.py index 76f1d606cb2..d850be274e3 100644 --- a/tensorflow_serving/apis/model_service_pb2.py +++ b/tensorflow_serving/apis/model_service_pb2.py @@ -18,19 +18,23 @@ # python -m grpc.tools.protoc --python_out=. --grpc_python_out=. -I. tensorflow_serving/apis/model_service.proto import sys + _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 +from google.protobuf import symbol_database as _symbol_database + # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() -from tensorflow_serving.apis import get_model_status_pb2 as tensorflow__serving_dot_apis_dot_get__model__status__pb2 -from tensorflow_serving.apis import model_management_pb2 as tensorflow__serving_dot_apis_dot_model__management__pb2 +from tensorflow_serving.apis import ( + get_model_status_pb2 as tensorflow__serving_dot_apis_dot_get__model__status__pb2, +) +from tensorflow_serving.apis import ( + model_management_pb2 as tensorflow__serving_dot_apis_dot_model__management__pb2, +) DESCRIPTOR = _descriptor.FileDescriptor( name='tensorflow_serving/apis/model_service.proto', diff --git a/tensorflow_serving/apis/model_service_pb2_grpc.py b/tensorflow_serving/apis/model_service_pb2_grpc.py index 44c578b8648..29e4683bcb9 100644 --- a/tensorflow_serving/apis/model_service_pb2_grpc.py +++ b/tensorflow_serving/apis/model_service_pb2_grpc.py @@ -19,11 +19,15 @@ import grpc -from tensorflow_serving.apis import get_model_status_pb2 as tensorflow__serving_dot_apis_dot_get__model__status__pb2 -from tensorflow_serving.apis import model_management_pb2 as tensorflow__serving_dot_apis_dot_model__management__pb2 +from tensorflow_serving.apis import ( + get_model_status_pb2 as tensorflow__serving_dot_apis_dot_get__model__status__pb2, +) +from tensorflow_serving.apis import ( + model_management_pb2 as tensorflow__serving_dot_apis_dot_model__management__pb2, +) -class ModelServiceStub(object): +class ModelServiceStub: """ModelService provides methods to query and update the state of the server, e.g. which models/versions are being served. """ @@ -50,7 +54,7 @@ def __init__(self, channel): ) -class ModelServiceServicer(object): +class ModelServiceServicer: """ModelService provides methods to query and update the state of the server, e.g. which models/versions are being served. """ diff --git a/tensorflow_serving/apis/prediction_service_pb2.py b/tensorflow_serving/apis/prediction_service_pb2.py index e51a700f720..4aa40744ce6 100644 --- a/tensorflow_serving/apis/prediction_service_pb2.py +++ b/tensorflow_serving/apis/prediction_service_pb2.py @@ -22,23 +22,32 @@ # source: tensorflow_serving/apis/prediction_service.proto import sys + _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 +from google.protobuf import symbol_database as _symbol_database + # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() -from tensorflow_serving.apis import classification_pb2 as tensorflow__serving_dot_apis_dot_classification__pb2 -from tensorflow_serving.apis import get_model_metadata_pb2 as tensorflow__serving_dot_apis_dot_get__model__metadata__pb2 -from tensorflow_serving.apis import inference_pb2 as tensorflow__serving_dot_apis_dot_inference__pb2 -from tensorflow_serving.apis import predict_pb2 as tensorflow__serving_dot_apis_dot_predict__pb2 -from tensorflow_serving.apis import regression_pb2 as tensorflow__serving_dot_apis_dot_regression__pb2 - +from tensorflow_serving.apis import ( + classification_pb2 as tensorflow__serving_dot_apis_dot_classification__pb2, +) +from tensorflow_serving.apis import ( + get_model_metadata_pb2 as tensorflow__serving_dot_apis_dot_get__model__metadata__pb2, +) +from tensorflow_serving.apis import ( + inference_pb2 as tensorflow__serving_dot_apis_dot_inference__pb2, +) +from tensorflow_serving.apis import ( + predict_pb2 as tensorflow__serving_dot_apis_dot_predict__pb2, +) +from tensorflow_serving.apis import ( + regression_pb2 as tensorflow__serving_dot_apis_dot_regression__pb2, +) DESCRIPTOR = _descriptor.FileDescriptor( name='tensorflow_serving/apis/prediction_service.proto', diff --git a/tensorflow_serving/apis/prediction_service_pb2_grpc.py b/tensorflow_serving/apis/prediction_service_pb2_grpc.py index 082f94a39a0..f74c23819fb 100644 --- a/tensorflow_serving/apis/prediction_service_pb2_grpc.py +++ b/tensorflow_serving/apis/prediction_service_pb2_grpc.py @@ -18,14 +18,24 @@ # python -m grpc.tools.protoc --python_out=. --grpc_python_out=. -I. tensorflow_serving/apis/prediction_service.proto import grpc -from tensorflow_serving.apis import classification_pb2 as tensorflow__serving_dot_apis_dot_classification__pb2 -from tensorflow_serving.apis import get_model_metadata_pb2 as tensorflow__serving_dot_apis_dot_get__model__metadata__pb2 -from tensorflow_serving.apis import inference_pb2 as tensorflow__serving_dot_apis_dot_inference__pb2 -from tensorflow_serving.apis import predict_pb2 as tensorflow__serving_dot_apis_dot_predict__pb2 -from tensorflow_serving.apis import regression_pb2 as tensorflow__serving_dot_apis_dot_regression__pb2 +from tensorflow_serving.apis import ( + classification_pb2 as tensorflow__serving_dot_apis_dot_classification__pb2, +) +from tensorflow_serving.apis import ( + get_model_metadata_pb2 as tensorflow__serving_dot_apis_dot_get__model__metadata__pb2, +) +from tensorflow_serving.apis import ( + inference_pb2 as tensorflow__serving_dot_apis_dot_inference__pb2, +) +from tensorflow_serving.apis import ( + predict_pb2 as tensorflow__serving_dot_apis_dot_predict__pb2, +) +from tensorflow_serving.apis import ( + regression_pb2 as tensorflow__serving_dot_apis_dot_regression__pb2, +) -class PredictionServiceStub(object): +class PredictionServiceStub: """open source marker; do not remove PredictionService provides access to machine-learned models loaded by model_servers. @@ -64,7 +74,7 @@ def __init__(self, channel): ) -class PredictionServiceServicer(object): +class PredictionServiceServicer: """open source marker; do not remove PredictionService provides access to machine-learned models loaded by model_servers. diff --git a/tensorflow_serving/batching/test_util/matrix_half_plus_two_saved_model.py b/tensorflow_serving/batching/test_util/matrix_half_plus_two_saved_model.py index d111459009c..06f06e73111 100644 --- a/tensorflow_serving/batching/test_util/matrix_half_plus_two_saved_model.py +++ b/tensorflow_serving/batching/test_util/matrix_half_plus_two_saved_model.py @@ -14,6 +14,7 @@ # ============================================================================== import tensorflow.compat.v1 as tf + FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string("output_dir", "/tmp/matrix_half_plus_two/1", @@ -22,13 +23,14 @@ def _generate_saved_model_for_matrix_half_plus_two(export_dir): """Creates SavedModel for half plus two model that accepts batches of - 3*3 matrices. - The model divides all elements in each matrix by 2 and adds 2 to them. - So, for one input matrix [[1, 2, 3], [4, 5, 6], [7, 8, 9]] - the result will be [[2.5, 3, 3.5], [4, 4.5, 5], [5.5, 6, 6.5]]. - Args: - export_dir: The directory where to write SavedModel files. - """ + 3*3 matrices. + The model divides all elements in each matrix by 2 and adds 2 to them. + So, for one input matrix [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + the result will be [[2.5, 3, 3.5], [4, 4.5, 5], [5.5, 6, 6.5]]. + + Args: + export_dir: The directory where to write SavedModel files. + """ builder = tf.saved_model.builder.SavedModelBuilder(export_dir) with tf.Session() as session: x = tf.placeholder(tf.float32, shape=[None, 3, 3], name="x") diff --git a/tensorflow_serving/example/mnist_client.py b/tensorflow_serving/example/mnist_client.py index a9078cc2c8f..e4312b41366 100644 --- a/tensorflow_serving/example/mnist_client.py +++ b/tensorflow_serving/example/mnist_client.py @@ -25,21 +25,17 @@ mnist_client.py --num_tests=100 --server=localhost:9000 """ -from __future__ import print_function import sys import threading # This is a placeholder for a Google-internal import. - import grpc +import mnist_input_data import numpy import tensorflow as tf -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_service_pb2_grpc -import mnist_input_data - +from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc tf.compat.v1.app.flags.DEFINE_integer( 'concurrency', 1, 'maximum number of concurrent inference requests') @@ -50,7 +46,7 @@ FLAGS = tf.compat.v1.app.flags.FLAGS -class _ResultCounter(object): +class _ResultCounter: """Counter for the prediction results.""" def __init__(self, num_tests, concurrency): @@ -94,6 +90,7 @@ def _create_rpc_callback(label, result_counter): Args: label: The correct label for the predicted example. result_counter: Counter for the prediction result. + Returns: The callback function. """ diff --git a/tensorflow_serving/example/mnist_input_data.py b/tensorflow_serving/example/mnist_input_data.py index 3e8021a2435..94bdae0db48 100644 --- a/tensorflow_serving/example/mnist_input_data.py +++ b/tensorflow_serving/example/mnist_input_data.py @@ -17,7 +17,6 @@ """Functions for downloading and reading MNIST data.""" -from __future__ import print_function import gzip import os @@ -95,12 +94,11 @@ def extract_labels(filename, one_hot=False): return labels -class DataSet(object): +class DataSet: """Class encompassing test, validation and training MNIST data set.""" def __init__(self, images, labels, fake_data=False, one_hot=False): """Construct a DataSet. one_hot arg is used only if fake_data is true.""" - if fake_data: self._num_examples = 10000 self.one_hot = one_hot @@ -171,7 +169,7 @@ def next_batch(self, batch_size, fake_data=False): def read_data_sets(train_dir, fake_data=False, one_hot=False): """Return training, validation and testing data sets.""" - class DataSets(object): + class DataSets: pass data_sets = DataSets() diff --git a/tensorflow_serving/example/mnist_saved_model.py b/tensorflow_serving/example/mnist_saved_model.py index 3f3672b27e2..0db1ab2d202 100644 --- a/tensorflow_serving/example/mnist_saved_model.py +++ b/tensorflow_serving/example/mnist_saved_model.py @@ -25,19 +25,16 @@ export_dir """ -from __future__ import print_function import os import sys -# This is a placeholder for a Google-internal import. +import mnist_input_data +# This is a placeholder for a Google-internal import. import tensorflow as tf - from tensorflow.python.ops import lookup_ops -import mnist_input_data - tf.compat.v1.app.flags.DEFINE_integer('training_iteration', 1000, 'number of training iterations.') tf.compat.v1.app.flags.DEFINE_integer('model_version', 1, diff --git a/tensorflow_serving/example/resnet_client.py b/tensorflow_serving/example/resnet_client.py index b531166a91d..e6e9163ef9c 100644 --- a/tensorflow_serving/example/resnet_client.py +++ b/tensorflow_serving/example/resnet_client.py @@ -27,15 +27,14 @@ resnet_client.py """ -from __future__ import print_function import base64 import io import json import numpy as np -from PIL import Image import requests +from PIL import Image # The server URL specifies the endpoint of your server running the ResNet # model with the name "resnet" and using the predict interface. @@ -79,8 +78,7 @@ def main(): total_time += response.elapsed.total_seconds() prediction = response.json()['predictions'][0] - print('Prediction class: {}, avg latency: {} ms'.format( - np.argmax(prediction), (total_time * 1000) / num_requests)) + print(f'Prediction class: {np.argmax(prediction)}, avg latency: {(total_time * 1000) / num_requests} ms') if __name__ == '__main__': diff --git a/tensorflow_serving/example/resnet_client_grpc.py b/tensorflow_serving/example/resnet_client_grpc.py index 5a7171c6caf..f46bb6838e0 100644 --- a/tensorflow_serving/example/resnet_client_grpc.py +++ b/tensorflow_serving/example/resnet_client_grpc.py @@ -16,20 +16,17 @@ """ -from __future__ import print_function import io # This is a placeholder for a Google-internal import. - import grpc import numpy as np -from PIL import Image import requests import tensorflow as tf +from PIL import Image -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_service_pb2_grpc +from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc # The image URL is the location of the image we should send to the server IMAGE_URL = 'https://tensorflow.org/images/blogs/serving/cat.jpg' @@ -73,7 +70,7 @@ def main(_): tf.make_tensor_proto(data)) result = stub.Predict(request, 10.0) # 10 secs timeout result = result.outputs['activation_49'].float_val - print('Prediction class: {}'.format(np.argmax(result))) + print(f'Prediction class: {np.argmax(result)}') if __name__ == '__main__': diff --git a/tensorflow_serving/example/resnet_warmup.py b/tensorflow_serving/example/resnet_warmup.py index c7a6af151fb..a7018f1e76a 100644 --- a/tensorflow_serving/example/resnet_warmup.py +++ b/tensorflow_serving/example/resnet_warmup.py @@ -14,36 +14,34 @@ # ============================================================================== """Creates the tf_serving_warmup_requests file to warm up a ResNet SavedModel. - 1. Invoke this script passing in the saved_model directory (including version - folder, the folder containing saved_model.pb) as an argument. - 2. Restart tensorflow_model_server. +1. Invoke this script passing in the saved_model directory (including version +folder, the folder containing saved_model.pb) as an argument. +2. Restart tensorflow_model_server. - If unsure of the model directory, look for the output: - 'No warmup data file found at' in the tensorflow_model_server - startup log +If unsure of the model directory, look for the output: +'No warmup data file found at' in the tensorflow_model_server +startup log - After the script is run, and tensorflow_model_server is restarted, to verify - it is working look for the output: - 'Starting to read warmup data for model at' and 'Finished reading warmup data - for model at' in the tensorflow_model_server startup log +After the script is run, and tensorflow_model_server is restarted, to verify +it is working look for the output: +'Starting to read warmup data for model at' and 'Finished reading warmup data +for model at' in the tensorflow_model_server startup log - Usage example: - python resnet_warmup.py saved_model_dir +Usage example: +python resnet_warmup.py saved_model_dir """ -from __future__ import print_function import io import os import sys import numpy as np -from PIL import Image import requests import tensorflow as tf -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_log_pb2 +from PIL import Image +from tensorflow_serving.apis import predict_pb2, prediction_log_pb2 # IMAGE_URLS are the locations of the images we use to warmup the model IMAGE_URLS = ['https://tensorflow.org/images/blogs/serving/cat.jpg', diff --git a/tensorflow_serving/experimental/example/half_plus_two_with_rpop.py b/tensorflow_serving/experimental/example/half_plus_two_with_rpop.py index 07fe685d139..f90dea3f7dd 100644 --- a/tensorflow_serving/experimental/example/half_plus_two_with_rpop.py +++ b/tensorflow_serving/experimental/example/half_plus_two_with_rpop.py @@ -29,7 +29,9 @@ import tensorflow.compat.v1 as tf -from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops import remote_predict_ops +from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops import ( + remote_predict_ops, +) tf.app.flags.DEFINE_string("output_dir", "/tmp/half_plus_two_with_rpop/1/", "Savedmodel export path") diff --git a/tensorflow_serving/experimental/example/half_plus_two_with_rpop_client.py b/tensorflow_serving/experimental/example/half_plus_two_with_rpop_client.py index b5b4bf7fb55..a22085a3751 100644 --- a/tensorflow_serving/experimental/example/half_plus_two_with_rpop_client.py +++ b/tensorflow_serving/experimental/example/half_plus_two_with_rpop_client.py @@ -36,15 +36,13 @@ tensorflow_model_server --port=8500 --model_config_file=/tmp/config_file.txt """ -from __future__ import print_function # This is a placeholder for a Google-internal import. import grpc import tensorflow.compat.v1 as tf -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_service_pb2_grpc +from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc tf.app.flags.DEFINE_string('server', 'localhost:8500', 'PredictionService host:port') diff --git a/tensorflow_serving/experimental/example/remote_predict_client.py b/tensorflow_serving/experimental/example/remote_predict_client.py index 1f09a26c077..f3df4591b52 100644 --- a/tensorflow_serving/experimental/example/remote_predict_client.py +++ b/tensorflow_serving/experimental/example/remote_predict_client.py @@ -17,13 +17,14 @@ Example client code which calls the Remote Predict Op directly. """ -from __future__ import print_function # This is a placeholder for a Google-internal import. import tensorflow.compat.v1 as tf -from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops import remote_predict_ops +from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops import ( + remote_predict_ops, +) tf.app.flags.DEFINE_string("input_tensor_aliases", "x", "Aliases of input tensors") diff --git a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/__init__.py b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/__init__.py index c1597decea2..a62db86fbab 100644 --- a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/__init__.py +++ b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/__init__.py @@ -16,10 +16,10 @@ @@run """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function from tensorflow.python.util.all_util import remove_undocumented -from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops.remote_predict_ops import run + +from tensorflow_serving.experimental.tensorflow.ops.remote_predict.python.ops.remote_predict_ops import ( + run, +) remove_undocumented(__name__) diff --git a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/ops/remote_predict_op.cc b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/ops/remote_predict_op.cc index 0d5bed00af5..8beea8cfff3 100644 --- a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/ops/remote_predict_op.cc +++ b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/ops/remote_predict_op.cc @@ -87,7 +87,7 @@ fail_op_on_rpc_error: If set true, the Op fails if the rpc fails, and returns Set true by default. max_rpc_deadline_millis: The rpc deadline for remote predict. The actual deadline is min(incoming_rpc_deadline, max_rpc_deadline_millis). -signature_name: the signature def for remote graph inference, defaulting to +signature_name: the signature def for remote graph inference, defaulting to "serving_default". target_address: Address of the server hosting the remote graph. model_name: Model name of the remote TF graph. @@ -102,7 +102,7 @@ output_tensor_aliases: Tensor of strings for the output tensor alias names to status_code: Returns the status code of the rpc call; basically converting tensorflow::error::Code to it's int value, so 0 means OK. status_error_message: Returns the error message in the rpc status. -output_tensors: Tensors returned by the Predict call on the remote graph, which +output_tensors: Tensors returned by the Predict call on the remote graph, which are in the same order as output_tensor_aliases. output_types: A list of types of the output tensors. Length of this list should be equal to the length of 'output_tensor_aliases'. diff --git a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/python/ops/remote_predict_ops.py b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/python/ops/remote_predict_ops.py index 59e3541c79c..e84efa24647 100644 --- a/tensorflow_serving/experimental/tensorflow/ops/remote_predict/python/ops/remote_predict_ops.py +++ b/tensorflow_serving/experimental/tensorflow/ops/remote_predict/python/ops/remote_predict_ops.py @@ -14,17 +14,19 @@ # ============================================================================== """Operations for RemotePredict.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import os.path + # This is a placeholder for a Google-internal import. import tensorflow.compat.v1 as tf -from tensorflow_serving.experimental.tensorflow.ops.remote_predict.ops import gen_remote_predict_op +from tensorflow_serving.experimental.tensorflow.ops.remote_predict.ops import ( + gen_remote_predict_op, +) + # pylint: disable=wildcard-import from tensorflow_serving.experimental.tensorflow.ops.remote_predict.ops.gen_remote_predict_op import * + # pylint: enable=wildcard-import _remote_predict_op_module = tf.load_op_library( diff --git a/tensorflow_serving/g3doc/saved_model_warmup.md b/tensorflow_serving/g3doc/saved_model_warmup.md index 1d4345ae758..838d0966ff8 100644 --- a/tensorflow_serving/g3doc/saved_model_warmup.md +++ b/tensorflow_serving/g3doc/saved_model_warmup.md @@ -48,5 +48,3 @@ Warmup data can be added in two ways: `YourSavedModel/assets.extra/tf_serving_warmup_requests` based on the validation requests provided via [RequestSpec](https://www.tensorflow.org/tfx/guide/infra_validator#requestspec). - - diff --git a/tensorflow_serving/model_servers/profiler_client.py b/tensorflow_serving/model_servers/profiler_client.py index c4573842980..65bb98f361c 100644 --- a/tensorflow_serving/model_servers/profiler_client.py +++ b/tensorflow_serving/model_servers/profiler_client.py @@ -14,12 +14,8 @@ # ============================================================================== """Simple client to send profiling request to ModelServer.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import tensorflow as tf - from tensorflow.python.profiler import profiler_client diff --git a/tensorflow_serving/model_servers/tensorflow_model_server_test.py b/tensorflow_serving/model_servers/tensorflow_model_server_test.py index 32e53c05885..c15c19de9bd 100644 --- a/tensorflow_serving/model_servers/tensorflow_model_server_test.py +++ b/tensorflow_serving/model_servers/tensorflow_model_server_test.py @@ -15,9 +15,6 @@ """Tests for tensorflow_model_server.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import json import os @@ -25,7 +22,6 @@ import sys import time - # During the creation of the 'tensorflow_serving' package, bazel emits a python # 'tensorflow' module which contains its dependencies (e.g. example.proto). # Since bazel python libraries take precedence in sys.path and the created @@ -37,19 +33,21 @@ # This is a placeholder for a Google-internal import. # pylint: disable=g-import-not-at-top import grpc -from six.moves import range import tensorflow.compat.v1 as tf - +from six.moves import range from tensorflow.python.platform import flags from tensorflow.python.profiler import profiler_client from tensorflow.python.saved_model import signature_constants -from tensorflow_serving.apis import classification_pb2 -from tensorflow_serving.apis import get_model_metadata_pb2 -from tensorflow_serving.apis import get_model_status_pb2 -from tensorflow_serving.apis import inference_pb2 -from tensorflow_serving.apis import model_service_pb2_grpc -from tensorflow_serving.apis import prediction_service_pb2_grpc -from tensorflow_serving.apis import regression_pb2 + +from tensorflow_serving.apis import ( + classification_pb2, + get_model_metadata_pb2, + get_model_status_pb2, + inference_pb2, + model_service_pb2_grpc, + prediction_service_pb2_grpc, + regression_pb2, +) from tensorflow_serving.model_servers.test_util import tensorflow_model_server_test_base FLAGS = flags.FLAGS @@ -74,7 +72,7 @@ def __BuildModelConfigFile(self): in the configuration template file and writes it out to another file used by the test. """ - with open(self._GetGoodModelConfigTemplate(), 'r') as template_file: + with open(self._GetGoodModelConfigTemplate()) as template_file: config = template_file.read().replace('${TEST_HALF_PLUS_TWO_DIR}', self._GetSavedModelBundlePath()) config = config.replace('${TEST_HALF_PLUS_THREE_DIR}', @@ -314,7 +312,6 @@ def testBadModelConfig(self): def testModelConfigReload(self): """Test model server polls filesystem for model configuration.""" - base_config_proto = """ model_config_list: {{ config: {{ @@ -368,7 +365,6 @@ def testModelConfigReload(self): def testModelConfigReloadWithZeroPollPeriod(self): """Test model server does not poll filesystem for model config.""" - base_config_proto = """ model_config_list: {{ config: {{ @@ -442,7 +438,7 @@ def testClassifyREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default:classify'.format(host, port) + url = f'http://{host}:{port}/v1/models/default:classify' json_req = {'signature_name': 'classify_x_to_y', 'examples': [{'x': 2.0}]} # Send request @@ -450,7 +446,7 @@ def testClassifyREST(self): try: resp_data = tensorflow_model_server_test_base.CallREST(url, json_req) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify response self.assertEqual(json.loads(resp_data.decode()), {'results': [[['', 3.0]]]}) @@ -462,7 +458,7 @@ def testRegressREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default:regress'.format(host, port) + url = f'http://{host}:{port}/v1/models/default:regress' json_req = {'signature_name': 'regress_x_to_y', 'examples': [{'x': 2.0}]} # Send request @@ -470,7 +466,7 @@ def testRegressREST(self): try: resp_data = tensorflow_model_server_test_base.CallREST(url, json_req) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify response self.assertEqual(json.loads(resp_data.decode()), {'results': [3.0]}) @@ -482,7 +478,7 @@ def testPredictREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default:predict'.format(host, port) + url = f'http://{host}:{port}/v1/models/default:predict' json_req = {'instances': [2.0, 3.0, 4.0]} # Send request @@ -490,7 +486,7 @@ def testPredictREST(self): try: resp_data = tensorflow_model_server_test_base.CallREST(url, json_req) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify response self.assertEqual( @@ -503,7 +499,7 @@ def testPredictColumnarREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default:predict'.format(host, port) + url = f'http://{host}:{port}/v1/models/default:predict' json_req = {'inputs': [2.0, 3.0, 4.0]} # Send request @@ -511,7 +507,7 @@ def testPredictColumnarREST(self): try: resp_data = tensorflow_model_server_test_base.CallREST(url, json_req) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify response self.assertEqual( @@ -524,14 +520,14 @@ def testGetStatusREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default'.format(host, port) + url = f'http://{host}:{port}/v1/models/default' # Send request resp_data = None try: resp_data = tensorflow_model_server_test_base.CallREST(url, None) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify response self.assertEqual( @@ -553,14 +549,14 @@ def testGetModelMetadataREST(self): model_path)[2].split(':') # Prepare request - url = 'http://{}:{}/v1/models/default/metadata'.format(host, port) + url = f'http://{host}:{port}/v1/models/default/metadata' # Send request resp_data = None try: resp_data = tensorflow_model_server_test_base.CallREST(url, None) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') try: model_metadata_file = self._GetModelMetadataFile() @@ -576,7 +572,7 @@ def testGetModelMetadataREST(self): json.loads(resp_data.decode())), tensorflow_model_server_test_base.SortedObject(expected_metadata)) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') def testPrometheusEndpoint(self): """Test ModelStatus implementation over REST API with columnar inputs.""" @@ -587,14 +583,14 @@ def testPrometheusEndpoint(self): monitoring_config_file=self._GetMonitoringConfigFile())[2].split(':') # Prepare request - url = 'http://{}:{}/monitoring/prometheus/metrics'.format(host, port) + url = f'http://{host}:{port}/monitoring/prometheus/metrics' # Send request resp_data = None try: resp_data = tensorflow_model_server_test_base.CallREST(url, None) except Exception as e: # pylint: disable=broad-except - self.fail('Request failed with error: {}'.format(e)) + self.fail(f'Request failed with error: {e}') # Verify that there should be some metric type information. self.assertIn('# TYPE', @@ -735,22 +731,19 @@ def test_distrat_sequential_keras_saved_model_save(self): def test_profiler_service_with_valid_trace_request(self): """Test integration with profiler service by sending tracing requests.""" - # Start model server model_path = self._GetSavedModelBundlePath() _, grpc_addr, rest_addr = TensorflowModelServerTest.RunServer( 'default', model_path) # Prepare predict request - url = 'http://{}/v1/models/default:predict'.format(rest_addr) + url = f'http://{rest_addr}/v1/models/default:predict' json_req = '{"instances": [2.0, 3.0, 4.0]}' # In a subprocess, send a REST predict request every second for 3 seconds - exec_command = ("wget {} --content-on-error=on -O- --post-data '{}' " - "--header='Content-Type:application/json'").format( - url, json_req) - repeat_command = 'for n in {{1..3}}; do {} & sleep 1; done;'.format( - exec_command) + exec_command = (f"wget {url} --content-on-error=on -O- --post-data '{json_req}' " + "--header='Content-Type:application/json'") + repeat_command = f'for n in {{1..3}}; do {exec_command} & sleep 1; done;' proc = subprocess.Popen( repeat_command, shell=True, @@ -770,7 +763,7 @@ def test_profiler_service_with_valid_trace_request(self): # Log stdout & stderr of subprocess issuing predict requests for debugging out, err = proc.communicate() - print("stdout: '{}' | stderr: '{}'".format(out, err)) + print(f"stdout: '{out}' | stderr: '{err}'") def test_tf_text(self): """Test TF Text.""" diff --git a/tensorflow_serving/model_servers/tensorflow_model_server_test_client.py b/tensorflow_serving/model_servers/tensorflow_model_server_test_client.py index 546726a9ab2..63c080b17c2 100644 --- a/tensorflow_serving/model_servers/tensorflow_model_server_test_client.py +++ b/tensorflow_serving/model_servers/tensorflow_model_server_test_client.py @@ -14,20 +14,14 @@ # ============================================================================== """Manual test client for tensorflow_model_server.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function # This is a placeholder for a Google-internal import. import grpc import tensorflow as tf - from tensorflow.core.framework import types_pb2 -from tensorflow.python.platform import flags -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_service_pb2_grpc +from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc tf.compat.v1.app.flags.DEFINE_string('server', 'localhost:8500', 'inception_inference service host:port') diff --git a/tensorflow_serving/model_servers/test_util/tensorflow_model_server_test_base.py b/tensorflow_serving/model_servers/test_util/tensorflow_model_server_test_base.py index 62c591c4d63..de36df5b5ad 100644 --- a/tensorflow_serving/model_servers/test_util/tensorflow_model_server_test_base.py +++ b/tensorflow_serving/model_servers/test_util/tensorflow_model_server_test_base.py @@ -15,9 +15,6 @@ """Tests for tensorflow_model_server.""" -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import atexit import json @@ -28,17 +25,14 @@ import time # This is a placeholder for a Google-internal import. - import grpc -from six.moves import range -from six.moves import urllib import tensorflow as tf - +from six.moves import range, urllib from tensorflow.core.framework import types_pb2 from tensorflow.python.platform import flags from tensorflow.python.saved_model import signature_constants -from tensorflow_serving.apis import predict_pb2 -from tensorflow_serving.apis import prediction_service_pb2_grpc + +from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc FLAGS = flags.FLAGS @@ -87,7 +81,7 @@ def WaitForServerReady(port): try: # Send empty request to missing model - channel = grpc.insecure_channel('localhost:{}'.format(port)) + channel = grpc.insecure_channel(f'localhost:{port}') stub = prediction_service_pb2_grpc.PredictionServiceStub(channel) stub.Predict(request, RPC_TIMEOUT) except grpc.RpcError as error: @@ -101,16 +95,15 @@ def CallREST(url, req, max_attempts=60): """Returns HTTP response body from a REST API call.""" for attempt in range(max_attempts): try: - print('Attempt {}: Sending request to {} with data:\n{}'.format( - attempt, url, req)) + print(f'Attempt {attempt}: Sending request to {url} with data:\n{req}') json_data = json.dumps(req).encode('utf-8') if req is not None else None resp = urllib.request.urlopen(urllib.request.Request(url, data=json_data)) resp_data = resp.read() - print('Received response:\n{}'.format(resp_data)) + print(f'Received response:\n{resp_data}') resp.close() return resp_data except Exception as e: # pylint: disable=broad-except - print('Failed attempt {}. Error: {}'.format(attempt, e)) + print(f'Failed attempt {attempt}. Error: {e}') if attempt == max_attempts - 1: raise print('Retrying...') @@ -190,9 +183,8 @@ def RunServer( return TensorflowModelServerTestBase.model_servers_dict[args_key] port = PickUnusedPort() rest_api_port = PickUnusedPort() - print(('Starting test server on port: {} for model_name: ' - '{}/model_config_file: {}'.format(port, model_name, - model_config_file))) + print(f'Starting test server on port: {port} for model_name: ' + f'{model_name}/model_config_file: {model_config_file}') command = os.path.join( TensorflowModelServerTestBase.TestSrcDirPath(model_server_path), diff --git a/tensorflow_serving/servables/tensorflow/testdata/bad_model_config.txt b/tensorflow_serving/servables/tensorflow/testdata/bad_model_config.txt index 6649d3fd44a..887d07c4356 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/bad_model_config.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/bad_model_config.txt @@ -1 +1 @@ -improperly formatted file \ No newline at end of file +improperly formatted file diff --git a/tensorflow_serving/servables/tensorflow/testdata/export_bad_half_plus_two.py b/tensorflow_serving/servables/tensorflow/testdata/export_bad_half_plus_two.py index d8b58ef1754..68d5d3b6fce 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/export_bad_half_plus_two.py +++ b/tensorflow_serving/servables/tensorflow/testdata/export_bad_half_plus_two.py @@ -21,7 +21,6 @@ import os # This is a placeholder for a Google-internal import. - import tensorflow as tf diff --git a/tensorflow_serving/servables/tensorflow/testdata/export_counter.py b/tensorflow_serving/servables/tensorflow/testdata/export_counter.py index 1e733199b24..282c7a88276 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/export_counter.py +++ b/tensorflow_serving/servables/tensorflow/testdata/export_counter.py @@ -18,9 +18,6 @@ reset_counter, to test Predict service. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function # This is a placeholder for a Google-internal import. import tensorflow as tf diff --git a/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.README b/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.README index d3fcb3d8d85..1b6a59f2654 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.README +++ b/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.README @@ -19,4 +19,3 @@ and is updated using bazel run -c opt parse_example_tflite_with_string cp /tmp/parse_example_tflite parse_example_tflite/00000123/model.tflite ``` - diff --git a/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.py b/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.py index 854322a9f08..744eace9ae9 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.py +++ b/tensorflow_serving/servables/tensorflow/testdata/parse_example_tflite.py @@ -35,7 +35,6 @@ # This is a placeholder for a Google-internal import. import tensorflow.compat.v1 as tf - from tensorflow.lite.tools.signature import signature_def_utils FLAGS = None diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two.py b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two.py index 4c9b7c80157..4fb964beabc 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two.py +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two.py @@ -45,9 +45,6 @@ --device=gpu """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function import argparse import os @@ -55,7 +52,6 @@ # This is a placeholder for a Google-internal import. import tensorflow.compat.v1 as tf - from tensorflow.lite.tools.signature import signature_def_utils from tensorflow.python.lib.io import file_io diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000124/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000124/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000124/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_2_versions/00000124/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_gpu_trt/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_gpu_trt/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_gpu_trt/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_gpu_trt/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mkl/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mkl/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mkl/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mkl/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets.extra/mlmd_uuid b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets.extra/mlmd_uuid index afc2417480e..cffaea71d35 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets.extra/mlmd_uuid +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets.extra/mlmd_uuid @@ -1 +1 @@ -test_mlmd_uuid \ No newline at end of file +test_mlmd_uuid diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_mlmd/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_tf2_cpu/00000123/assets/foo.txt b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_tf2_cpu/00000123/assets/foo.txt index f9ff0366880..56c3e54a43f 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_tf2_cpu/00000123/assets/foo.txt +++ b/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_tf2_cpu/00000123/assets/foo.txt @@ -1 +1 @@ -asset-file-contents \ No newline at end of file +asset-file-contents diff --git a/tensorflow_serving/servables/tensorflow/testdata/tf_text_regression.README b/tensorflow_serving/servables/tensorflow/testdata/tf_text_regression.README index faf81a58f1a..038352e0c66 100644 --- a/tensorflow_serving/servables/tensorflow/testdata/tf_text_regression.README +++ b/tensorflow_serving/servables/tensorflow/testdata/tf_text_regression.README @@ -16,4 +16,3 @@ This model is used to test the integration with TF Text, and is updated using this script: https://github.com/tensorflow/text/blob/master/oss_scripts/model_server/save_models.py - diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 66032984cb2..9ce7b69ea7f 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -187,4 +187,3 @@ FROM binary_build as clean_build RUN bazel clean --expunge --color=yes && \ rm -rf /root/.cache CMD ["/bin/bash"] - diff --git a/tensorflow_serving/tools/docker/Dockerfile.gpu b/tensorflow_serving/tools/docker/Dockerfile.gpu index 80b210d5058..fe92f8ab636 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.gpu @@ -87,4 +87,3 @@ tensorflow_model_server --port=8500 --rest_api_port=8501 \ && chmod +x /usr/bin/tf_serving_entrypoint.sh ENTRYPOINT ["/usr/bin/tf_serving_entrypoint.sh"] - diff --git a/tensorflow_serving/tools/pip_package/setup.py b/tensorflow_serving/tools/pip_package/setup.py index 9531ceb3be7..72c3bb764c6 100644 --- a/tensorflow_serving/tools/pip_package/setup.py +++ b/tensorflow_serving/tools/pip_package/setup.py @@ -25,8 +25,7 @@ import sys -from setuptools import find_packages -from setuptools import setup +from setuptools import find_packages, setup DOCLINES = __doc__.split('\n') diff --git a/tensorflow_serving/util/net_http/client/test_client/public/httpclient.h b/tensorflow_serving/util/net_http/client/test_client/public/httpclient.h index 52b624d9c07..14cb4e51cff 100644 --- a/tensorflow_serving/util/net_http/client/test_client/public/httpclient.h +++ b/tensorflow_serving/util/net_http/client/test_client/public/httpclient.h @@ -46,4 +46,3 @@ inline std::unique_ptr CreateEvHTTPConnection( } // namespace tensorflow #endif // THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_ - diff --git a/third_party/icu/data.patch b/third_party/icu/data.patch index bcea58afeee..2375d94cc53 100644 --- a/third_party/icu/data.patch +++ b/third_party/icu/data.patch @@ -1,9 +1,9 @@ --- a/icu4c/source/common/udata.cpp +++ b/icu4c/source/common/udata.cpp @@ -18,11 +18,10 @@ - + #include "unicode/utypes.h" /* U_PLATFORM etc. */ - + -#ifdef __GNUC__ -/* if gcc -#define ATTRIBUTE_WEAK __attribute__ ((weak)) @@ -14,7 +14,7 @@ +#else +# define ATTRIBUTE_WEAK #endif - + #include "unicode/putil.h" @@ -649,10 +648,10 @@ extern "C" const DataHeader U_DATA_API U_ICUDATA_ENTRY_POINT; * partial-data-library access functions where each returns a pointer @@ -28,7 +28,7 @@ +const void *uprv_getICUData_conversion(void) ATTRIBUTE_WEAK; +const void *uprv_getICUData_other(void) ATTRIBUTE_WEAK; +U_CDECL_END - + /*----------------------------------------------------------------------* * * @@ -709,11 +708,14 @@ openCommonData(const char *path, /* Path from OpenChoice? */ @@ -54,7 +54,7 @@ index e61eb5795c..95c43f2334 100644 @@ -55,6 +55,11 @@ #include "uconfig_local.h" #endif - + +// Tensorflow is statically linked on all platforms. +#ifndef U_STATIC_IMPLEMENTATION +#define U_STATIC_IMPLEMENTATION @@ -62,4 +62,4 @@ index e61eb5795c..95c43f2334 100644 + /** * \def U_DEBUG - * Determines whether to include debugging code. \ No newline at end of file + * Determines whether to include debugging code. diff --git a/third_party/sentencepiece/sentencepiece.patch b/third_party/sentencepiece/sentencepiece.patch index 7e7f80736a8..41d55a91267 100644 --- a/third_party/sentencepiece/sentencepiece.patch +++ b/third_party/sentencepiece/sentencepiece.patch @@ -3,13 +3,13 @@ index 22cd115..97e0bda 100644 --- a/src/bpe_model.cc +++ b/src/bpe_model.cc @@ -21,7 +21,7 @@ - + #include "bpe_model.h" #include "freelist.h" -#include "third_party/absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_map.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/bpe_model_trainer.cc b/src/bpe_model_trainer.cc index 964d44e..ae8983c 100644 @@ -17,12 +17,12 @@ index 964d44e..ae8983c 100644 +++ b/src/bpe_model_trainer.cc @@ -18,7 +18,7 @@ #include - + #include "bpe_model_trainer.h" -#include "third_party/absl/container/flat_hash_set.h" +#include "absl/container/flat_hash_set.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/bpe_model_trainer.h b/src/bpe_model_trainer.h index e011a37..17f6e06 100644 @@ -30,12 +30,12 @@ index e011a37..17f6e06 100644 +++ b/src/bpe_model_trainer.h @@ -20,7 +20,7 @@ #include - + #include "sentencepiece_model.pb.h" -#include "third_party/absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_map.h" #include "trainer_interface.h" - + namespace sentencepiece { diff --git a/src/bpe_model_trainer_test.cc b/src/bpe_model_trainer_test.cc index 173eb9c..2a43c3a 100644 @@ -50,14 +50,14 @@ index 173eb9c..2a43c3a 100644 +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/builder.cc b/src/builder.cc index 378aaa0..1557a07 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -18,10 +18,10 @@ - + #include "builder.h" #include "filesystem.h" -#include "third_party/absl/strings/str_join.h" @@ -68,17 +68,17 @@ index 378aaa0..1557a07 100644 +#include "absl/strings/str_replace.h" +#include "absl/strings/str_split.h" +#include "absl/strings/strip.h" - + #ifdef ENABLE_NFKC_COMPILE #include @@ -36,7 +36,7 @@ - + #include "normalization_rule.h" #include "normalizer.h" -#include "third_party/darts_clone/darts.h" +#include "include/darts.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/builder.h b/src/builder.h index 49d2884..289fab6 100644 @@ -90,7 +90,7 @@ index 49d2884..289fab6 100644 #include "sentencepiece_processor.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" - + namespace sentencepiece { namespace normalizer { diff --git a/src/builder_test.cc b/src/builder_test.cc @@ -104,7 +104,7 @@ index 4acb7b3..1dee5c7 100644 -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/char_model_trainer_test.cc b/src/char_model_trainer_test.cc index 8c2e4b7..e8b4979 100644 @@ -119,7 +119,7 @@ index 8c2e4b7..e8b4979 100644 +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/compile_charsmap_main.cc b/src/compile_charsmap_main.cc index c5a5188..931028b 100644 @@ -133,9 +133,9 @@ index c5a5188..931028b 100644 -#include "third_party/absl/strings/string_view.h" +#include "absl/flags/flag.h" +#include "absl/strings/string_view.h" - + using sentencepiece::normalizer::Builder; - + diff --git a/src/error.cc b/src/error.cc index a226d98..ab4675d 100644 --- a/src/error.cc @@ -157,24 +157,24 @@ index 833c8f7..6a169d9 100644 +++ b/src/filesystem.cc @@ -15,7 +15,7 @@ #include - + #include "filesystem.h" -#include "third_party/absl/memory/memory.h" +#include "absl/memory/memory.h" #include "util.h" - + #if defined(OS_WIN) && defined(UNICODE) && defined(_UNICODE) diff --git a/src/filesystem.h b/src/filesystem.h index e572b4b..dbcce48 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -23,7 +23,7 @@ - + #include "common.h" #include "sentencepiece_processor.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" - + namespace sentencepiece { namespace filesystem { diff --git a/src/filesystem_test.cc b/src/filesystem_test.cc @@ -182,13 +182,13 @@ index 790e756..39ece99 100644 --- a/src/filesystem_test.cc +++ b/src/filesystem_test.cc @@ -14,7 +14,7 @@ - + #include "filesystem.h" #include "testharness.h" -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/init.h b/src/init.h index 090a2d9..acfda8a 100644 @@ -196,15 +196,15 @@ index 090a2d9..acfda8a 100644 +++ b/src/init.h @@ -16,8 +16,8 @@ #define INIT_H_ - + #include "common.h" -#include "third_party/absl/flags/flag.h" -#include "third_party/absl/flags/parse.h" +#include "absl/flags/flag.h" +#include "absl/flags/parse.h" - + ABSL_DECLARE_FLAG(int32, minloglevel); - + diff --git a/src/model_factory.cc b/src/model_factory.cc index be99501..040c00c 100644 --- a/src/model_factory.cc @@ -217,13 +217,13 @@ index be99501..040c00c 100644 +#include "absl/memory/memory.h" #include "unigram_model.h" #include "word_model.h" - + diff --git a/src/model_interface.cc b/src/model_interface.cc index c49be1e..22c6378 100644 --- a/src/model_interface.cc +++ b/src/model_interface.cc @@ -16,8 +16,8 @@ - + #include "model_interface.h" #include "sentencepiece_model.pb.h" -#include "third_party/absl/memory/memory.h" @@ -231,7 +231,7 @@ index c49be1e..22c6378 100644 +#include "absl/memory/memory.h" +#include "absl/strings/str_format.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/model_interface.h b/src/model_interface.h index aef5b53..fc14257 100644 @@ -248,7 +248,7 @@ index aef5b53..fc14257 100644 +#include "absl/strings/string_view.h" +#include "include/darts.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/model_interface_test.cc b/src/model_interface_test.cc index 69ee4e6..26a1e05 100644 @@ -261,7 +261,7 @@ index 69ee4e6..26a1e05 100644 -#include "third_party/absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_map.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/normalizer.cc b/src/normalizer.cc index 100b875..1791bd1 100644 @@ -269,7 +269,7 @@ index 100b875..1791bd1 100644 +++ b/src/normalizer.cc @@ -18,11 +18,11 @@ #include - + #include "common.h" -#include "third_party/absl/memory/memory.h" -#include "third_party/absl/strings/match.h" @@ -282,7 +282,7 @@ index 100b875..1791bd1 100644 +#include "absl/strings/strip.h" +#include "include/darts.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/normalizer.h b/src/normalizer.h index 622bbd2..1326102 100644 @@ -297,7 +297,7 @@ index 622bbd2..1326102 100644 +#include "absl/strings/string_view.h" +#include "include/darts.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/pretokenizer_for_training.cc b/src/pretokenizer_for_training.cc index 049658e..8021511 100644 @@ -305,11 +305,11 @@ index 049658e..8021511 100644 +++ b/src/pretokenizer_for_training.cc @@ -14,7 +14,7 @@ #include - + #include "pretokenizer_for_training.h" -#include "third_party/absl/strings/str_replace.h" +#include "absl/strings/str_replace.h" - + namespace sentencepiece { namespace pretokenizer { diff --git a/src/pretokenizer_for_training.h b/src/pretokenizer_for_training.h @@ -322,7 +322,7 @@ index 2d3bc82..38beaa6 100644 #include "sentencepiece_processor.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" - + namespace sentencepiece { namespace pretokenizer { diff --git a/src/pretokenizer_for_training_test.cc b/src/pretokenizer_for_training_test.cc @@ -336,7 +336,7 @@ index 80f4787..c559eb8 100644 -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "trainer_interface.h" - + namespace sentencepiece { diff --git a/src/sentencepiece_processor.cc b/src/sentencepiece_processor.cc index 1e4e7a0..1ff3990 100644 @@ -364,14 +364,14 @@ index 1e4e7a0..1ff3990 100644 +#include "absl/strings/strip.h" #include "unigram_model.h" #include "util.h" - + diff --git a/src/sentencepiece_processor.h b/src/sentencepiece_processor.h index e8bd5f5..e81ebbf 100644 --- a/src/sentencepiece_processor.h +++ b/src/sentencepiece_processor.h @@ -22,7 +22,7 @@ #include - + #if defined(_USE_INTERNAL_STRING_VIEW) -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" @@ -395,7 +395,7 @@ index 373e73e..829c3d4 100644 +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/sentencepiece_trainer.cc b/src/sentencepiece_trainer.cc index b9fe64f..47ef33c 100644 @@ -419,7 +419,7 @@ index b9fe64f..47ef33c 100644 +#include "absl/strings/strip.h" #include "trainer_factory.h" #include "util.h" - + diff --git a/src/sentencepiece_trainer_test.cc b/src/sentencepiece_trainer_test.cc index e44e66b..fc73b1d 100644 --- a/src/sentencepiece_trainer_test.cc @@ -431,7 +431,7 @@ index e44e66b..fc73b1d 100644 -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/spec_parser.h b/src/spec_parser.h index 2c5a95b..263f2bd 100644 @@ -439,14 +439,14 @@ index 2c5a95b..263f2bd 100644 +++ b/src/spec_parser.h @@ -19,8 +19,8 @@ #include - + #include "sentencepiece_processor.h" -#include "third_party/absl/strings/ascii.h" -#include "third_party/absl/strings/str_split.h" +#include "absl/strings/ascii.h" +#include "absl/strings/str_split.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/spm_decode_main.cc b/src/spm_decode_main.cc index 3382ddc..9dda65c 100644 @@ -461,7 +461,7 @@ index 3382ddc..9dda65c 100644 +#include "absl/flags/flag.h" +#include "absl/strings/str_split.h" #include "util.h" - + ABSL_FLAG(std::string, model, "", "model file name"); diff --git a/src/spm_encode_main.cc b/src/spm_encode_main.cc index 4d12a38..29b7458 100644 @@ -480,7 +480,7 @@ index 4d12a38..29b7458 100644 +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" #include "trainer_interface.h" - + ABSL_FLAG(std::string, model, "", "model file name"); diff --git a/src/spm_export_vocab_main.cc b/src/spm_export_vocab_main.cc index b5d93cb..70a65c1 100644 @@ -492,7 +492,7 @@ index b5d93cb..70a65c1 100644 #include "sentencepiece_processor.h" -#include "third_party/absl/flags/flag.h" +#include "absl/flags/flag.h" - + ABSL_FLAG(std::string, output, "", "Output filename"); ABSL_FLAG(std::string, model, "", "input model file name"); diff --git a/src/spm_normalize_main.cc b/src/spm_normalize_main.cc @@ -505,7 +505,7 @@ index 96da360..8c541b8 100644 #include "sentencepiece_trainer.h" -#include "third_party/absl/flags/flag.h" +#include "absl/flags/flag.h" - + ABSL_FLAG(std::string, model, "", "Model file name"); ABSL_FLAG(bool, use_internal_normalization, false, diff --git a/src/spm_train_main.cc b/src/spm_train_main.cc @@ -525,7 +525,7 @@ index baf8dbf..ba1e811 100644 +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" #include "util.h" - + using sentencepiece::NormalizerSpec; diff --git a/src/testharness.cc b/src/testharness.cc index f6b1efe..daf2d14 100644 @@ -533,12 +533,12 @@ index f6b1efe..daf2d14 100644 +++ b/src/testharness.cc @@ -26,7 +26,7 @@ #include - + #include "common.h" -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/testharness.h b/src/testharness.h index 9879b06..98317ad 100644 @@ -546,7 +546,7 @@ index 9879b06..98317ad 100644 +++ b/src/testharness.h @@ -21,9 +21,9 @@ #include - + #include "common.h" -#include "third_party/absl/flags/flag.h" -#include "third_party/absl/flags/parse.h" @@ -554,7 +554,7 @@ index 9879b06..98317ad 100644 +#include "absl/flags/flag.h" +#include "absl/flags/parse.h" +#include "absl/strings/string_view.h" - + ABSL_DECLARE_FLAG(std::string, test_tmpdir); ABSL_DECLARE_FLAG(std::string, test_srcdir); diff --git a/src/trainer_factory.cc b/src/trainer_factory.cc @@ -562,7 +562,7 @@ index d1d2541..ff594d0 100644 --- a/src/trainer_factory.cc +++ b/src/trainer_factory.cc @@ -14,7 +14,7 @@ - + #include "bpe_model_trainer.h" #include "char_model_trainer.h" -#include "third_party/absl/memory/memory.h" @@ -606,14 +606,14 @@ index f66d59a..8a654ec 100644 -#include "third_party/absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_map.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/trainer_interface_test.cc b/src/trainer_interface_test.cc index 70a51ad..d7f3f0c 100644 --- a/src/trainer_interface_test.cc +++ b/src/trainer_interface_test.cc @@ -16,8 +16,8 @@ - + #include "filesystem.h" #include "testharness.h" -#include "third_party/absl/strings/str_cat.h" @@ -622,15 +622,15 @@ index 70a51ad..d7f3f0c 100644 +#include "absl/strings/str_format.h" #include "trainer_interface.h" #include "util.h" - + diff --git a/src/unicode_script.cc b/src/unicode_script.cc index 583dc30..11b24dc 100644 --- a/src/unicode_script.cc +++ b/src/unicode_script.cc @@ -14,7 +14,7 @@ - + #include - + -#include "third_party/absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_map.h" #include "unicode_script.h" @@ -641,7 +641,7 @@ index f2e67e9..f1b8299 100644 --- a/src/unicode_script_map.h +++ b/src/unicode_script_map.h @@ -14,7 +14,7 @@ - + #ifndef UNICODE_SCRIPT_DATA_H_ #define UNICODE_SCRIPT_DATA_H_ -#include "third_party/absl/container/flat_hash_map.h" @@ -654,14 +654,14 @@ index ab33565..e0b1c4d 100644 --- a/src/unicode_script_test.cc +++ b/src/unicode_script_test.cc @@ -14,7 +14,7 @@ - + #include "common.h" #include "testharness.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" #include "unicode_script.h" #include "util.h" - + diff --git a/src/unigram_model.cc b/src/unigram_model.cc index 3b99060..9c72fb9 100644 --- a/src/unigram_model.cc @@ -669,7 +669,7 @@ index 3b99060..9c72fb9 100644 @@ -22,9 +22,9 @@ #include #include - + -#include "third_party/absl/memory/memory.h" -#include "third_party/absl/strings/str_split.h" -#include "third_party/absl/strings/string_view.h" @@ -678,7 +678,7 @@ index 3b99060..9c72fb9 100644 +#include "absl/strings/string_view.h" #include "unigram_model.h" #include "util.h" - + diff --git a/src/unigram_model.h b/src/unigram_model.h index 448e489..9062f12 100644 --- a/src/unigram_model.h @@ -689,7 +689,7 @@ index 448e489..9062f12 100644 #include "sentencepiece_model.pb.h" -#include "third_party/darts_clone/darts.h" +#include "include/darts.h" - + namespace sentencepiece { namespace unigram { diff --git a/src/unigram_model_test.cc b/src/unigram_model_test.cc @@ -705,7 +705,7 @@ index f93b21c..808e907 100644 +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/unigram_model_trainer.cc b/src/unigram_model_trainer.cc index 9615040..373ec95 100644 @@ -728,7 +728,7 @@ index 91fbeb4..f2d6b36 100644 +++ b/src/unigram_model_trainer.h @@ -21,7 +21,7 @@ #include - + #include "sentencepiece_model.pb.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" @@ -749,18 +749,18 @@ index ffe515e..fdb25f6 100644 +#include "absl/strings/str_join.h" #include "unigram_model_trainer.h" #include "util.h" - + diff --git a/src/util.h b/src/util.h index 0d15863..d4a2d51 100644 --- a/src/util.h +++ b/src/util.h @@ -30,7 +30,7 @@ - + #include "common.h" #include "sentencepiece_processor.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/strings/string_view.h" - + #ifdef SPM_NO_THREADLOCAL #include diff --git a/src/util_test.cc b/src/util_test.cc @@ -768,13 +768,13 @@ index 71d006f..231fc96 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -16,7 +16,7 @@ - + #include "filesystem.h" #include "testharness.h" -#include "third_party/absl/strings/str_cat.h" +#include "absl/strings/str_cat.h" #include "util.h" - + namespace sentencepiece { diff --git a/src/word_model_trainer.cc b/src/word_model_trainer.cc index 0b8b062..b057843 100644 @@ -783,7 +783,7 @@ index 0b8b062..b057843 100644 @@ -15,8 +15,8 @@ #include #include - + -#include "third_party/absl/container/flat_hash_map.h" -#include "third_party/absl/strings/string_view.h" +#include "absl/container/flat_hash_map.h" @@ -805,4 +805,3 @@ index c4a8bc6..366810f 100644 +#include "absl/strings/str_join.h" #include "util.h" #include "word_model_trainer.h" - diff --git a/third_party/tf_text/tftext.patch b/third_party/tf_text/tftext.patch index fbc1e7f0287..852cf9b9db2 100644 --- a/third_party/tf_text/tftext.patch +++ b/third_party/tf_text/tftext.patch @@ -60,7 +60,7 @@ index 7f2c7c3..a9a6e06 100644 + if (kGetOffsets) { output_start_offsets->resize(original_num_tokens + 1); output_start_offsets->back() = input_word_offset_in_text; - + diff --git a/tensorflow_text/tftext.bzl b/tensorflow_text/tftext.bzl index 65430ca..e8584fb 100644 --- a/tensorflow_text/tftext.bzl @@ -97,7 +97,7 @@ index 013a35f..0c20d3e 100644 #include "tensorflow/core/platform/logging.h" +#include "tensorflow/core/public/version.h" #include "tensorflow_text/core/kernels/wordpiece_tokenizer.h" - + namespace tensorflow { @@ -159,7 +160,16 @@ LookupStatus LookupTableVocab::Contains(const absl::string_view key, keys.flat()(0) = tstring(key.data(), key.size()); @@ -114,7 +114,7 @@ index 013a35f..0c20d3e 100644 + return LookupStatus(std::string(status.message())); +#endif + } - + if (static_cast(values.flat()(0)) != kOutOfVocabValue) { *value = true; diff --git a/tensorflow_text/core/kernels/wordpiece_tokenizer.h b/tensorflow_text/core/kernels/wordpiece_tokenizer.h @@ -123,18 +123,17 @@ index d1def5b..c888aeb 100644 +++ b/tensorflow_text/core/kernels/wordpiece_tokenizer.h @@ -16,6 +16,7 @@ #define TENSORFLOW_TEXT_CORE_KERNELS_WORDPIECE_TOKENIZER_H_ - + #include +#include #include - + #include "absl/strings/string_view.h" @@ -25,7 +26,7 @@ namespace text { - + struct LookupStatus { LookupStatus() : error_msg(""), success(true) {} - LookupStatus(const std::string& msg) : error_msg(msg), success(false) {} + LookupStatus(std::string msg) : error_msg(std::move(msg)), success(false) {} std::string error_msg; bool success; - diff --git a/tools/gen_status_stamp.sh b/tools/gen_status_stamp.sh index f8c840d6d8d..32a73498caa 100755 --- a/tools/gen_status_stamp.sh +++ b/tools/gen_status_stamp.sh @@ -35,5 +35,3 @@ if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then else echo "BUILD_SCM_REVISION no_git" fi; - -