Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the default buildpacks to use paketo and add a tip for tilt #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/modelserving/v1beta1/custom/custom_model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ to run the image build on the cloud and continuously build/deploy new versions f

### Use pack to build and push the custom model server image
```bash
pack build --builder=heroku/buildpacks:20 ${DOCKER_USER}/custom-model:v1
pack build --builder paketobuildpacks/builder:base ${DOCKER_USER}/custom-model:v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samj1912 getting the following error with paketobuildpack, it is working fine with heroku buildpack or manually crafted Dockerfile.

Traceback (most recent call last):
  File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/workspace/model.py", line 15, in <module>
    import kserve
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/kserve/__init__.py", line 17, in <module>
    from kserve.model_server import ModelServer
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/kserve/model_server.py", line 27, in <module>
    import kserve.handlers as handlers
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/kserve/handlers/__init__.py", line 15, in <module>
    from .base import NotFoundHandler  # noqa # pylint: disable=unused-import
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/kserve/handlers/base.py", line 18, in <module>
    from kserve.model_repository import ModelRepository
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/kserve/model_repository.py", line 17, in <module>
    from ray.serve.api import RayServeHandle
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/ray/serve/__init__.py", line 2, in <module>
    from ray.serve.api import (start, get_replica_context, shutdown, ingress,
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/ray/serve/api.py", line 25, in <module>
    from ray.serve.controller import ServeController
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/ray/serve/controller.py", line 13, in <module>
    from ray.serve.deployment_state import ReplicaState, DeploymentStateManager
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/ray/serve/deployment_state.py", line 19, in <module>
    from ray.serve.storage.kv_store import KVStoreBase
  File "/layers/paketo-buildpacks_pip-install/packages/lib/python3.8/site-packages/ray/serve/storage/kv_store.py", line 1, in <module>
    import sqlite3
  File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.8/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.8/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: libsqlite3.so.0: cannot open shared object file: No such file or directory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuzisun it should work now.

samj1912 marked this conversation as resolved.
Show resolved Hide resolved
docker push ${DOCKER_USER}/custom-model:v1
```

Expand Down Expand Up @@ -93,6 +93,8 @@ curl localhost:8080/v1/models/custom-model:predict -d @./input.json

{"predictions": [[14.861763000488281, 13.94291877746582, 13.924378395080566, 12.182709693908691, 12.00634765625]]}
```
!!! tip
You can also use [`tilt`](https://tilt.dev/) along with `pack` and [`paketo`](https://paketo.io/) Buildpacks allowing you make code changes and have them reflected live in your custom inference service. For more details see - [Paketo Python Buildpacks - Enable Process Reloading](https://paketo.io/docs/howto/python/#enable-process-reloading)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks cool, you can create the Tiltfile like following for continuous dev development, we might want to add a bit more instruction for how to do this.

load('ext://pack', 'pack')
k8s_kind('InferenceService', api_version='serving.kserve.io/v1beta1', image_json_path='{.spec.predictor.containers[*].image}')

allow_k8s_contexts('docker-desktop')

pack(
  'yuzisun/tilt-demo-2022',
  ignore=[
    'Tiltfile',
    'service.yaml',
    '.*',
  ],
  live_update = [
    sync('.', '/workspace'),
  ],
  deps=["."],
)
k8s_yaml('service.yaml')
k8s_resource('tilt-demo', extra_pod_selectors={'serving.kserve.io/inferenceservice':'tilt-demo'})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tiltfile I am using looks a bit like -

# -*- mode: Python -*-

version_settings(constraint='>=0.22.1')
load('ext://pack', 'pack')
docker_compose('docker-compose.yml')

pack('myapp',
  builder="paketobuildpacks/builder:full",
  live_update=[
    sync('.', '/workspace'),
  ]
)


## Deploy the Custom Predictor on KServe
### Create the InferenceService
Expand Down