Add clipper deployment support#151
Conversation
|
Hello @yubozhao, Thanks for updating this PR.
Comment last updated at 2019-07-16 22:50:54 UTC |
| node_modules/ | ||
| yarn-error.log | ||
| yarn.lock | ||
| .DS_Store |
bentoml/archive/templates.py
Outdated
| """ | ||
|
|
||
| BENTO_SERVICE_DOCKERFILE_CLIPPER_TEMPLATE = """\ | ||
| FROM clipper/python36-closure-container:0.3 |
There was a problem hiding this comment.
add a note on why we use python36 image, even for BentoArchive built in python27
bentoml/archive/templates.py
Outdated
|
|
||
| ENV TINI_VERSION v0.16.1 | ||
| ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini | ||
| RUN chmod +x /usr/bin/tini |
There was a problem hiding this comment.
na, removed it.
done
bentoml/archive/templates.py
Outdated
| RUN chmod +x /usr/bin/tini | ||
| ##### End installation for miniconda3 | ||
|
|
||
| RUN set -x \ |
There was a problem hiding this comment.
move this up to the "apt-get" section above, let's not run apt-get update multiple times in one docker build
bentoml/archive/templates.py
Outdated
| WORKDIR /container | ||
|
|
||
| # update conda base env | ||
| RUN conda env update -n base -f /container/environment.yml |
There was a problem hiding this comment.
shouldn't this be "/container/bento/environment.yml"?
There was a problem hiding this comment.
same for the requirement.txt and setup.sh file below?
There was a problem hiding this comment.
yeah, those weren't done when i made the draft PR.
done now
| shutil.copytree(self.archive_path, model_path) | ||
|
|
||
| image = build_docker_image(snapshot_path) | ||
| self.clipper_conn.register_application(name=self.application_name, |
There was a problem hiding this comment.
I would suggest leaving register_application and link_model_to_app to the user, similar to the "deploy_xxx" commands provided in clipper, it should only deploy the model, without affecting the application
| return | ||
|
|
||
| def check_status(self): | ||
| if self.is_deployed: |
There was a problem hiding this comment.
discussed offline, remove check_status and delete here, will recommend user follow clipper convention on checking the model status and stopping running model instance
bentoml/archive/archiver.py
Outdated
| with open(os.path.join(path, 'Dockerfile-sagemaker'), 'w') as f: | ||
| f.write(BENTO_SERVICE_DOCKERFILE_SAGEMAKER_TEMPLATE) | ||
| with open(os.path.join(path, 'Dockerfile-clipper'), 'w') as f: | ||
| f.write(BENTO_SERVICE_DOCKERFILE_CLIPPER_TEMPLATE) |
There was a problem hiding this comment.
discussed offline, we should handle this similar to DEFAULT_CLIPPER_ENTRY, generate it when calling deploy
There was a problem hiding this comment.
same for BENTO_SERVICE_DOCKERFILE_SAGEMAKER_TEMPLATE above, but this can be in separate PR
| """Clipper deployment for BentoML bundle | ||
| """ | ||
|
|
||
| def __init__(self, clipper_conn, archive_path, api_name, slo_micros=100000): |
There was a problem hiding this comment.
remove slo_micros since we will not handle register application
| return self.application_name | ||
|
|
||
|
|
||
| def deploy_bentoml(clipper_conn, archive_path, api_name): |
There was a problem hiding this comment.
also expose the clipper "labels" here? http://clipper.ai/api/api.html#definition-Model
|
|
||
| def build_docker_image(snapshot_path): | ||
| docker_api = docker.APIClient() | ||
| tag = "something" |
There was a problem hiding this comment.
maybe use BentoArchive version for tag?
| raise BentoMLException( | ||
| 'Please specify api-name, when more than one API is present in the archive') | ||
| application_name = bento_service.name + '-' + api.name | ||
| input_type = 'strings' |
There was a problem hiding this comment.
Why do we still need 'handle_clipper_numbers'? looks like its just strings and bytes we are supporting?
b269c79 to
fb95c00
Compare
fb95c00 to
f12c5a6
Compare
f12c5a6 to
3ee4861
Compare
Codecov Report
@@ Coverage Diff @@
## master #151 +/- ##
==========================================
- Coverage 54.57% 52.55% -2.03%
==========================================
Files 51 53 +2
Lines 2767 2940 +173
==========================================
+ Hits 1510 1545 +35
- Misses 1257 1395 +138
Continue to review full report at Codecov.
|
|
|
||
| def handle_clipper_strings(self, inputs, func): | ||
| def transform_and_predict(input_string): | ||
| # Assuming input string is JSON format |
There was a problem hiding this comment.
Maybe give user a choice between json and csv??
| clipper_conn(clipper_admin.ClipperConnection): Clipper conntection instance | ||
| archive_path(str): Path to the bentoml service archive. | ||
| api_name(str): name of the api that will be running in the clipper cluster | ||
| input_type(str): Input type that clipper accept |
There was a problem hiding this comment.
add some more notes here - especially about the default value and behavior around ImageHnalder check below
| raise BentoMLException( | ||
| "Please specify api-name, when more than one API is present in the archive" | ||
| ) | ||
| application_name = generate_clipper_compatiable_string( |
There was a problem hiding this comment.
give the user the option to provide an application name as the function parameter?
| if item.startswith('bool'): | ||
| return 'boolean' | ||
| return 'object' | ||
| if item.startswith("int"): |
There was a problem hiding this comment.
is this formatted by black? I thought it should be single quote?
There was a problem hiding this comment.
Yes, those formatted by black. I will re-run it to make sure.
There was a problem hiding this comment.
changed back. format script skip string normalization
bentoml/service.py
Outdated
| return self.handler.handle_clipper_strings(inputs, self.func) | ||
|
|
||
| def handle_clipper_bytes(self, inputs): | ||
| return self.handler.handle_clipper_strings(inputs, self.func) |
bentoml/handlers/image_handler.py
Outdated
|
|
||
| def handle_clipper_strings(self, inputs, func): | ||
| raise RuntimeError( | ||
| "Image handler does not support 'strings' input_type \ |
bentoml/deployment/utils.py
Outdated
| sys.stderr.write(error["message"]) | ||
| raise RuntimeError("Error on build - code %s" % error["code"]) | ||
| elif "stream" in line_payload: | ||
| # TODO: move this to logger.info |
There was a problem hiding this comment.
try just use logger.info here? and similarly for the logging.error above?
| # update conda and setup environment and pre-install common ML libraries to speed up docker build | ||
| RUN conda update conda -y \ | ||
| && conda install pip numpy scipy \ | ||
| && pip install six bentoml |
There was a problem hiding this comment.
this is ok for now but we need to pin this to the version that user is using for saving the given BentoArchive
Provide `bentoml.deployment.clipper.deploy_bentoml` for users.
```python
from bentoml.deployment.clipper import deploy_bentoml
deployed_model_name, deployed_model_version = deploy_bentoml(
clipper_connection,
bentoml_service_archive_path,
api_name,
input_type
)
# After model is deployed to clipper cluster, can register application and link up
application and deployed model to be an endpoint in clipper cluster
```
(Thanks for sending a pull request! Please make sure to read the contribution guidelines, then fill out the blanks below.)
What changes were proposed in this pull request?
Does this close any currently open issues?
How was this patch tested?