Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/ogx/cli/letsgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the root directory of this source tree.

import argparse
import warnings
from typing import Any

from ogx.cli.stack.lets_go import add_letsgo_arguments, run_letsgo_cmd
Expand All @@ -14,12 +15,33 @@
class LetsGo(Subcommand):
"""Auto-detect providers, generate runtime config, and start the stack."""

def __init__(self, subparsers: Any) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"go",
prog="ogx go",
description="Auto-detect providers and start the stack",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
self._add_arguments()
self.parser.set_defaults(func=self._run_cmd)

def _add_arguments(self) -> None:
add_letsgo_arguments(self.parser)

def _run_cmd(self, args: argparse.Namespace) -> None:
run_letsgo_cmd(args, self.parser)


class LetsGoDeprecated(Subcommand):
"""Backward-compatible alias for 'ogx go' (deprecated)."""

def __init__(self, subparsers: Any) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"letsgo",
prog="ogx letsgo",
description="Auto-detect providers and start the stack",
description="Auto-detect providers and start the stack (deprecated, use 'ogx go' instead)",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
self._add_arguments()
Expand All @@ -29,4 +51,9 @@ def _add_arguments(self) -> None:
add_letsgo_arguments(self.parser)

def _run_cmd(self, args: argparse.Namespace) -> None:
warnings.warn(
"'ogx letsgo' is deprecated and will be removed in a future release. Use 'ogx go' instead.",
FutureWarning,
stacklevel=1,
)
run_letsgo_cmd(args, self.parser)
3 changes: 2 additions & 1 deletion src/ogx/cli/ogx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Initialize logging early before any loggers get created
setup_logging()

from .letsgo import LetsGo
from .letsgo import LetsGo, LetsGoDeprecated
from .run import Run
from .stack import StackParser # type: ignore[attr-defined]
from .stack.utils import print_subcommand_description
Expand All @@ -36,6 +36,7 @@ def __init__(self) -> None:

# Add sub-commands
LetsGo.create(subparsers)
LetsGoDeprecated.create(subparsers)
Run.create(subparsers)
StackParser.create(subparsers)

Expand Down
14 changes: 7 additions & 7 deletions src/ogx/cli/stack/lets_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ def run_letsgo_cmd(args: argparse.Namespace, parser: argparse.ArgumentParser) ->
if not has_inference:
parser.error("No inference providers detected. Nothing to run.")

distro_dir = DISTRIBS_BASE_DIR / "letsgo-run" if args.persist_config else Path(tempfile.mkdtemp())
distro_dir = DISTRIBS_BASE_DIR / "go-run" if args.persist_config else Path(tempfile.mkdtemp())
os.makedirs(distro_dir, exist_ok=True)

try:
run_config = run_config_from_dynamic_config_spec(
dynamic_config_spec=providers_spec,
distro_dir=distro_dir,
distro_name="letsgo-run",
distro_name="go-run",
)
except ValueError as e:
cprint(str(e), color="red", file=sys.stderr)
Expand Down Expand Up @@ -360,16 +360,16 @@ def _probe_endpoint(


class StackLetsGo(Subcommand):
"""Auto-detect providers, generate runtime config, and start the stack (deprecated, use 'ogx letsgo' instead)."""
"""Auto-detect providers, generate runtime config, and start the stack (deprecated, use 'ogx go' instead)."""

def __init__(self, subparsers: Any) -> None:
super().__init__()
self.parser = subparsers.add_parser(
"letsgo",
prog="ogx stack letsgo",
"go",
prog="ogx stack go",
description="""Auto-detect providers and start the stack.

NOTE: 'ogx stack letsgo' is deprecated. Use 'ogx letsgo' instead.""",
NOTE: 'ogx stack go' is deprecated. Use 'ogx go' instead.""",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
self._add_arguments()
Expand All @@ -380,7 +380,7 @@ def _add_arguments(self) -> None:

def _run_stack_lets_go_cmd(self, args: argparse.Namespace) -> None:
warnings.warn(
"'ogx stack letsgo' is deprecated and will be removed in a future release. Use 'ogx letsgo' instead.",
"'ogx stack go' is deprecated and will be removed in a future release. Use 'ogx go' instead.",
FutureWarning,
stacklevel=1,
)
Expand Down
26 changes: 23 additions & 3 deletions tests/unit/cli/test_stack_lets_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

"""Unit tests for `ogx letsgo` and `ogx stack letsgo` CLI commands."""
"""Unit tests for `ogx go` and `ogx stack go` CLI commands."""

import argparse
import warnings
Expand All @@ -13,7 +13,7 @@
import httpx
import pytest

from ogx.cli.letsgo import LetsGo
from ogx.cli.letsgo import LetsGo, LetsGoDeprecated
from ogx.cli.stack.lets_go import (
_CLAUDE_CODE_ALIASES,
_CLAUDE_CODE_PROVIDER_PRIORITY,
Expand All @@ -36,6 +36,12 @@ def top_level_letsgo() -> LetsGo:
return LetsGo(subparsers)


@pytest.fixture
def top_level_letsgo_deprecated() -> LetsGoDeprecated:
subparsers = argparse.ArgumentParser().add_subparsers()
return LetsGoDeprecated(subparsers)


class TestArguments:
def test_defaults(self, lets_go: StackLetsGo):
args = lets_go.parser.parse_args([])
Expand Down Expand Up @@ -452,7 +458,7 @@ def test_stack_letsgo_emits_deprecation_warning(self, lets_go: StackLetsGo):
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
assert len(future_warnings) == 1
assert "deprecated" in str(future_warnings[0].message)
assert "ogx letsgo" in str(future_warnings[0].message)
assert "ogx go" in str(future_warnings[0].message)

def test_top_level_letsgo_no_deprecation_warning(self, top_level_letsgo: LetsGo):
with (
Expand All @@ -466,6 +472,20 @@ def test_top_level_letsgo_no_deprecation_warning(self, top_level_letsgo: LetsGo)
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
assert len(future_warnings) == 0

def test_top_level_letsgo_deprecated_emits_deprecation_warning(self, top_level_letsgo_deprecated: LetsGoDeprecated):
with (
patch("ogx.cli.letsgo.run_letsgo_cmd"),
warnings.catch_warnings(record=True) as w,
):
warnings.simplefilter("always")
args = top_level_letsgo_deprecated.parser.parse_args([])
top_level_letsgo_deprecated._run_cmd(args)

future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
assert len(future_warnings) == 1
assert "deprecated" in str(future_warnings[0].message)
assert "ogx go" in str(future_warnings[0].message)


class TestClaudeCodeAliases:
def test_anthropic_chosen_over_others(self):
Expand Down
Loading