From 2061bafd5c6803577aa6993fba7a4854964ccb9f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:35:06 +0000 Subject: [PATCH 1/4] feat(cli): deprecate braintrust eval and push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > 🤖 **This text was AI-generated.** The Python CLI still runs evals and pushes code, but it does not tell users how to switch to the standalone bt CLI. Reuse the warning and help pattern from https://github.com/braintrustdata/braintrust-sdk-python/pull/1201. Point users to `bt eval` and `bt functions push` without changing how either legacy command runs. Note that Eval() sandbox registration still requires `braintrust push`. Co-authored-by: Abhijeet Prasad --- py/src/braintrust/cli/_deprecation.py | 21 ++++++++ py/src/braintrust/cli/eval.py | 20 ++++++-- py/src/braintrust/cli/install/_deprecation.py | 16 ++---- py/src/braintrust/cli/push.py | 18 +++++-- py/src/braintrust/cli/test_deprecation.py | 51 +++++++++++++++++++ 5 files changed, 104 insertions(+), 22 deletions(-) create mode 100644 py/src/braintrust/cli/_deprecation.py create mode 100644 py/src/braintrust/cli/test_deprecation.py diff --git a/py/src/braintrust/cli/_deprecation.py b/py/src/braintrust/cli/_deprecation.py new file mode 100644 index 000000000..ba78af68c --- /dev/null +++ b/py/src/braintrust/cli/_deprecation.py @@ -0,0 +1,21 @@ +import sys +from argparse import RawDescriptionHelpFormatter +from functools import wraps + + +def add_deprecated_parser(subparsers, name, summary, parents, handler, *, deprecation): + parser = subparsers.add_parser( + name, + help=f"{summary} (deprecated)", + description=f"{summary}.\n\n{deprecation}", + formatter_class=RawDescriptionHelpFormatter, + parents=parents, + ) + + @wraps(handler) + def run(args): + print("Warning: " + deprecation.replace("\n", " "), file=sys.stderr) + return handler(args) + + parser.set_defaults(func=run) + return parser diff --git a/py/src/braintrust/cli/eval.py b/py/src/braintrust/cli/eval.py index f0e5dc890..60650b323 100644 --- a/py/src/braintrust/cli/eval.py +++ b/py/src/braintrust/cli/eval.py @@ -24,6 +24,15 @@ from ..logger import Dataset from ..parameters import RemoteEvalParameters from ..util import eprint +from ._deprecation import add_deprecated_parser + + +_DEPRECATION = ( + "braintrust eval is deprecated. Use bt eval.\n" + "Install bt: https://github.com/braintrustdata/bt#installation\n" + "In bt eval, --filter matches evaluators, not dataset rows, and --jsonl uses a different schema.\n" + "Use BRAINTRUST_API_KEY or bt login instead of --api-key, and --org instead of --org-name." +) INCLUDE = [ @@ -326,10 +335,13 @@ def run(args): def build_parser(subparsers, parent_parser): - parser = subparsers.add_parser( + parser = add_deprecated_parser( + subparsers, "eval", - help="Run evals locally.", - parents=[parent_parser], + "Run evals locally", + [parent_parser], + run, + deprecation=_DEPRECATION, ) parser.add_argument( @@ -412,5 +424,3 @@ def build_parser(subparsers, parent_parser): nargs="*", help="A list of files or directories to run. If no files are specified, the current directory is used.", ) - - parser.set_defaults(func=run) diff --git a/py/src/braintrust/cli/install/_deprecation.py b/py/src/braintrust/cli/install/_deprecation.py index 41929000a..d615c4695 100644 --- a/py/src/braintrust/cli/install/_deprecation.py +++ b/py/src/braintrust/cli/install/_deprecation.py @@ -1,8 +1,8 @@ -import sys import textwrap -from argparse import RawDescriptionHelpFormatter from functools import wraps +from .._deprecation import add_deprecated_parser as _add_deprecated_parser + DEPRECATION = ( "The braintrust install commands are deprecated.\n" @@ -12,17 +12,8 @@ def add_deprecated_parser(subparsers, name, summary, parents, handler): - parser = subparsers.add_parser( - name, - help=f"{summary} (deprecated)", - description=f"{summary}.\n\n{DEPRECATION}", - formatter_class=RawDescriptionHelpFormatter, - parents=parents, - ) - @wraps(handler) def run(args): - print("Warning: " + DEPRECATION.replace("\n", " "), file=sys.stderr) try: return handler(args) except ModuleNotFoundError as exc: @@ -40,5 +31,4 @@ def run(args): ) ) from exc - parser.set_defaults(func=run) - return parser + return _add_deprecated_parser(subparsers, name, summary, parents, run, deprecation=DEPRECATION) diff --git a/py/src/braintrust/cli/push.py b/py/src/braintrust/cli/push.py index b7f374904..ca722bd43 100644 --- a/py/src/braintrust/cli/push.py +++ b/py/src/braintrust/cli/push.py @@ -24,6 +24,14 @@ from ..generated_types import IfExists from ..parameters import serialize_remote_eval_parameters_container from ..util import add_azure_blob_headers +from ._deprecation import add_deprecated_parser + + +_DEPRECATION = ( + "braintrust push is deprecated. Use bt functions push for functions.\n" + "Install bt: https://github.com/braintrustdata/bt#installation\n" + "Eval() sandbox registration still requires braintrust push." +) def _pkg_install_arg(pkg) -> str | None: @@ -418,10 +426,13 @@ def run(args): def build_parser(subparsers, parent_parser): """Adds the parser for the push subcommand.""" - parser = subparsers.add_parser( + parser = add_deprecated_parser( + subparsers, "push", - help="Push code to Braintrust", - parents=[parent_parser], + "Push code to Braintrust", + [parent_parser], + run, + deprecation=_DEPRECATION, ) parser.add_argument( "--api-key", @@ -447,4 +458,3 @@ def build_parser(subparsers, parent_parser): help="File to push.", ) parser.add_argument("--requirements", help="The requirements file to bundle dependencies from.") - parser.set_defaults(func=run) diff --git a/py/src/braintrust/cli/test_deprecation.py b/py/src/braintrust/cli/test_deprecation.py new file mode 100644 index 000000000..38e87fe2b --- /dev/null +++ b/py/src/braintrust/cli/test_deprecation.py @@ -0,0 +1,51 @@ +import shutil +import subprocess +import sysconfig + +import pytest +from braintrust.logger import TEST_API_KEY + + +INSTALL_URL = "https://github.com/braintrustdata/bt#installation" +COMMANDS = [("eval", "bt eval"), ("push", "bt functions push")] + + +@pytest.fixture +def cli(): + executable = shutil.which("braintrust", path=sysconfig.get_path("scripts")) + assert executable is not None + return executable + + +@pytest.mark.parametrize(("command", "replacement"), COMMANDS) +def test_deprecated_command_help(cli, command, replacement): + root_help = subprocess.run([cli, "--help"], capture_output=True, text=True, check=True) + assert "(deprecated)" in next(line for line in root_help.stdout.splitlines() if line.split()[:1] == [command]) + + result = subprocess.run([cli, command, "--help"], capture_output=True, text=True, check=True) + assert result.stderr == "" + assert f"braintrust {command} is deprecated" in result.stdout + assert replacement in result.stdout + assert INSTALL_URL in result.stdout + + +@pytest.mark.parametrize(("command", "replacement"), COMMANDS) +@pytest.mark.parametrize("file_exists", [True, False]) +def test_deprecated_command_warns_on_stderr(cli, command, replacement, file_exists, tmp_path): + path = tmp_path / "eval_empty.py" + if file_exists: + path.touch() + args = ( + ["--no-send-logs", "--terminate-on-failure", path.name] + if command == "eval" + else ["--api-key", TEST_API_KEY, path.name] + ) + result = subprocess.run([cli, command, *args], cwd=tmp_path, capture_output=True, text=True, check=False) + + assert result.returncode == (0 if file_exists else 1), result.stderr + warning = result.stderr.splitlines()[0] + assert warning.startswith(f"Warning: braintrust {command} is deprecated.") + assert replacement in warning + assert INSTALL_URL in warning + assert result.stderr.count("Warning:") == 1 + assert INSTALL_URL not in result.stdout From d30407e42f02bb88497cf8f89d9029087a5a92aa Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:40:36 +0000 Subject: [PATCH 2/4] fix(cli): shorten eval and push deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > 🤖 **This text was AI-generated.** The migration warnings listed differences that distracted from the command to run next. Keep the warnings focused on `bt eval` and `bt functions push` and end each with the installation link. This changes the warning and help text, not command behavior. Follow-up for https://github.com/braintrustdata/braintrust-sdk-python/pull/1203. Co-authored-by: Abhijeet Prasad --- py/src/braintrust/cli/eval.py | 5 +---- py/src/braintrust/cli/push.py | 5 ++--- py/src/braintrust/cli/test_deprecation.py | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/py/src/braintrust/cli/eval.py b/py/src/braintrust/cli/eval.py index 60650b323..08e002b8e 100644 --- a/py/src/braintrust/cli/eval.py +++ b/py/src/braintrust/cli/eval.py @@ -28,10 +28,7 @@ _DEPRECATION = ( - "braintrust eval is deprecated. Use bt eval.\n" - "Install bt: https://github.com/braintrustdata/bt#installation\n" - "In bt eval, --filter matches evaluators, not dataset rows, and --jsonl uses a different schema.\n" - "Use BRAINTRUST_API_KEY or bt login instead of --api-key, and --org instead of --org-name." + "braintrust eval is deprecated. Use bt eval.\nInstall bt: https://github.com/braintrustdata/bt#installation" ) diff --git a/py/src/braintrust/cli/push.py b/py/src/braintrust/cli/push.py index ca722bd43..5d2683b97 100644 --- a/py/src/braintrust/cli/push.py +++ b/py/src/braintrust/cli/push.py @@ -28,9 +28,8 @@ _DEPRECATION = ( - "braintrust push is deprecated. Use bt functions push for functions.\n" - "Install bt: https://github.com/braintrustdata/bt#installation\n" - "Eval() sandbox registration still requires braintrust push." + "braintrust push is deprecated. Use bt functions push.\n" + "Install bt: https://github.com/braintrustdata/bt#installation" ) diff --git a/py/src/braintrust/cli/test_deprecation.py b/py/src/braintrust/cli/test_deprecation.py index 38e87fe2b..c52c52735 100644 --- a/py/src/braintrust/cli/test_deprecation.py +++ b/py/src/braintrust/cli/test_deprecation.py @@ -47,5 +47,6 @@ def test_deprecated_command_warns_on_stderr(cli, command, replacement, file_exis assert warning.startswith(f"Warning: braintrust {command} is deprecated.") assert replacement in warning assert INSTALL_URL in warning + assert warning == f"Warning: braintrust {command} is deprecated. Use {replacement}. Install bt: {INSTALL_URL}" assert result.stderr.count("Warning:") == 1 assert INSTALL_URL not in result.stdout From 29536f6b6200eebc4fa899c624cb31724f2b4943 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:41:26 +0000 Subject: [PATCH 3/4] ref(cli): keep install deprecation code independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > 🤖 **This text was AI-generated.** The install CLI is being removed separately. Keep the eval and push warning helper in `cli/_deprecation.py` and leave all install files as they are on main so that removal does not conflict with these warnings. Follow-up for https://github.com/braintrustdata/braintrust-sdk-python/pull/1203. Co-authored-by: Abhijeet Prasad --- py/src/braintrust/cli/install/_deprecation.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/py/src/braintrust/cli/install/_deprecation.py b/py/src/braintrust/cli/install/_deprecation.py index d615c4695..41929000a 100644 --- a/py/src/braintrust/cli/install/_deprecation.py +++ b/py/src/braintrust/cli/install/_deprecation.py @@ -1,8 +1,8 @@ +import sys import textwrap +from argparse import RawDescriptionHelpFormatter from functools import wraps -from .._deprecation import add_deprecated_parser as _add_deprecated_parser - DEPRECATION = ( "The braintrust install commands are deprecated.\n" @@ -12,8 +12,17 @@ def add_deprecated_parser(subparsers, name, summary, parents, handler): + parser = subparsers.add_parser( + name, + help=f"{summary} (deprecated)", + description=f"{summary}.\n\n{DEPRECATION}", + formatter_class=RawDescriptionHelpFormatter, + parents=parents, + ) + @wraps(handler) def run(args): + print("Warning: " + DEPRECATION.replace("\n", " "), file=sys.stderr) try: return handler(args) except ModuleNotFoundError as exc: @@ -31,4 +40,5 @@ def run(args): ) ) from exc - return _add_deprecated_parser(subparsers, name, summary, parents, run, deprecation=DEPRECATION) + parser.set_defaults(func=run) + return parser From 687f91e48090bd5ace15de6bc508c24aea5e8a2f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:42:28 +0000 Subject: [PATCH 4/4] test(cli): remove deprecation subprocess tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > 🤖 **This text was AI-generated.** Keep the deprecation change limited to the command warnings and help text. Remove the new subprocess test file without changing the existing CLI tests. Follow-up for https://github.com/braintrustdata/braintrust-sdk-python/pull/1203. Co-authored-by: Abhijeet Prasad --- py/src/braintrust/cli/test_deprecation.py | 52 ----------------------- 1 file changed, 52 deletions(-) delete mode 100644 py/src/braintrust/cli/test_deprecation.py diff --git a/py/src/braintrust/cli/test_deprecation.py b/py/src/braintrust/cli/test_deprecation.py deleted file mode 100644 index c52c52735..000000000 --- a/py/src/braintrust/cli/test_deprecation.py +++ /dev/null @@ -1,52 +0,0 @@ -import shutil -import subprocess -import sysconfig - -import pytest -from braintrust.logger import TEST_API_KEY - - -INSTALL_URL = "https://github.com/braintrustdata/bt#installation" -COMMANDS = [("eval", "bt eval"), ("push", "bt functions push")] - - -@pytest.fixture -def cli(): - executable = shutil.which("braintrust", path=sysconfig.get_path("scripts")) - assert executable is not None - return executable - - -@pytest.mark.parametrize(("command", "replacement"), COMMANDS) -def test_deprecated_command_help(cli, command, replacement): - root_help = subprocess.run([cli, "--help"], capture_output=True, text=True, check=True) - assert "(deprecated)" in next(line for line in root_help.stdout.splitlines() if line.split()[:1] == [command]) - - result = subprocess.run([cli, command, "--help"], capture_output=True, text=True, check=True) - assert result.stderr == "" - assert f"braintrust {command} is deprecated" in result.stdout - assert replacement in result.stdout - assert INSTALL_URL in result.stdout - - -@pytest.mark.parametrize(("command", "replacement"), COMMANDS) -@pytest.mark.parametrize("file_exists", [True, False]) -def test_deprecated_command_warns_on_stderr(cli, command, replacement, file_exists, tmp_path): - path = tmp_path / "eval_empty.py" - if file_exists: - path.touch() - args = ( - ["--no-send-logs", "--terminate-on-failure", path.name] - if command == "eval" - else ["--api-key", TEST_API_KEY, path.name] - ) - result = subprocess.run([cli, command, *args], cwd=tmp_path, capture_output=True, text=True, check=False) - - assert result.returncode == (0 if file_exists else 1), result.stderr - warning = result.stderr.splitlines()[0] - assert warning.startswith(f"Warning: braintrust {command} is deprecated.") - assert replacement in warning - assert INSTALL_URL in warning - assert warning == f"Warning: braintrust {command} is deprecated. Use {replacement}. Install bt: {INSTALL_URL}" - assert result.stderr.count("Warning:") == 1 - assert INSTALL_URL not in result.stdout