Skip to content
Permalink
Browse files

Use generated YataiServicer interface for deployment RPCs (#251)

* use YataiService(bentoml.proto.YataiServicer)

* Add missing service methods

* auto format

* pylint fix

* # pylint: disable=unused-argument
  • Loading branch information...
parano committed Aug 6, 2019
1 parent 6180555 commit 684aee768803155d7ffd8fcbc39a6cd9e05598f3
Showing with 39 additions and 19 deletions.
  1. +0 −1 bentoml/service.py
  2. +39 −17 bentoml/{deployment/service.py → yatai/__init__.py}
  3. +0 −1 tests/test_service_env.py
@@ -389,7 +389,6 @@ def _init_artifacts(self, artifacts):
for artifact in artifacts:
self._artifacts[artifact.name] = artifact


def _init_env(self, env=None):
if env is None:
# By default use BentoServiceEnv defined on class via @env decorator
@@ -30,61 +30,83 @@

from bentoml.deployment.store import DeploymentStore
from bentoml.exceptions import BentoMLException
from bentoml.proto.yatai_service_pb2_grpc import YataiServicer


LOG = logging.getLogger(__name__)


class DeploymentService(object):
# pylint: disable=unused-argument
class YataiService(YataiServicer):
def __init__(self):
self.store = DeploymentStore()

def apply(self, apply_deployment_request):
def HealthCheck(self, request, context):
raise NotImplementedError('Method not implemented!')

def GetYataiServiceVersion(self, request, context):
raise NotImplementedError('Method not implemented!')

def ApplyDeployment(self, request, context):
try:
deployment_pb = apply_deployment_request.deployment
deployment_pb = request.deployment
operator = get_deployment_operator(deployment_pb)
return operator.apply(apply_deployment_request)
return operator.apply(request)

except BentoMLException:
response = ApplyDeploymentResponse()
# response.status = ...
# LOG.error(....)
return response

def delete(self, delete_deployment_request):
def DeleteDeployment(self, request, context):
try:
deployment_name = delete_deployment_request.deployment_name
deployment_name = request.deployment_name
deployment_pb = self.store.get(deployment_name)
operator = get_deployment_operator(deployment_pb)
return operator.delete(delete_deployment_request)
return operator.delete(request)

except BentoMLException:
response = DeleteDeploymentResponse()
# response.status = ...
# LOG.error(....)
return response

def get(self, get_deployment_request):
# deployment_name = get_deployment_request.deployment_name
def GetDeployment(self, request, context):
# deployment_name = request.deployment_name
# deployment_pb = self.store.get(deployment_name)
# # get deployment status etc
#
# response = GetDeploymentResponse()
# # construct deployment status into GetDeploymentResponse
pass

def describe(self, describe_deployment_request):
# deployment_name = describe_deployment_request.deployment_name
def DescribeDeployment(self, request, context):
# deployment_name = request.deployment_name
# response = DescribeDeploymentResponse()
# # ...
pass

def list(self, list_deployments_request):
def ListDeployments(self, request, context):
# deployment_pb_list = self.store.list(
# list_deployments_request.filter,
# list_deployments_request.labels,
# list_deployments_request.offset,
# list_deployments_request.limit,
# request.filter,
# request.labels,
# request.offset,
# request.limit,
# )
# response = ListDeploymentsResponse()
pass

def AddBento(self, request_iterator, context):
raise NotImplementedError('Method not implemented!')

def RemoveBento(self, request, context):
raise NotImplementedError('Method not implemented!')

def GetBento(self, request, context):
raise NotImplementedError('Method not implemented!')

def ListBento(self, request, context):
raise NotImplementedError('Method not implemented!')


# pylint: enable=unused-argument
@@ -50,7 +50,6 @@ def predict(self, df):


def test_pip_dependencies_with_archive(tmpdir):

@bentoml.env(pip_dependencies=['numpy', 'pandas', 'torch'])
class ServiceWithList(bentoml.BentoService):
@bentoml.api(bentoml.handlers.DataframeHandler)

0 comments on commit 684aee7

Please sign in to comment.
You can’t perform that action at this time.