Unverified Commit 491a2109 authored by Abhishek Gupta's avatar Abhishek Gupta Committed by GitHub
Browse files

fix: correct typos in help text and add missing docstrings (#5607)


Signed-off-by: default avatarAbhishek Kumar Gupta <mail2abhishekgupta@gmail.com>
parent 7de80960
......@@ -7,7 +7,7 @@
# - OpenAI HTTP server.
# - Auto-discovery: Watches etcd for engine/worker registration (via `register_llm`).
# - Pre-processor: Prompt templating and tokenization.
# - Router, defaulting to round-robin (TODO: Add flags to enable KV routing).
# - Router, defaulting to round-robin. Use --router-mode to switch (round-robin, random, kv).
#
# Pass `--interactive` or `-i` for text chat instead of HTTP server.
#
......@@ -86,6 +86,11 @@ def validate_model_path(value):
def parse_args():
"""Parse command-line arguments for the Dynamo frontend.
Returns:
argparse.Namespace: Parsed command-line arguments.
"""
parser = argparse.ArgumentParser(
description="Dynamo Frontend: HTTP+Pre-processor+Router",
formatter_class=argparse.RawTextHelpFormatter, # To preserve multi-line help formatting
......@@ -244,7 +249,7 @@ def parse_args():
parser.add_argument(
"--model-path",
type=validate_model_path,
help="Path to model directory on disk (e.g., /tmp/model_cache/lama3.2_1B/)",
help="Path to model directory on disk (e.g., /tmp/model_cache/llama3.2_1B/)",
)
parser.add_argument(
"--metrics-prefix",
......@@ -286,7 +291,7 @@ def parse_args():
type=str,
choices=["etcd", "file", "mem"],
default=os.environ.get("DYN_STORE_KV", "etcd"),
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
)
parser.add_argument(
"--request-plane",
......@@ -315,6 +320,11 @@ def parse_args():
async def async_main():
"""Main async entry point for the Dynamo frontend.
Initializes the distributed runtime, configures routing, and starts
the HTTP server or interactive mode based on command-line arguments.
"""
# The system status server port is a worker concern.
#
# Serve tests set DYN_SYSTEM_PORT for the worker, but aggregated launch scripts
......@@ -428,10 +438,16 @@ async def async_main():
async def graceful_shutdown(runtime):
"""Handle graceful shutdown of the distributed runtime.
Args:
runtime: The DistributedRuntime instance to shut down.
"""
runtime.shutdown()
def main():
"""Entry point for the Dynamo frontend CLI."""
uvloop.run(async_main())
......
......@@ -153,6 +153,11 @@ def parse_bootstrap_ports(ports_str: str | None) -> list[int]:
def parse_args():
"""Parse command-line arguments for the Dynamo mocker engine.
Returns:
argparse.Namespace: Parsed command-line arguments.
"""
parser = argparse.ArgumentParser(
description="Mocker engine for testing Dynamo LLM infrastructure with vLLM-style CLI.",
formatter_class=argparse.RawDescriptionHelpFormatter,
......@@ -315,7 +320,7 @@ def parse_args():
type=str,
choices=["etcd", "file", "mem"],
default=os.environ.get("DYN_STORE_KV", "etcd"),
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
)
parser.add_argument(
"--request-plane",
......
......@@ -108,7 +108,7 @@ DYNAMO_ARGS: Dict[str, Dict[str, Any]] = {
"type": str,
"choices": ["etcd", "file", "mem"],
"default": os.environ.get("DYN_STORE_KV", "etcd"),
"help": "Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
"help": "Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
},
"request-plane": {
"flags": ["--request-plane"],
......@@ -196,6 +196,7 @@ class Config:
def _preprocess_for_encode_config(
config: Config,
) -> Dict[str, Any]: # pyright: ignore[reportUnusedFunction]
"""Convert Config object to dictionary for encoding."""
return {
"server_args": config.server_args,
"dynamo_args": config.dynamo_args,
......
......@@ -106,10 +106,23 @@ class Config:
def _preprocess_for_encode_config(
obj: Config,
) -> dict: # pyright: ignore[reportUnusedFunction]
"""Convert Config object to dictionary for encoding."""
return obj.__dict__
def parse_endpoint(endpoint: str) -> tuple[str, str, str]:
"""Parse a Dynamo endpoint string into its components.
Args:
endpoint: Endpoint string in format 'namespace.component.endpoint'
or 'dyn://namespace.component.endpoint'.
Returns:
Tuple of (namespace, component, endpoint_name).
Raises:
ValueError: If endpoint format is invalid.
"""
endpoint_str = endpoint.replace("dyn://", "", 1)
endpoint_parts = endpoint_str.split(".")
if len(endpoint_parts) != 3:
......@@ -122,6 +135,11 @@ def parse_endpoint(endpoint: str) -> tuple[str, str, str]:
def cmd_line_args():
"""Parse command-line arguments for the TensorRT-LLM backend.
Returns:
Config: Parsed configuration object.
"""
parser = argparse.ArgumentParser(
description="TensorRT-LLM server integrated with Dynamo LLM."
)
......@@ -306,7 +324,7 @@ def cmd_line_args():
type=str,
choices=["etcd", "file", "mem"],
default=os.environ.get("DYN_STORE_KV", "etcd"),
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
)
parser.add_argument(
"--request-plane",
......
......@@ -102,10 +102,16 @@ class Config:
@register_encoder(Config)
def _preprocess_for_encode_config(config: Config) -> Dict[str, Any]:
"""Convert Config object to dictionary for encoding."""
return config.__dict__
def parse_args() -> Config:
"""Parse command-line arguments for the vLLM backend.
Returns:
Config: Parsed configuration object.
"""
parser = FlexibleArgumentParser(
description="vLLM server integrated with Dynamo LLM."
)
......@@ -243,7 +249,7 @@ def parse_args() -> Config:
type=str,
choices=["etcd", "file", "mem"],
default=os.environ.get("DYN_STORE_KV", "etcd"),
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
help="Which key-value backend to use: etcd, mem, file. Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details. File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.",
)
parser.add_argument(
"--request-plane",
......
......@@ -121,7 +121,7 @@ pub struct Flags {
pub migration_limit: Option<u32>,
/// Which key-value backend to use: etcd, mem, file.
/// Etcd uses the ETCD_* env vars (e.g. ETCD_ENPOINTS) for connection details.
/// Etcd uses the ETCD_* env vars (e.g. ETCD_ENDPOINTS) for connection details.
/// File uses root dir from env var DYN_FILE_KV or defaults to $TMPDIR/dynamo_store_kv.
#[arg(long, default_value = "etcd", value_parser = ["etcd", "file", "mem"])]
pub store_kv: String,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment