33from argparse import SUPPRESS , ArgumentParser , Namespace
44from pathlib import Path
55
6- import git
7-
86from codeflash .cli_cmds import logging_config
97from codeflash .cli_cmds .cli_common import apologize_and_exit
108from codeflash .cli_cmds .cmd_init import init_codeflash , install_github_actions
119from codeflash .cli_cmds .console import logger
1210from codeflash .code_utils import env_utils
1311from codeflash .code_utils .config_parser import parse_config_file
14- from codeflash .code_utils .git_utils import (
15- check_and_push_branch ,
16- check_running_in_git_repo ,
17- confirm_proceeding_with_no_git_repo ,
18- get_repo_owner_and_name ,
19- )
20- from codeflash .code_utils .github_utils import get_github_secrets_page_url , require_github_app_or_exit
2112from codeflash .version import __version__ as version
2213
2314
@@ -75,6 +66,13 @@ def parse_args() -> Namespace:
7566
7667
7768def process_and_validate_cmd_args (args : Namespace ) -> Namespace :
69+ from codeflash .code_utils .git_utils import (
70+ check_running_in_git_repo ,
71+ confirm_proceeding_with_no_git_repo ,
72+ get_repo_owner_and_name ,
73+ )
74+ from codeflash .code_utils .github_utils import require_github_app_or_exit
75+
7876 is_init : bool = args .command .startswith ("init" ) if args .command else False
7977 if args .verbose :
8078 logging_config .set_level (logging .DEBUG , echo_setting = not is_init )
@@ -125,6 +123,7 @@ def process_pyproject_config(args: Namespace) -> Namespace:
125123 "disable_telemetry" ,
126124 "disable_imports_sorting" ,
127125 "git_remote" ,
126+ "override_fixtures" ,
128127 ]
129128 for key in supported_keys :
130129 if key in pyproject_config and (
@@ -144,21 +143,26 @@ def process_pyproject_config(args: Namespace) -> Namespace:
144143 assert Path (args .benchmarks_root ).resolve ().is_relative_to (Path (args .tests_root ).resolve ()), (
145144 f"--benchmarks-root { args .benchmarks_root } must be a subdirectory of --tests-root { args .tests_root } "
146145 )
147- if env_utils .get_pr_number () is not None :
148- assert env_utils .ensure_codeflash_api_key (), (
149- "Codeflash API key not found. When running in a Github Actions Context, provide the "
150- "'CODEFLASH_API_KEY' environment variable as a secret.\n "
151- "You can add a secret by going to your repository's settings page, then clicking 'Secrets' in the left sidebar.\n "
152- "Then, click 'New repository secret' and add your api key with the variable name CODEFLASH_API_KEY.\n "
153- f"Here's a direct link: { get_github_secrets_page_url ()} \n "
154- "Exiting..."
155- )
146+ if env_utils .get_pr_number () is not None :
147+ import git
148+
149+ from codeflash .code_utils .git_utils import get_repo_owner_and_name
150+ from codeflash .code_utils .github_utils import get_github_secrets_page_url , require_github_app_or_exit
151+
152+ assert env_utils .ensure_codeflash_api_key (), (
153+ "Codeflash API key not found. When running in a Github Actions Context, provide the "
154+ "'CODEFLASH_API_KEY' environment variable as a secret.\n "
155+ "You can add a secret by going to your repository's settings page, then clicking 'Secrets' in the left sidebar.\n "
156+ "Then, click 'New repository secret' and add your api key with the variable name CODEFLASH_API_KEY.\n "
157+ f"Here's a direct link: { get_github_secrets_page_url ()} \n "
158+ "Exiting..."
159+ )
156160
157- repo = git .Repo (search_parent_directories = True )
161+ repo = git .Repo (search_parent_directories = True )
158162
159- owner , repo_name = get_repo_owner_and_name (repo )
163+ owner , repo_name = get_repo_owner_and_name (repo )
160164
161- require_github_app_or_exit (owner , repo_name )
165+ require_github_app_or_exit (owner , repo_name )
162166
163167 if hasattr (args , "ignore_paths" ) and args .ignore_paths is not None :
164168 normalized_ignore_paths = []
@@ -187,6 +191,11 @@ def project_root_from_module_root(module_root: Path, pyproject_file_path: Path)
187191
188192def handle_optimize_all_arg_parsing (args : Namespace ) -> Namespace :
189193 if hasattr (args , "all" ):
194+ import git
195+
196+ from codeflash .code_utils .git_utils import check_and_push_branch , get_repo_owner_and_name
197+ from codeflash .code_utils .github_utils import require_github_app_or_exit
198+
190199 # Ensure that the user can actually open PRs on the repo.
191200 try :
192201 git_repo = git .Repo (search_parent_directories = True )
0 commit comments