Unverified Commit 39bfb57b authored by Harry Mellor's avatar Harry Mellor Committed by GitHub
Browse files

Add API docs link if the CLI arg is a config class (#37432)


Signed-off-by: default avatarHarry Mellor <19981378+hmellor@users.noreply.github.com>
parent c9d838fc
...@@ -108,6 +108,7 @@ from vllm.utils.network_utils import get_ip ...@@ -108,6 +108,7 @@ from vllm.utils.network_utils import get_ip
from vllm.utils.torch_utils import resolve_kv_cache_dtype_string from vllm.utils.torch_utils import resolve_kv_cache_dtype_string
from vllm.v1.attention.backends.registry import AttentionBackendEnum from vllm.v1.attention.backends.registry import AttentionBackendEnum
from vllm.v1.sample.logits_processor import LogitsProcessor from vllm.v1.sample.logits_processor import LogitsProcessor
from vllm.version import __version__ as VLLM_VERSION
if TYPE_CHECKING: if TYPE_CHECKING:
from vllm.model_executor.layers.quantization import QuantizationMethods from vllm.model_executor.layers.quantization import QuantizationMethods
...@@ -243,6 +244,14 @@ NEEDS_HELP = ( ...@@ -243,6 +244,14 @@ NEEDS_HELP = (
) )
def _maybe_add_docs_url(cls: Any) -> str:
"""Generate API docs URL for a vllm config class."""
if not cls.__module__.startswith("vllm.config"):
return ""
version = f"v{VLLM_VERSION}" if "dev" not in VLLM_VERSION else "latest"
return f"\n\nAPI docs: https://docs.vllm.ai/en/{version}/api/vllm/config/#vllm.config.{cls.__name__}"
@functools.lru_cache(maxsize=30) @functools.lru_cache(maxsize=30)
def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]: def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]:
# Save time only getting attr docs if we're generating help text # Save time only getting attr docs if we're generating help text
...@@ -293,6 +302,7 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]: ...@@ -293,6 +302,7 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]:
raise argparse.ArgumentTypeError(repr(e)) from e raise argparse.ArgumentTypeError(repr(e)) from e
kwargs[name]["type"] = parse_dataclass kwargs[name]["type"] = parse_dataclass
kwargs[name]["help"] += _maybe_add_docs_url(dataclass_cls)
kwargs[name]["help"] += f"\n\n{json_tip}" kwargs[name]["help"] += f"\n\n{json_tip}"
elif contains_type(type_hints, bool): elif contains_type(type_hints, bool):
# Creates --no-<name> and --<name> flags # Creates --no-<name> and --<name> flags
......
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