Skip to content

Conversation

@aseembits93
Copy link
Contributor

@aseembits93 aseembits93 commented May 12, 2025

User description

Currently, posthog log outputs interfere with the console output of resuming for checkpoint


PR Type

Enhancement


Description

Move checkpoint prompt logic to main CLI
Add args.previous_checkpoint_functions in main
Optimizer uses args.previous_checkpoint_functions now
Remove redundant checkpoint prompt import


Changes walkthrough 📝

Relevant files
Enhancement
main.py
Add checkpoint prompt call in main                                             

codeflash/main.py

  • Import ask_should_use_checkpoint_get_functions
  • Set args.previous_checkpoint_functions in main
  • +3/-0     
    optimizer.py
    Refactor optimizer checkpoint logic                                           

    codeflash/optimization/optimizer.py

  • Remove inline checkpoint prompt call
  • Replace with args.previous_checkpoint_functions usage
  • +2/-3     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @aseembits93 aseembits93 requested a review from Saga4 May 12, 2025 23:15
    @aseembits93 aseembits93 enabled auto-merge May 12, 2025 23:15
    @github-actions
    Copy link

    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

    Unused Import

    The import CodeflashRunCheckpoint is added but not used in this diff, which may trigger lint warnings or indicate missing functionality. Consider removing it or using it as intended.

    from codeflash.code_utils.checkpoint import CodeflashRunCheckpoint
    Missing Initialization

    The attribute args.previous_checkpoint_functions is only set in the else branch of main(). If the optimizer is invoked via the args.command path, this attribute will be missing and may cause errors. Ensure it's initialized for all code paths that call the optimizer.

    args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args)

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Default checkpoint functions to list

    Guard against a None return from ask_should_use_checkpoint_get_functions by
    defaulting to an empty list. This avoids passing None into downstream functions and
    prevents type errors.

    codeflash/main.py [39]

    -args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args)
    +args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args) or []
    Suggestion importance[1-10]: 6

    __

    Why: Providing a fallback empty list prevents potential None values from propagating and causing type errors when previous_checkpoint_functions is used downstream.

    Low
    Add fallback for missing attribute

    Use getattr to safely retrieve previous_checkpoint_functions with a fallback empty
    list, preventing attribute errors if the property is missing.

    codeflash/optimization/optimizer.py [98]

    -previous_checkpoint_functions=self.args.previous_checkpoint_functions,
    +previous_checkpoint_functions=getattr(self.args, "previous_checkpoint_functions", []),
    Suggestion importance[1-10]: 5

    __

    Why: Using getattr avoids attribute errors if previous_checkpoint_functions isn’t set, but the code already ensures this attribute in main.py, so the impact is moderate.

    Low

    @aseembits93 aseembits93 requested a review from dasarchan May 12, 2025 23:21
    @aseembits93 aseembits93 self-assigned this May 12, 2025
    @aseembits93 aseembits93 requested a review from misrasaurabh1 May 12, 2025 23:36
    @aseembits93 aseembits93 merged commit a85ed90 into main May 12, 2025
    15 checks passed
    @aseembits93 aseembits93 deleted the fix-benchmark-prompt branch May 12, 2025 23:53
    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.

    3 participants