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

fix: honor host and port config in service decorator #4776

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/_bentoml_impl/server/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def server_on_deployment(svc: AnyService) -> None:
member()


@inject
@inject(squeeze_none=True)
def serve_http(
bento_identifier: str | AnyService,
working_dir: str | None = None,
Expand Down
6 changes: 3 additions & 3 deletions src/bentoml/_internal/bento/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,10 @@ def write_to_bento(self, bento_fs: FS, build_ctx: str) -> None:
"--no-annotate",
]
)
if get_quiet_mode():
pip_compile_args.append("--quiet")
elif get_debug_mode():
if get_debug_mode():
pip_compile_args.append("--verbose")
else:
pip_compile_args.append("--quiet")
logger.info("Locking PyPI package versions.")
cmd = [sys.executable, "-m", "piptools", "compile"]
cmd.extend(pip_compile_args)
Expand Down
2 changes: 1 addition & 1 deletion src/bentoml/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _get_runner_socket_windows(
)


@inject
@inject(squeeze_none=True)
def serve_http_production(
bento_identifier: str,
working_dir: str,
Expand Down
4 changes: 2 additions & 2 deletions src/bentoml/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
RUNNER = "runner"


@inject
@inject(squeeze_none=True)
def start_runner_server(
bento_identifier: str,
working_dir: str,
Expand Down Expand Up @@ -142,7 +142,7 @@ def start_runner_server(
)


@inject
@inject(squeeze_none=True)
def start_http_server(
bento_identifier: str,
runner_map: dict[str, str],
Expand Down
17 changes: 3 additions & 14 deletions src/bentoml_cli/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,23 @@ def cli():
"-p",
"--port",
type=click.INT,
default=BentoMLContainer.http.port.get(),
help="The port to listen on for the REST api server",
envvar="BENTOML_PORT",
show_default=True,
show_envvar=True,
)
@click.option(
"--host",
type=click.STRING,
default=BentoMLContainer.http.host.get(),
help="The host to bind for the REST api server",
envvar="BENTOML_HOST",
show_default=True,
show_envvar=True,
)
@click.option(
"--api-workers",
type=click.INT,
default=BentoMLContainer.api_server_workers.get(),
help="Specify the number of API server workers to start. Default to number of available CPU cores in production mode",
envvar="BENTOML_API_WORKERS",
show_default=True,
show_envvar=True,
hidden=True,
)
@click.option(
Expand All @@ -113,7 +110,6 @@ def cli():
@click.option(
"--backlog",
type=click.INT,
default=BentoMLContainer.api_server_config.backlog.get(),
help="The maximum number of pending connections.",
show_default=True,
hidden=True,
Expand All @@ -136,55 +132,48 @@ def cli():
@click.option(
"--ssl-certfile",
type=str,
default=BentoMLContainer.ssl.certfile.get(),
help="SSL certificate file",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-keyfile",
type=str,
default=BentoMLContainer.ssl.keyfile.get(),
help="SSL key file",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-keyfile-password",
type=str,
default=BentoMLContainer.ssl.keyfile_password.get(),
help="SSL keyfile password",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-version",
type=int,
default=BentoMLContainer.ssl.version.get(),
help="SSL version to use (see stdlib 'ssl' module)",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-cert-reqs",
type=int,
default=BentoMLContainer.ssl.cert_reqs.get(),
help="Whether client certificate is required (see stdlib 'ssl' module)",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-ca-certs",
type=str,
default=BentoMLContainer.ssl.ca_certs.get(),
help="CA certificates file",
show_default=True,
hidden=True,
)
@click.option(
"--ssl-ciphers",
type=str,
default=BentoMLContainer.ssl.ciphers.get(),
help="Ciphers to use (see stdlib 'ssl' module)",
show_default=True,
hidden=True,
Expand Down
55 changes: 12 additions & 43 deletions src/bentoml_cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,25 @@ def cli():
@click.option(
"--port",
type=click.INT,
default=BentoMLContainer.http.port.get(),
help="The port to listen on for the REST api server",
envvar="BENTOML_PORT",
show_default=True,
show_envvar=True,
)
@click.option(
"--host",
type=click.STRING,
default=BentoMLContainer.http.host.get(),
help="The host to bind for the REST api server [defaults: 127.0.0.1(dev), 0.0.0.0(production)]",
envvar="BENTOML_HOST",
show_envvar="BENTOML_HOST",
)
@click.option(
"--backlog",
type=click.INT,
default=BentoMLContainer.api_server_config.backlog.get(),
help="The maximum number of pending connections.",
show_default=True,
show_envvar=True,
)
@click.option(
"--api-workers",
type=click.INT,
default=BentoMLContainer.api_server_workers.get(),
help="Specify the number of API server workers to start. Default to number of available CPU cores in production mode",
envvar="BENTOML_API_WORKERS",
)
Expand All @@ -94,47 +90,20 @@ def cli():
default=None,
show_default=True,
)
@click.option("--ssl-certfile", type=str, help="SSL certificate file")
@click.option("--ssl-keyfile", type=str, help="SSL key file")
@click.option("--ssl-keyfile-password", type=str, help="SSL keyfile password")
@click.option(
"--ssl-certfile",
type=str,
default=BentoMLContainer.ssl.certfile.get(),
help="SSL certificate file",
)
@click.option(
"--ssl-keyfile",
type=str,
default=BentoMLContainer.ssl.keyfile.get(),
help="SSL key file",
)
@click.option(
"--ssl-keyfile-password",
type=str,
default=BentoMLContainer.ssl.keyfile_password.get(),
help="SSL keyfile password",
)
@click.option(
"--ssl-version",
type=int,
default=BentoMLContainer.ssl.version.get(),
help="SSL version to use (see stdlib 'ssl' module)",
"--ssl-version", type=int, help="SSL version to use (see stdlib 'ssl' module)"
)
@click.option(
"--ssl-cert-reqs",
type=int,
default=BentoMLContainer.ssl.cert_reqs.get(),
help="Whether client certificate is required (see stdlib 'ssl' module)",
)
@click.option("--ssl-ca-certs", type=str, help="CA certificates file")
@click.option(
"--ssl-ca-certs",
type=str,
default=BentoMLContainer.ssl.ca_certs.get(),
help="CA certificates file",
)
@click.option(
"--ssl-ciphers",
type=str,
default=BentoMLContainer.ssl.ciphers.get(),
help="Ciphers to use (see stdlib 'ssl' module)",
"--ssl-ciphers", type=str, help="Ciphers to use (see stdlib 'ssl' module)"
)
@click.option(
"--timeout-keep-alive",
Expand All @@ -154,9 +123,9 @@ def start_http_server( # type: ignore (unused warning)
depends: list[str] | None,
runner_map: str | None,
bind: str | None,
port: int,
host: str,
backlog: int,
port: int | None,
host: str | None,
backlog: int | None,
working_dir: str | None,
api_workers: int | None,
timeout: int | None,
Expand Down
Loading