diff --git a/dvc/_debug.py b/dvc/_debug.py index 1c4001b2d7..c40327e140 100644 --- a/dvc/_debug.py +++ b/dvc/_debug.py @@ -198,33 +198,84 @@ def debugtools(args: Optional["Namespace"] = None, **kwargs): def add_debugging_flags(parser): from argparse import SUPPRESS - parser.add_argument("--cprofile", action="store_true", default=False, help=SUPPRESS) - parser.add_argument("--yappi", action="store_true", default=False, help=SUPPRESS) + # For detailed info see: + # https://github.com/iterative/dvc/wiki/Debugging,-Profiling-and-Benchmarking-DVC + args, _ = parser.parse_known_args() + verbose = args.verbose + + def debug_help(msg): + if verbose: + return msg + return SUPPRESS + + parser = parser.add_argument_group("debug options") + + parser.add_argument( + "--cprofile", + action="store_true", + default=False, + help=debug_help("Generate cprofile data for tools like snakeviz / tuna"), + ) + parser.add_argument( + "--cprofile-dump", help=debug_help("Location to dump cprofile file") + ) + parser.add_argument( + "--yappi", + action="store_true", + default=False, + help=debug_help( + "Generate a callgrind file for use with tools like " + "kcachegrind / qcachegrind" + ), + ) parser.add_argument( "--yappi-separate-threads", action="store_true", default=False, - help=SUPPRESS, + help=debug_help("Generate one callgrind file per thread"), ) parser.add_argument( - "--viztracer", action="store_true", default=False, help=SUPPRESS + "--viztracer", + action="store_true", + default=False, + help=debug_help("Generate a viztracer file for use with vizviewer"), ) - parser.add_argument("--viztracer-depth", type=int, help=SUPPRESS) parser.add_argument( - "--viztracer-async", action="store_true", default=False, help=SUPPRESS + "--viztracer-depth", + type=int, + help=debug_help("Set viztracer maximum stack depth"), ) - parser.add_argument("--cprofile-dump", help=SUPPRESS) - parser.add_argument("--pdb", action="store_true", default=False, help=SUPPRESS) parser.add_argument( - "--instrument", action="store_true", default=False, help=SUPPRESS + "--viztracer-async", + action="store_true", + default=False, + help=debug_help("Treat async tasks as threads"), + ) + parser.add_argument( + "--pdb", + action="store_true", + default=False, + help=debug_help("Drop into the pdb/ipdb debugger on any exception"), ) parser.add_argument( - "--instrument-open", action="store_true", default=False, help=SUPPRESS + "--instrument", + action="store_true", + default=False, + help=debug_help("Use pyinstrument CLI profiler"), + ) + parser.add_argument( + "--instrument-open", + action="store_true", + default=False, + help=debug_help("Use pyinstrument web profiler"), ) parser.add_argument( "--show-stack", "--ss", action="store_true", default=False, - help=SUPPRESS, + help=debug_help( + r"Use Ctrl+T on macOS or Ctrl+\ on Linux to print the stack " + "frame currently executing. Unavailable on Windows." + ), ) diff --git a/dvc/cli/parser.py b/dvc/cli/parser.py index fb6b7fe9d5..d38a13bd51 100644 --- a/dvc/cli/parser.py +++ b/dvc/cli/parser.py @@ -137,7 +137,6 @@ def get_parent_parser(): from dvc._debug import add_debugging_flags parent_parser = argparse.ArgumentParser(add_help=False) - add_debugging_flags(parent_parser) log_level_group = parent_parser.add_mutually_exclusive_group() log_level_group.add_argument( "-q", "--quiet", action="count", default=0, help="Be quiet." @@ -145,6 +144,7 @@ def get_parent_parser(): log_level_group.add_argument( "-v", "--verbose", action="count", default=0, help="Be verbose." ) + add_debugging_flags(parent_parser) return parent_parser