Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def entrypoint():
parser.add_argument("--host", type=str, default="[::]")
parser.add_argument("--port", type=int, default=5009)

args = parser.parse_args()
args, extra_args = parser.parse_known_args()

command = [
"gunicorn",
Expand All @@ -48,6 +48,7 @@ def entrypoint():
"--workers",
str(args.num_workers),
"model_engine_server.inference.forwarding.echo_server:app",
*extra_args,
]
subprocess.run(command)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def entrypoint():
parser.add_argument("--host", type=str, default="[::]")
parser.add_argument("--port", type=int, default=5000)
parser.add_argument("--set", type=str, action="append")
parser.add_argument("--graceful-timeout", type=int, default=600)

args = parser.parse_args()
args, extra_args = parser.parse_known_args()

values = [f"CONFIG_FILE={args.config}"]
if args.set is not None:
Expand All @@ -160,8 +161,11 @@ def entrypoint():
"uvicorn.workers.UvicornWorker",
"--workers",
str(args.num_workers),
"--graceful-timeout",
str(args.graceful_timeout),
*envs,
"model_engine_server.inference.forwarding.http_forwarder:app",
*extra_args,
Copy link
Contributor

Choose a reason for hiding this comment

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

oh wait hmm I think it might be good to just hardcode in the termination grace period seconds as a default here idk

Copy link
Contributor

Choose a reason for hiding this comment

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

extra_args feels like it should be a dict to me (e.g. --key1 val1 --key2 val2 from {key1: val1, key2: val2}), is there such thing as extra_kwargs?

this way we can set a default of graceful-timeout and override it if necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, so default it to 600 seconds? Will do! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait didn't see the second comment when I commented ^that (GitHub is bad at refreshing lol 😅 ). From local testing, parser.parse_known_args() will turn --key1 val1 --key2 val2 into extra_args = ["--key1", "val1", "--key2", "val2"], which seems fine to directly pass? :P

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it's fine to pass; I was hoping for a dict but if we don't get that from argparse then we can just directly pass it

]
subprocess.run(command)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import os
import subprocess

Expand All @@ -8,6 +9,10 @@


def start_server():
parser = argparse.ArgumentParser()
parser.add_argument("--graceful-timeout", type=int, default=600)
args, extra_args = parser.parse_known_args()

# TODO: HTTPS
command = [
"gunicorn",
Expand All @@ -21,7 +26,10 @@ def start_server():
"uvicorn.workers.UvicornWorker",
"--workers",
str(NUM_PROCESSES),
"--graceful-timeout",
str(args.graceful_timeout),
"model_engine_server.inference.sync_inference.fastapi_server:app",
*extra_args,
]
unset_sensitive_envvars()
subprocess.run(command)
Expand Down