Skip to content

Conversation

@dasarchan
Copy link
Contributor

@dasarchan dasarchan commented May 5, 2025

User description

Prompt the user to turn telemetry on or off, and store setting in pyproject.toml.


PR Type

Enhancement


Description

Prompt user to enable or disable telemetry
Store disable-telemetry setting in pyproject.toml
Add ask_for_telemetry helper function using Rich Confirm
Bump version to 0.12.2.post2.dev0+b6bbeecc


Changes walkthrough 📝

Relevant files
Enhancement
cmd_init.py
Add telemetry prompt and config storage                                   

codeflash/cli_cmds/cmd_init.py

  • Introduce ask_for_telemetry function prompting via Rich
  • Call ask_for_telemetry in configure_pyproject_toml
  • Store disable-telemetry flag in pyproject.toml
  • +17/-0   
    main.py
    Import telemetry prompt in main                                                   

    codeflash/main.py

    • Import ask_for_telemetry in entrypoint
    +1/-1     
    Configuration changes
    version.py
    Bump version to post2.dev0+b6bbeecc                                           

    codeflash/version.py

  • Bump __version__ string to include post2.dev0
  • Update __version_tuple__ accordingly
  • +2/-2     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @dasarchan dasarchan requested a review from Copilot May 5, 2025 18:27
    @CLAassistant
    Copy link

    CLAassistant commented May 5, 2025

    CLA assistant check
    All committers have signed the CLA.

    Copy link

    Copilot AI left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Pull Request Overview

    The PR adds an option to enable or disable telemetry during the Codeflash initialization process and updates versioning information.

    • Updates version strings in codeflash/version.py
    • Imports and integrates a new telemetry prompt in main.py and cmd_init.py
    • Stores the telemetry choice in pyproject.toml via a new configuration key

    Reviewed Changes

    Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

    File Description
    codeflash/version.py Updates version strings and version tuple format
    codeflash/main.py Imports the new telemetry prompt function
    codeflash/cli_cmds/cmd_init.py Adds telemetry prompt call and writes telemetry setting to toml
    Comments suppressed due to low confidence (2)

    codeflash/cli_cmds/cmd_init.py:688

    • [nitpick] Using the key 'disable-telemetry' with a negated value may be confusing. Consider renaming the key to 'telemetry-enabled' to directly reflect the user's choice.
    codeflash_section["disable-telemetry"] = not enable_telemetry
    

    codeflash/version.py:3

    • Changing version_tuple to include non-integer values may impact consumers that expect a numeric tuple. Consider documenting this change in the changelog or confirming that all version consumers handle the new format properly.
    __version_tuple__ = (0, 12, 2, "post2", "dev0", "b6bbeecc")
    

    @github-actions
    Copy link

    github-actions bot commented May 5, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Undefined Name

    The function ask_for_telemetry calls ph(...) but ph is not defined or imported, which may cause a runtime error during execution.

    ph("cli-telemetry-prompt", {"telemetry_enabled": enable_telemetry})
    Unused Import

    ask_for_telemetry is imported in main.py but not used anywhere in this file, leading to a dead import and potential linter warnings.

    from codeflash.cli_cmds.cmd_init import CODEFLASH_LOGO, ask_run_end_to_end_test, ask_for_telemetry
    Missing Tests

    There are no tests covering the new telemetry prompt or the persistence of the disable-telemetry setting in pyproject.toml. Consider adding unit or integration tests.

    def configure_pyproject_toml(setup_info: SetupInfo) -> None:
        toml_path = Path.cwd() / "pyproject.toml"
        try:
            with toml_path.open(encoding="utf8") as pyproject_file:
                pyproject_data = tomlkit.parse(pyproject_file.read())
        except FileNotFoundError:
            click.echo(
                f"I couldn't find a pyproject.toml in the current directory.{LF}"
                f"Please create a new empty pyproject.toml file here, OR if you use poetry then run `poetry init`, OR run `codeflash init` again from a directory with an existing pyproject.toml file."
            )
            apologize_and_exit()
    
        enable_telemetry = ask_for_telemetry()
    
        codeflash_section = tomlkit.table()
        codeflash_section.add(tomlkit.comment("All paths are relative to this pyproject.toml's directory."))
        codeflash_section["module-root"] = setup_info.module_root
        codeflash_section["tests-root"] = setup_info.tests_root
        codeflash_section["test-framework"] = setup_info.test_framework
        codeflash_section["benchmarks-root"] = setup_info.benchmarks_root if setup_info.benchmarks_root else ""
        codeflash_section["ignore-paths"] = setup_info.ignore_paths
        codeflash_section["disable-telemetry"] = not enable_telemetry
        if setup_info.git_remote not in ["", "origin"]:

    @github-actions
    Copy link

    github-actions bot commented May 5, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Remove unused import

    Remove the unused ask_for_telemetry import to avoid lint errors and keep the import
    list clean.

    codeflash/main.py [8]

    -from codeflash.cli_cmds.cmd_init import CODEFLASH_LOGO, ask_run_end_to_end_test, ask_for_telemetry
    +from codeflash.cli_cmds.cmd_init import CODEFLASH_LOGO, ask_run_end_to_end_test
    Suggestion importance[1-10]: 5

    __

    Why: The imported ask_for_telemetry is not used in main.py, so removing it prevents lint warnings and keeps imports clean.

    Low

    @dasarchan dasarchan requested review from KRRT7 and misrasaurabh1 May 5, 2025 21:42
    @dasarchan dasarchan merged commit 8774060 into main May 6, 2025
    15 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants