BentoML icon indicating copy to clipboard operation
BentoML copied to clipboard

Add Yatai deployment APIs to Yatai client

Open parano opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe.

Currently, Yatai provides a few ways to create and manage deployments:

  • Web UI (requires yatai account logged in)
  • REST API (requires API token)
  • kubectl / kubernetes API + BentoDeployment CRD definition YAML file (requires credentials to access the Kubernetes cluster)

The REST API is great for users to automate deployment, without direct access to the K8s cluster. However invoking a REST API call directly is not a great experience, it would be nice to add related API calls to the YataiClient class.

Describe the solution you'd like

Add deployment and bento management APIs to the YataiClient class, e.g.:

yatai_client = bentoml.YataiClient.from_env()

bento = yatai_client.get_bento('my_svc:v1')
assert bento and bento.status.is_ready()

yatai_client.create_deployment('my_deployment', bento.tag, ...)

# For updating a deployment:
yatai_client.update_deployment('my_deployment', bento.tag)


deployment_info = yatai_client.get_deployment('my_deployment')
# check deployment_info.status

This API will also allow us to create more Yatai related CLI commands, e.g.:

bentoml yatai create-deployment {BENTO_TAG} ...

Describe alternatives you've considered

Additional context

parano avatar Apr 08 '22 19:04 parano

I'd be willing to hop on this if you let me :)

Could I get a few pointers on where to start, what the expectations are besides the snippet (eg. how to deal with configuration for the deployment -> class/dict based)?

I've already implemented another standalone client (with very limited functionality) for a project that needed to get urls for relevant runners, so I think I have a general overview about how this can look.

fwindolf avatar Jul 27 '22 09:07 fwindolf

Hi @fwindolf, definitely welcome the contribution!

I assume you already have Yatai deployed and running? If that's the case, the first starting point would be to take a look at the REST API implementation.

  • go to /swagger path of your Yatai deployment and understand the deployment related REST APIs
  • implement the corresponding REST API client in BentoML's Yatai REST client here: https://github.com/bentoml/BentoML/blob/main/bentoml/_internal/yatai_rest_api_client/yatai.py
  • Lastly, define the top-level user-facing client APIs as described in the snippets above. The implementation should go to here: https://github.com/bentoml/BentoML/blob/main/bentoml/_internal/yatai_client/init.py

The top-level user-facing part is probably where we need a bit more explorating, regarding using attrs class or dict or yaml file as deployment configuration. It would be great to have a chat with you and discuss more. Are you in the community slack today?

On a side note, the https://github.com/bentoml/yatai-schemas contains more information about the internal structure used in yatai and yatai deployment component, if you are interested in diving deeper. @yetone would be the best person to help with code review and give feedback on the design/direction.

parano avatar Jul 29 '22 22:07 parano

Thanks for the pointers. I've taken a look and I think I'll be able to find my way into it.

I'll say hi in slack sometime today :)

fwindolf avatar Aug 03 '22 08:08 fwindolf

@fwindolf How's the progress on this? Any help we can provide?

ssheng avatar Sep 13 '22 03:09 ssheng

Hey, I've been working on it and made some progress. But then I left for vacation and haven't touched it since due to shifted prios in the company, but it will probably get to it on friday. Am I blocking someone here?

fwindolf avatar Sep 13 '22 07:09 fwindolf

@fwindolf, thanks for the update. No you are not blocking anyone. Just that we'd like to extend our help if needed. Looking forward to your PR.

ssheng avatar Sep 13 '22 09:09 ssheng