From ac710dfd54328a8b668d02ec06033a0ea6985282 Mon Sep 17 00:00:00 2001 From: Aaron <29749331+aarnphm@users.noreply.github.com> Date: Sun, 28 May 2023 10:04:33 -0700 Subject: [PATCH] revert(perf): remove group alias There is no need for this feature Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> --- src/openllm/cli.py | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/openllm/cli.py b/src/openllm/cli.py index 9974d939..93ace953 100644 --- a/src/openllm/cli.py +++ b/src/openllm/cli.py @@ -162,45 +162,9 @@ class OpenLLMCommandGroup(BentoMLCommandGroup): def __init__(self, *args: t.Any, **attrs: t.Any) -> None: super(OpenLLMCommandGroup, self).__init__(*args, **attrs) # these two dictionaries will store known aliases for commands and groups - self._alias_groups: dict[str, tuple[str, click.Group]] = {} self._cached_http: dict[str, t.Any] = {} self._cached_grpc: dict[str, t.Any] = {} - def group(self, *args: t.Any, **attrs: t.Any) -> t.Callable[[F[P]], click.Group]: - """Override the default 'cli.group' with supports for aliases for given group.""" - from click.utils import make_default_short_help - - aliases = attrs.pop("aliases", []) - - def wrapper(f: F[P]) -> click.Group: - from gettext import gettext - - name = attrs.pop("name", f.__name__) - group = super(OpenLLMCommandGroup, self).group(name, *args, **attrs)(f) - if group.short_help: - text = inspect.cleandoc(group.short_help) - elif group.help: - text = make_default_short_help(group.help, 45) - else: - text = "" - - if group.deprecated: - text = gettext("(Deprecated) {text}").format(text=text) - - attrs.setdefault("help", inspect.getdoc(f)) - attrs.setdefault("short_help", text) - if len(aliases) > 0: - for alias in aliases: - aliased_group = super(OpenLLMCommandGroup, self).group(alias, *args, **attrs)(f) - aliased_group.short_help = text + f" (alias for '{name}')" - self._alias_groups[name] = (alias, aliased_group) - - for __, g in self._alias_groups.values(): - g.commands = group.commands - return group - - return wrapper - def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None: cmd_name = self.resolve_alias(cmd_name) if ctx.command.name == "start": @@ -534,7 +498,7 @@ def create_cli() -> click.Group: ctx.exit() - @cli.group(cls=OpenLLMCommandGroup, context_settings=_CONTEXT_SETTINGS, aliases=["start-http"], name="start") + @cli.group(cls=OpenLLMCommandGroup, context_settings=_CONTEXT_SETTINGS, name="start") def _(): """ Start any LLM as a REST server.