Skip to content

Commit f983449

Browse files
committed
early exit
1 parent de74e68 commit f983449

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def check_formatter_installed(formatter_cmds: list[str], exit_on_failure: bool =
2626
return True
2727

2828
exe_name = cmd_tokens[0]
29-
command_str = " ".join(formatter_cmds)
29+
command_str = " ".join(formatter_cmds).replace(" $file", "")
3030

3131
if shutil.which(exe_name) is None:
3232
logger.error(
33-
f"⚠️ Formatter command not found: {command_str}\n"
34-
f"Please install '{exe_name}' or update the 'formatter-cmds' in your pyproject.toml config."
33+
f"Could not find formatter: {command_str}\n"
34+
f"Please install it or update 'formatter-cmds' in your codeflash configuration"
3535
)
3636
return False
3737

@@ -44,15 +44,12 @@ def check_formatter_installed(formatter_cmds: list[str], exit_on_failure: bool =
4444
return True
4545
except FileNotFoundError:
4646
logger.error(
47-
f"⚠️ Formatter command not found: {command_str}\n"
48-
f"Please install '{exe_name}' or update the 'formatter-cmds' in your pyproject.toml config."
47+
f"Could not find formatter: {command_str}\n"
48+
f"Please install it or update 'formatter-cmds' in your codeflash configuration"
4949
)
5050
return False
5151
except Exception as e:
52-
logger.error(
53-
f"⚠️ Error running formatter '{command_str}': {e}\n"
54-
f"Please verify the 'formatter-cmds' in your pyproject.toml config."
55-
)
52+
logger.error(f"Formatter failed to run: {command_str}\nError: {e}")
5653
return False
5754

5855

codeflash/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from codeflash.cli_cmds.cli import parse_args, process_pyproject_config
1010
from codeflash.cli_cmds.cmd_init import CODEFLASH_LOGO, ask_run_end_to_end_test
1111
from codeflash.cli_cmds.console import paneled_text
12+
from codeflash.code_utils import env_utils
1213
from codeflash.code_utils.checkpoint import ask_should_use_checkpoint_get_functions
1314
from codeflash.code_utils.config_parser import parse_config_file
1415
from codeflash.code_utils.version_check import check_for_newer_minor_version
@@ -39,6 +40,8 @@ def main() -> None:
3940
ask_run_end_to_end_test(args)
4041
else:
4142
args = process_pyproject_config(args)
43+
if not env_utils.check_formatter_installed(args.formatter_cmds):
44+
return
4245
args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args)
4346
init_sentry(not args.disable_telemetry, exclude_errors=True)
4447
posthog_cf.initialize_posthog(not args.disable_telemetry)

codeflash/optimization/optimizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ def run(self) -> None:
260260
console.rule()
261261
if not env_utils.ensure_codeflash_api_key():
262262
return
263-
if not env_utils.check_formatter_installed(self.args.formatter_cmds):
264-
return
265263
if self.args.no_draft and is_pr_draft():
266264
logger.warning("PR is in draft mode, skipping optimization")
267265
return

0 commit comments

Comments
 (0)