From d9a18ac982b20c5456930c963b6e7495a47961bc Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 3 Jul 2022 13:54:29 +0200 Subject: [PATCH] Print default values --- src/great_ai/__main__.py | 6 +++--- src/great_ai/parse_arguments.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/great_ai/__main__.py b/src/great_ai/__main__.py index 4d03f3c..6c3045e 100644 --- a/src/great_ai/__main__.py +++ b/src/great_ai/__main__.py @@ -43,9 +43,9 @@ def main() -> None: args = parse_arguments() should_auto_reload = not _is_in_production_mode(logger=None) - if args.workers > 1 and should_auto_reload: + if args.worker_count > 1 and should_auto_reload: raise ArgumentValidationError( - "Cannot use auto-reload with multiple workers: set the `--workers=1` CLI argument," + "Cannot use auto-reload with multiple worker_count: set the `--worker_count=1` CLI argument," + "or set the ENVIRONMENT environment variable to `production`." ) @@ -53,7 +53,7 @@ def main() -> None: host=args.host, port=args.port, timeout_keep_alive=args.timeout_keep_alive, - workers=args.workers, + workers=args.worker_count, server_header=False, reload=False, log_config=GREAT_AI_LOGGING_CONFIG, diff --git a/src/great_ai/parse_arguments.py b/src/great_ai/parse_arguments.py index 1ca111c..e816b6b 100644 --- a/src/great_ai/parse_arguments.py +++ b/src/great_ai/parse_arguments.py @@ -12,35 +12,39 @@ def parse_arguments() -> Namespace: help="the name of the file containing your to-be-served function such as `main.py`\n", ) + default_host = "0.0.0.0" parser.add_argument( "--host", type=str, - help="it is passed to uvicorn which starts a server listening on this address", - default="0.0.0.0", + help=f"it is passed to uvicorn which starts a server listening on this address (default: {default_host})", + default=default_host, required=False, ) + default_port = 6060 parser.add_argument( "--port", type=int, - help="it is passed to uvicorn which starts a server listening on this port", - default=6060, + help=f"it is passed to uvicorn which starts a server listening on this port (default: {default_port})", + default=default_port, required=False, ) + default_timeout_keep_alive = 600 parser.add_argument( "--timeout_keep_alive", type=int, - help="it is passed to uvicorn which uses it for timing out requests taking longer than this many seconds", + help=f"it is passed to uvicorn which uses it for timing out requests taking longer than this many seconds (default: {default_timeout_keep_alive})", default=600, required=False, ) + default_worker_count = 1 parser.add_argument( - "--workers", + "--worker_count", type=int, - help="it is passed to uvicorn which starts this many server processes", - default=1, + help=f"it is passed to uvicorn which starts this many server processes (default: {default_worker_count})", + default=default_worker_count, required=False, )