How to use the bentoml.yatai.status.Status.OK function in bentoml

To help you get started, we’ve selected a few bentoml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bentoml / BentoML / bentoml / deployment / serverless / gcp_function.py View on Github external
stage=deployment_pb.namespace,
                )
                try:
                    response = call_serverless_command(["info"], serverless_project_dir)
                    info_json = parse_serverless_info_response_to_json_string(response)
                    state = DeploymentState(
                        state=DeploymentState.RUNNING, info_json=info_json
                    )
                    state.timestamp.GetCurrentTime()
                except BentoMLException as e:
                    state = DeploymentState(
                        state=DeploymentState.ERROR, error_message=str(e)
                    )
                    state.timestamp.GetCurrentTime()

            return DescribeDeploymentResponse(status=Status.OK(), state=state)
        except BentoMLException as error:
            return DescribeDeploymentResponse(status=error.status_proto)
github bentoml / BentoML / bentoml / yatai / yatai_service_impl.py View on Github external
def UpdateBento(self, request, context=None):
        try:
            # TODO: validate request
            if request.upload_status:
                self.bento_metadata_store.update_upload_status(
                    request.bento_name, request.bento_version, request.upload_status
                )
            if request.service_metadata:
                self.bento_metadata_store.update_bento_service_metadata(
                    request.bento_name, request.bento_version, request.service_metadata
                )
            return UpdateBentoResponse(status=Status.OK())
        except BentoMLException as e:
            logger.error("RPC ERROR UpdateBento: %s", e)
            return UpdateBentoResponse(status=e.status_proto)
github bentoml / BentoML / bentoml / yatai / yatai_service_impl.py View on Github external
def GetBento(self, request, context=None):
        try:
            # TODO: validate request
            bento_metadata_pb = self.bento_metadata_store.get(
                request.bento_name, request.bento_version
            )

            if bento_metadata_pb:
                return GetBentoResponse(status=Status.OK(), bento=bento_metadata_pb)
            else:
                return GetBentoResponse(
                    status=Status.NOT_FOUND(
                        "Bento `{}:{}` is not found".format(
                            request.bento_name, request.bento_version
                        )
                    )
                )
        except BentoMLException as e:
            logger.error("RPC ERROR GetBento: %s", e)
            return GetBentoResponse(status=e.status_proto)
github bentoml / BentoML / bentoml / deployment / serverless / gcp_function.py View on Github external
)
            with TempDirectory() as serverless_project_dir:
                generate_gcp_function_serverless_config(
                    deployment_pb.name,
                    api_names,
                    serverless_project_dir,
                    gcp_config.region,
                    # BentoML namespace is mapping to serverless stage.
                    stage=deployment_pb.namespace,
                )
                try:
                    response = call_serverless_command(
                        ['remove'], serverless_project_dir
                    )
                    if "Serverless: Stack removal finished..." in response:
                        status = Status.OK()
                    else:
                        status = Status.ABORTED()
                except BentoMLException as e:
                    status = Status.INTERNAL(str(e))

            return DeleteDeploymentResponse(status=status)
        except BentoMLException as error:
            return DeleteDeploymentResponse(status=error.status_proto)
github bentoml / BentoML / bentoml / deployment / sagemaker / __init__.py View on Github external
f"'{sagemaker_endpoint_name}'",
                )

            logger.debug("AWS describe endpoint response: %s", endpoint_status_response)
            endpoint_status = endpoint_status_response["EndpointStatus"]

            service_state = ENDPOINT_STATUS_TO_STATE[endpoint_status]

            deployment_state = DeploymentState(
                state=service_state,
                info_json=json.dumps(endpoint_status_response, default=str),
            )
            deployment_state.timestamp.GetCurrentTime()

            return DescribeDeploymentResponse(
                state=deployment_state, status=Status.OK()
            )
        except BentoMLException as error:
            return DescribeDeploymentResponse(status=error.status_proto)
github bentoml / BentoML / bentoml / yatai / yatai_service_impl.py View on Github external
def DangerouslyDeleteBento(self, request, context=None):
        try:
            # TODO: validate request
            self.bento_metadata_store.dangerously_delete(
                request.bento_name, request.bento_version
            )
            self.repo.dangerously_delete(request.bento_name, request.bento_version)
            return DangerouslyDeleteBentoResponse(status=Status.OK())
        except BentoMLException as e:
            logger.error("RPC ERROR DangerouslyDeleteBento: %s", e)
            return DangerouslyDeleteBentoResponse(status=e.status_proto)