Package: min-tfs-client
Minimal Tensor Serving Python ClientA lightweight python client to communicate with Tensor Serving.DescriptionCommunicating with Tensorflow models via Tensor Serving requiresgRPCand Tensorflow-specific protobufs. Thetensorflow-serving-apispackage on PyPI provides these interfaces, but requirestensorflowas a dependency. The Tensorflow python package currently stands at 700 Mb, with much of this space dedicated to libraries and executables required for training, saving, and visualising Tensorflow Models; these libraries are not required at inference time when communicating with Tensorflow Serving.This package exposes a minimal Tensor Serving client that does not include Tensorflow as a dependency. This reduces the overall package size to < 1 Mb. This is particularly useful when deploying web services via AWS Lambda that need to communicate with Tensorflow Serving, as Lambda carries a size limit on deployments.Install from PyPiThis is the quickest way to get started! Just run:pipinstallmin-tfs-clientInstalling from sourceInstallation from source will require the protobuf compilerprotocto be installed and available to the command line (e.g. via thePATHenvironment variable). The protobuf compiler can be downloaded from theprotocolbuffers/protobufGithub repo. Onceprotocis installed and available, you can run:gitclonehttps://github.com/zendesk/min-tfs-client.gitcdmin-tfs-client
pythonsetup.pycompile_pbcopy_grpc
pipinstall.Development InstallationFor dev installation, runpip install -e .instead ofpip install .. Also, you will requiretensorflow-model-serverandtensorflowto be installed to run and modify the integration tests. Specifically:tensorflowis required to run the model generation script (tests/integration/fixtures) that creates a test model for integration testing. It isnotrequired to just run the tests.tensorflow-model-serveris required to serve the model to perform the integration test. The commands that are used to run these tests in Travis are contained in.travis.yml.UsageBasic Usagefrommin_tfs_client.requestsimportTensorServingClientfrommin_tfs_client.tensorsimporttensor_proto_to_ndarrayclient=TensorServingClient(host="127.0.0.1",port=4080,credentials=None)response=client.predict_request(model_name="default",model_version=1,input_dict={# These input keys are model-specific"string_input":np.array(["hello world"]),"float_input":np.array([0.1],dtype=np.float32),"int_input":np.array([2],dtype=np.int64),},)float_output=tensor_proto_to_ndarray(# This output key is model-specificresponse.outputs["float_output"])Running testsRun all tests withpytest-vtests/Run a single test file withpytest<path_to_test_file>Run unit / integration tests withpytesttests/<unitorintegration>Contribution GuidelinesImprovements are always welcome. Please follow these steps to contribute:Submit a Pull Request with a detailed explanation of changesReceive approval from maintainersMaintainers will merge your changesLicence InformationUse of this software is subject to important terms and conditions as set forth in theLICENSEfile.The code contained withinprotobuf_srcs/tensorflowis forked fromTensorflow, and the code contained withinprotobuf_srcs/tensorflow_servingis forked fromTensorflow Serving. Please refer to the individual source files withinprotobuf_srcsfor individual file licence information.