2222from codeflash .cli_cmds .console import console , logger
2323from codeflash .code_utils .compat import LF
2424from codeflash .code_utils .config_parser import parse_config_file
25- from codeflash .code_utils .env_utils import get_codeflash_api_key
25+ from codeflash .code_utils .env_utils import check_formatter_installed , get_codeflash_api_key
2626from codeflash .code_utils .git_utils import get_git_remotes , get_repo_owner_and_name
2727from codeflash .code_utils .github_utils import get_github_secrets_page_url
2828from codeflash .code_utils .shell_utils import get_shell_rc_path , save_api_key_to_rc
@@ -201,7 +201,7 @@ def collect_setup_info() -> SetupInfo:
201201 path_type = inquirer .Path .DIRECTORY ,
202202 )
203203 if custom_module_root_answer :
204- module_root = Path (curdir ) / Path ( custom_module_root_answer ["path" ])
204+ module_root = Path (custom_module_root_answer ["path" ])
205205 else :
206206 apologize_and_exit ()
207207 else :
@@ -514,7 +514,8 @@ def install_github_actions(override_formatter_check: bool = False) -> None: # n
514514 from importlib .resources import files
515515
516516 benchmark_mode = False
517- if "benchmarks_root" in config :
517+ benchmarks_root = config .get ("benchmarks_root" , "" ).strip ()
518+ if benchmarks_root and benchmarks_root != "" :
518519 benchmark_mode = inquirer_wrapper (
519520 inquirer .confirm ,
520521 message = "⚡️It looks like you've configured a benchmarks_root in your config. Would you like to run the Github action in benchmark mode? "
@@ -537,7 +538,7 @@ def install_github_actions(override_formatter_check: bool = False) -> None: # n
537538 existing_api_key = None
538539 click .prompt (
539540 f"Next, you'll need to add your CODEFLASH_API_KEY as a secret to your GitHub repo.{ LF } "
540- f"Press Enter to open your repo's secrets page at { get_github_secrets_page_url (repo )} … { LF } "
541+ f"Press Enter to open your repo's secrets page at { get_github_secrets_page_url (repo )} { LF } "
541542 f"Then, click 'New repository secret' to add your api key with the variable name CODEFLASH_API_KEY.{ LF } "
542543 f"{ 'Here is your CODEFLASH_API_KEY: ' + existing_api_key + ' ' + LF } "
543544 if existing_api_key
@@ -720,11 +721,7 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
720721 )
721722 elif formatter == "don't use a formatter" :
722723 formatter_cmds .append ("disabled" )
723- if formatter in ["black" , "ruff" ]:
724- try :
725- subprocess .run ([formatter ], capture_output = True , check = False )
726- except (FileNotFoundError , NotADirectoryError ):
727- click .echo (f"⚠️ Formatter not found: { formatter } , please ensure it is installed" )
724+ check_formatter_installed (formatter_cmds , exit_on_failure = False )
728725 codeflash_section ["formatter-cmds" ] = formatter_cmds
729726 # Add the 'codeflash' section, ensuring 'tool' section exists
730727 tool_section = pyproject_data .get ("tool" , tomlkit .table ())
@@ -750,7 +747,7 @@ def install_github_app() -> None:
750747
751748 else :
752749 click .prompt (
753- f"Finally, you'll need install the Codeflash GitHub app by choosing the repository you want to install Codeflash on.{ LF } "
750+ f"Finally, you'll need to install the Codeflash GitHub app by choosing the repository you want to install Codeflash on.{ LF } "
754751 f"I will attempt to open the github app page - https://github.com/apps/codeflash-ai/installations/select_target { LF } "
755752 f"Press Enter to open the page to let you install the app…{ LF } " ,
756753 default = "" ,
@@ -924,6 +921,14 @@ def test_sort():
924921
925922
926923def run_end_to_end_test (args : Namespace , bubble_sort_path : str , bubble_sort_test_path : str ) -> None :
924+ try :
925+ check_formatter_installed (args .formatter_cmds )
926+ except Exception :
927+ logger .error (
928+ "Formatter not found. Review the formatter_cmds in your pyproject.toml file and make sure the formatter is installed."
929+ )
930+ return
931+
927932 command = ["codeflash" , "--file" , "bubble_sort.py" , "--function" , "sorter" ]
928933 if args .no_pr :
929934 command .append ("--no-pr" )
0 commit comments