1
0
Fork 0

feat(api): add flag to launch debugger

This commit is contained in:
Sean Sube 2023-11-19 21:05:39 -06:00
parent c1f1bf2b36
commit 781b34151c
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 13 additions and 4 deletions

View File

@ -45,6 +45,14 @@ def main():
apply_patches(server)
check_paths(server)
# debug options
if server.debug:
import debugpy
debugpy.listen(5678)
logger.warning("waiting for debugger")
debugpy.wait_for_client()
gc.set_debug(gc.DEBUG_STATS)
# register plugins
exports = load_plugins(server)
success = register_plugins(exports)
@ -60,10 +68,7 @@ def main():
load_platforms(server)
load_wildcards(server)
# debug and misc server options
if is_debug():
gc.set_debug(gc.DEBUG_STATS)
# misc server options
if not server.show_progress:
disable_progress_bar()
disable_progress_bars()

View File

@ -41,6 +41,7 @@ class ServerContext:
worker_retries: int
feature_flags: List[str]
plugins: List[str]
debug: bool
def __init__(
self,
@ -65,6 +66,7 @@ class ServerContext:
worker_retries: Optional[int] = DEFAULT_WORKER_RETRIES,
feature_flags: Optional[List[str]] = None,
plugins: Optional[List[str]] = None,
debug: bool = False,
) -> None:
self.bundle_path = bundle_path
self.model_path = model_path
@ -87,6 +89,7 @@ class ServerContext:
self.worker_retries = worker_retries
self.feature_flags = feature_flags or []
self.plugins = plugins or []
self.debug = debug
self.cache = ModelCache(self.cache_limit)
@ -128,6 +131,7 @@ class ServerContext:
),
feature_flags=environ.get("ONNX_WEB_FEATURE_FLAGS", "").split(","),
plugins=environ.get("ONNX_WEB_PLUGINS", "").split(","),
debug=get_boolean(environ, "ONNX_WEB_DEBUG", False),
)
def has_feature(self, flag: str) -> bool: