Skip to content

Commit 2f5f79e

Browse files
committed
cleanup for the human
1 parent 5c8fbf6 commit 2f5f79e

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

codeflash/code_utils/checkpoint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from rich.prompt import Confirm
1212

13+
from codeflash.cli_cmds.console import console
14+
1315
if TYPE_CHECKING:
1416
import argparse
1517

@@ -142,8 +144,9 @@ def ask_should_use_checkpoint_get_functions(args: argparse.Namespace) -> Optiona
142144
if previous_checkpoint_functions and Confirm.ask(
143145
"Previous Checkpoint detected from an incomplete optimization run, shall I continue the optimization from that point?",
144146
default=True,
147+
console=console,
145148
):
146-
pass
149+
console.rule()
147150
else:
148151
previous_checkpoint_functions = None
149152
return previous_checkpoint_functions

codeflash/discovery/functions_to_optimize.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import git
1414
import libcst as cst
1515
from pydantic.dataclasses import dataclass
16+
from rich.console import Console
17+
from rich.tree import Tree
1618

1719
from codeflash.api.cfapi import get_blocklisted_functions, is_function_being_optimized_again
1820
from codeflash.cli_cmds.console import DEBUG_MODE, console, logger
@@ -37,6 +39,9 @@
3739

3840
from codeflash.models.models import CodeOptimizationContext
3941
from codeflash.verification.verification_utils import TestConfig
42+
from rich import box
43+
from rich.panel import Panel
44+
from rich.text import Text
4045

4146

4247
@dataclass(frozen=True)
@@ -594,20 +599,22 @@ def filter_functions(
594599

595600
if not disable_logs:
596601
log_info = {
597-
f"{test_functions_removed_count} test function{'s' if test_functions_removed_count != 1 else ''}": test_functions_removed_count,
598-
f"{site_packages_removed_count} site-package function{'s' if site_packages_removed_count != 1 else ''}": site_packages_removed_count,
599-
f"{malformed_paths_count} non-importable file path{'s' if malformed_paths_count != 1 else ''}": malformed_paths_count,
600-
f"{non_modules_removed_count} function{'s' if non_modules_removed_count != 1 else ''} outside module-root": non_modules_removed_count,
601-
f"{ignore_paths_removed_count} file{'s' if ignore_paths_removed_count != 1 else ''} from ignored paths": ignore_paths_removed_count,
602-
f"{submodule_ignored_paths_count} file{'s' if submodule_ignored_paths_count != 1 else ''} from ignored submodules": submodule_ignored_paths_count,
603-
f"{blocklist_funcs_removed_count} function{'s' if blocklist_funcs_removed_count != 1 else ''} as previously optimized": blocklist_funcs_removed_count,
604-
f"{previous_checkpoint_functions_removed_count} function{'s' if previous_checkpoint_functions_removed_count != 1 else ''} skipped from checkpoint": previous_checkpoint_functions_removed_count,
602+
"Test functions removed": (test_functions_removed_count, "yellow"),
603+
"Site-package functions removed": (site_packages_removed_count, "magenta"),
604+
"Non-importable file paths": (malformed_paths_count, "red"),
605+
"Functions outside module-root": (non_modules_removed_count, "cyan"),
606+
"Files from ignored paths": (ignore_paths_removed_count, "blue"),
607+
"Files from ignored submodules": (submodule_ignored_paths_count, "bright_black"),
608+
"Blocklisted functions removed": (blocklist_funcs_removed_count, "bright_red"),
609+
"Functions skipped from checkpoint": (previous_checkpoint_functions_removed_count, "green"),
605610
}
606-
log_string = "\n".join([k for k, v in log_info.items() if v > 0])
607-
if log_string:
608-
logger.info(f"Ignoring: {log_string}")
611+
tree = Tree(Text("Ignored functions and files", style="bold"))
612+
for label, (count, color) in log_info.items():
613+
if count > 0:
614+
tree.add(Text(f"{label}: {count}", style=color))
615+
if len(tree.children) > 0:
616+
console.print(tree)
609617
console.rule()
610-
611618
return {Path(k): v for k, v in filtered_modified_functions.items() if v}, functions_count
612619

613620

0 commit comments

Comments
 (0)