From b46100158088e42879f504cce13b004d2ee84cb6 Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Thu, 15 May 2025 16:48:14 -0400 Subject: [PATCH] bump setup-uv --- codeflash/cli_cmds/cmd_init.py | 38 +++++++++++++------ .../codeflash-github-actions.md | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/codeflash/cli_cmds/cmd_init.py b/codeflash/cli_cmds/cmd_init.py index e7f195154..7e6d2cd57 100644 --- a/codeflash/cli_cmds/cmd_init.py +++ b/codeflash/cli_cmds/cmd_init.py @@ -45,6 +45,7 @@ f"{LF}" ) + @dataclass(frozen=True) class SetupInfo: module_root: str @@ -70,7 +71,6 @@ def init_codeflash() -> None: did_add_new_key = prompt_api_key() if should_modify_pyproject_toml(): - setup_info: SetupInfo = collect_setup_info() configure_pyproject_toml(setup_info) @@ -83,7 +83,6 @@ def init_codeflash() -> None: if "setup_info" in locals(): module_string = f" you selected ({setup_info.module_root})" - click.echo( f"{LF}" f"⚡️ Codeflash is now set up! You can now run:{LF}" @@ -125,11 +124,13 @@ def ask_run_end_to_end_test(args: Namespace) -> None: bubble_sort_path, bubble_sort_test_path = create_bubble_sort_file_and_test(args) run_end_to_end_test(args, bubble_sort_path, bubble_sort_test_path) + def should_modify_pyproject_toml() -> bool: """Check if the current directory contains a valid pyproject.toml file with codeflash config If it does, ask the user if they want to re-configure it. """ from rich.prompt import Confirm + pyproject_toml_path = Path.cwd() / "pyproject.toml" if not pyproject_toml_path.exists(): return True @@ -144,7 +145,9 @@ def should_modify_pyproject_toml() -> bool: return True create_toml = Confirm.ask( - "✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?", default=False, show_default=True + "✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?", + default=False, + show_default=True, ) return create_toml @@ -160,7 +163,18 @@ def collect_setup_info() -> SetupInfo: # Check for the existence of pyproject.toml or setup.py project_name = check_for_toml_or_setup_file() - ignore_subdirs = ["venv", "node_modules", "dist", "build", "build_temp", "build_scripts", "env", "logs", "tmp", "__pycache__"] + ignore_subdirs = [ + "venv", + "node_modules", + "dist", + "build", + "build_temp", + "build_scripts", + "env", + "logs", + "tmp", + "__pycache__", + ] valid_subdirs = [ d for d in next(os.walk("."))[1] if not d.startswith(".") and not d.startswith("__") and d not in ignore_subdirs ] @@ -262,13 +276,13 @@ def collect_setup_info() -> SetupInfo: benchmarks_options.append(create_benchmarks_option) benchmarks_options.append(custom_dir_option) - benchmarks_answer = inquirer_wrapper( inquirer.list_input, message="Where are your performance benchmarks located? (benchmarks must be a sub directory of your tests root directory)", choices=benchmarks_options, default=( - default_benchmarks_subdir if default_benchmarks_subdir in benchmarks_options else benchmarks_options[0]), + default_benchmarks_subdir if default_benchmarks_subdir in benchmarks_options else benchmarks_options[0] + ), ) if benchmarks_answer == create_benchmarks_option: @@ -304,7 +318,6 @@ def collect_setup_info() -> SetupInfo: # carousel=True, # ) - formatter = inquirer_wrapper( inquirer.list_input, message="Which code formatter do you use?", @@ -340,7 +353,7 @@ def collect_setup_info() -> SetupInfo: return SetupInfo( module_root=str(module_root), tests_root=str(tests_root), - benchmarks_root = str(benchmarks_root) if benchmarks_root else None, + benchmarks_root=str(benchmarks_root) if benchmarks_root else None, test_framework=cast(str, test_framework), ignore_paths=ignore_paths, formatter=cast(str, formatter), @@ -499,19 +512,22 @@ def install_github_actions(override_formatter_check: bool = False) -> None: return workflows_path.mkdir(parents=True, exist_ok=True) from importlib.resources import files + benchmark_mode = False if "benchmarks_root" in config: benchmark_mode = inquirer_wrapper( inquirer.confirm, message="⚡️It looks like you've configured a benchmarks_root in your config. Would you like to run the Github action in benchmark mode? " - " This will show the impact of Codeflash's suggested optimizations on your benchmarks", + " This will show the impact of Codeflash's suggested optimizations on your benchmarks", default=True, ) optimize_yml_content = ( files("codeflash").joinpath("cli_cmds", "workflows", "codeflash-optimize.yaml").read_text(encoding="utf-8") ) - materialized_optimize_yml_content = customize_codeflash_yaml_content(optimize_yml_content, config, git_root, benchmark_mode) + materialized_optimize_yml_content = customize_codeflash_yaml_content( + optimize_yml_content, config, git_root, benchmark_mode + ) with optimize_yaml_path.open("w", encoding="utf8") as optimize_yml_file: optimize_yml_file.write(materialized_optimize_yml_content) click.echo(f"{LF}✅ Created GitHub action workflow at {optimize_yaml_path}{LF}") @@ -607,7 +623,7 @@ def get_dependency_manager_installation_string(dep_manager: DependencyManager) - python_version_string = f"'{py_version.major}.{py_version.minor}'" if dep_manager == DependencyManager.UV: return """name: 🐍 Setup UV - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v6 with: enable-cache: true""" return f"""name: 🐍 Set up Python diff --git a/docs/docs/getting-started/codeflash-github-actions.md b/docs/docs/getting-started/codeflash-github-actions.md index 426d9c32a..7f9574dfb 100644 --- a/docs/docs/getting-started/codeflash-github-actions.md +++ b/docs/docs/getting-started/codeflash-github-actions.md @@ -106,7 +106,7 @@ This assumes that you install poetry with pip and have Codeflash dependency in t 2. uv ```yaml - - uses: astral-sh/setup-uv@v4 + - uses: astral-sh/setup-uv@v6 with: enable-cache: true - run: uv sync --group=dev