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

feat(cli): add CLI command to serve a runner #2920

Merged
merged 19 commits into from
Aug 26, 2022

Conversation

bojiang
Copy link
Member

@bojiang bojiang commented Aug 18, 2022

to arrange our serving CLI/Python APIs like this:

bentoml serve
bentoml serve --production
bentoml serve-grpc
bentoml serve-grpc --production

bentoml start-grpc-server
bentoml start-rest-server
bentoml start-runner-server

The APIs start with start are low-level APIs used in Yatai, would be hidden from the help message for now

run bare servers from container
docker run -it --rm -p 3000:3000 -e BENTOML_SERVE_COMPONENT=rest_server -e BENTOML_SERVE_RUNNER_MAP="asdfasdf=1 py_model.case-1.e2e=tcp://192.168.67.1:4000" general_workflow_service.case-1.e2e:tefgtebeok7iiusu
docker run -it --rm -p 4000:3000 -e BENTOML_SERVE_COMPONENT=runner -e BENTOML_SERVE_RUNNER_NAME=py_model.case-1.e2e general_workflow_service.case-1.e2e:awvtyqreokd4cusu

@bojiang bojiang requested review from ssheng, parano and a team as code owners August 18, 2022 03:09
@bojiang bojiang requested review from sauyon and removed request for a team August 18, 2022 03:09
@bojiang bojiang changed the title fix(cli): add CLI command to serve a runner feat(cli): add CLI command to serve a runner Aug 18, 2022
@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #2920 (5c5a98b) into main (901256c) will decrease coverage by 0.96%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2920      +/-   ##
==========================================
- Coverage   69.88%   68.92%   -0.97%     
==========================================
  Files         121      122       +1     
  Lines        9961    10094     +133     
==========================================
- Hits         6961     6957       -4     
- Misses       3000     3137     +137     
Impacted Files Coverage Δ
bentoml/serve.py 0.00% <0.00%> (ø)
bentoml/start.py 0.00% <0.00%> (ø)
bentoml/_internal/utils/circus/__init__.py 60.00% <0.00%> (-30.00%) ⬇️
bentoml/_internal/utils/formparser.py 18.71% <0.00%> (-1.29%) ⬇️
bentoml/_internal/service/service.py 96.70% <0.00%> (-0.11%) ⬇️
bentoml/__init__.py 100.00% <0.00%> (ø)
bentoml/_internal/io_descriptors/json.py 89.24% <0.00%> (ø)
bentoml/_internal/log.py 85.96% <0.00%> (+3.50%) ⬆️

@@ -11,7 +11,7 @@ _is_sourced() {

_main() {
# if first arg looks like a flag
if [ "${1:0:1}" = '-' ]; then
if [ -z "$@" ] || [ "${1:0:1}" = '-' ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is -z "$@" a superset of "${1:0:1}" = '-'?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really

Copy link
Member Author

Choose a reason for hiding this comment

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

command:
-z "$@" -> true
[ "${1:0:1}" = '-' ] -> false

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor style nit, but I think [ $# -eq 1 ] is clearer than [ -z "$@" ].

bentoml/serve.py Outdated


@inject
def serve_bare_api_server(
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Serve" isn't technically accurate here. How about just start_api_server and start_runner?

type=click.STRING,
default=None,
envvar="BENTOML_SERVE_COMPONENT",
help="[Experimental] Component (`api-server` or `runner`) to serve, if not specified, will serve all components",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it be api_server with a underscore? api_server is how it appears in other references.

bentoml_cli/utils.py Outdated Show resolved Hide resolved
sphinx==4.5.0
setuptools==60.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason for the downgrade?

Copy link
Member Author

Choose a reason for hiding this comment

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

ping @aarnphm

Copy link
Member

Choose a reason for hiding this comment

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

this has to do with the newer version of setuptools and it setup different kind of editables install. It is better to just lock setuptools for now.

@sauyon
Copy link
Contributor

sauyon commented Aug 25, 2022

I think HTTP is more accurate than REST, since our APIs can pretty easily be used to make a non-RESTful server.

type=click.STRING,
default=None,
envvar="BENTOML_SERVE_COMPONENT",
help="[Experimental] Component (`api-server` or `runner`) to serve, if not specified, will serve all components",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
help="[Experimental] Component (`api-server` or `runner`) to serve, if not specified, will serve all components",
help="[EXPERIMENTAL] Component (`api-server` or `runner`) to serve, if not specified, will serve all components",

type=click.STRING,
default=None,
envvar="BENTOML_SERVE_RUNNER_NAME",
help="[Experimental] required if `component` is `runner`, specify the runner name to serve",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
help="[Experimental] required if `component` is `runner`, specify the runner name to serve",
help="[EXPERIMENTAL] required if `component` is `runner`, specify the runner name to serve",

type=click.STRING,
multiple=True,
envvar="BENTOML_SERVE_RUNNER_MAP",
help="[Experimental] required if `component` is `api-server' JSON string of runners map",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
help="[Experimental] required if `component` is `api-server' JSON string of runners map",
help="[EXPERIMENTAL] required if `component` is `api-server' JSON string of runners map",

sphinx==4.5.0
setuptools==60.0.0
Copy link
Member

Choose a reason for hiding this comment

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

this has to do with the newer version of setuptools and it setup different kind of editables install. It is better to just lock setuptools for now.



@inject
def ensure_prometheus_dir(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we duplicating this function?

bentoml_cli/utils.py Outdated Show resolved Hide resolved
bentoml_cli/utils.py Outdated Show resolved Hide resolved
@ssheng ssheng merged commit 7aab4b6 into bentoml:main Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants