Skip to content

Commit 478c4de

Browse files
feat(cli): deprecate braintrust eval and push (#1203)
## Summary `braintrust eval` and `braintrust push` now print a stderr deprecation warning pointing to the standalone [`bt`](https://github.com/braintrustdata/bt) CLI, and are marked `(deprecated)` in `--help`. Both commands keep working unchanged. Follows the approach from #1201 via a shared `cli/_deprecation.py` (`add_deprecated_parser`), independent of `cli/install/` (which is being removed separately). `__main__.py` is untouched. ``` Warning: braintrust eval is deprecated. Use bt eval. Install bt: https://github.com/braintrustdata/bt#installation Warning: braintrust push is deprecated. Use bt functions push. Install bt: https://github.com/braintrustdata/bt#installation ``` --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
1 parent 6086f73 commit 478c4de

3 files changed

Lines changed: 46 additions & 9 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
from argparse import RawDescriptionHelpFormatter
3+
from functools import wraps
4+
5+
6+
def add_deprecated_parser(subparsers, name, summary, parents, handler, *, deprecation):
7+
parser = subparsers.add_parser(
8+
name,
9+
help=f"{summary} (deprecated)",
10+
description=f"{summary}.\n\n{deprecation}",
11+
formatter_class=RawDescriptionHelpFormatter,
12+
parents=parents,
13+
)
14+
15+
@wraps(handler)
16+
def run(args):
17+
print("Warning: " + deprecation.replace("\n", " "), file=sys.stderr)
18+
return handler(args)
19+
20+
parser.set_defaults(func=run)
21+
return parser

‎py/src/braintrust/cli/eval.py‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
from ..logger import Dataset
2525
from ..parameters import RemoteEvalParameters
2626
from ..util import eprint
27+
from ._deprecation import add_deprecated_parser
28+
29+
30+
_DEPRECATION = (
31+
"braintrust eval is deprecated. Use bt eval.\nInstall bt: https://github.com/braintrustdata/bt#installation"
32+
)
2733

2834

2935
INCLUDE = [
@@ -326,10 +332,13 @@ def run(args):
326332

327333

328334
def build_parser(subparsers, parent_parser):
329-
parser = subparsers.add_parser(
335+
parser = add_deprecated_parser(
336+
subparsers,
330337
"eval",
331-
help="Run evals locally.",
332-
parents=[parent_parser],
338+
"Run evals locally",
339+
[parent_parser],
340+
run,
341+
deprecation=_DEPRECATION,
333342
)
334343

335344
parser.add_argument(
@@ -412,5 +421,3 @@ def build_parser(subparsers, parent_parser):
412421
nargs="*",
413422
help="A list of files or directories to run. If no files are specified, the current directory is used.",
414423
)
415-
416-
parser.set_defaults(func=run)

‎py/src/braintrust/cli/push.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
from ..generated_types import IfExists
2525
from ..parameters import serialize_remote_eval_parameters_container
2626
from ..util import add_azure_blob_headers
27+
from ._deprecation import add_deprecated_parser
28+
29+
30+
_DEPRECATION = (
31+
"braintrust push is deprecated. Use bt functions push.\n"
32+
"Install bt: https://github.com/braintrustdata/bt#installation"
33+
)
2734

2835

2936
def _pkg_install_arg(pkg) -> str | None:
@@ -418,10 +425,13 @@ def run(args):
418425

419426
def build_parser(subparsers, parent_parser):
420427
"""Adds the parser for the push subcommand."""
421-
parser = subparsers.add_parser(
428+
parser = add_deprecated_parser(
429+
subparsers,
422430
"push",
423-
help="Push code to Braintrust",
424-
parents=[parent_parser],
431+
"Push code to Braintrust",
432+
[parent_parser],
433+
run,
434+
deprecation=_DEPRECATION,
425435
)
426436
parser.add_argument(
427437
"--api-key",
@@ -447,4 +457,3 @@ def build_parser(subparsers, parent_parser):
447457
help="File to push.",
448458
)
449459
parser.add_argument("--requirements", help="The requirements file to bundle dependencies from.")
450-
parser.set_defaults(func=run)

0 commit comments

Comments
 (0)