Skip to content

Conversation

@misrasaurabh1
Copy link
Contributor

@misrasaurabh1 misrasaurabh1 commented Jun 24, 2025

User description

also add verbose mode to --verify-setup


PR Type

Enhancement


Description

  • Add verbose flag to end-to-end test command

  • Use console.out instead of console.print

  • Refactor generated files cleanup in FunctionOptimizer

  • Track and cleanup current function optimizer


Changes walkthrough 📝

Relevant files
Enhancement
cmd_init.py
Support verbose end-to-end tests                                                 

codeflash/cli_cmds/cmd_init.py

  • Added --verbose flag support to end-to-end tests
  • Appended --verbose to the subprocess command
  • Replaced console.print with console.out for output
  • Minor whitespace formatting adjustment
  • +4/-2     
    function_optimizer.py
    Simplify generated files cleanup                                                 

    codeflash/optimization/function_optimizer.py

  • Simplified cleanup_generated_files implementation
  • Removed nested list comprehensions for paths
  • Iterated over self.test_files to collect cleanup paths
  • +5/-17   
    optimizer.py
    Track and cleanup current function optimizer                         

    codeflash/optimization/optimizer.py

  • Initialized current_function_optimizer in constructor
  • Assigned optimizer instance to current_function_optimizer in run
  • Invoked its cleanup_generated_files in cleanup_temporary_paths
  • +7/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • add verbose mode to --verify-setup
    @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Console Output

    Confirm that console.out is a valid method and supports the intended formatting and error handling, replacing the previous console.print.

    console.out(stripped)
    output.append(stripped)
    Incomplete Cleanup

    The simplified cleanup_generated_files drops the previous type-based filtering and may miss cleaning some generated test files; verify all relevant paths are covered.

    paths_to_cleanup = [self.test_cfg.concolic_test_root_dir]
    for test_file in self.test_files:
        paths_to_cleanup.append(test_file.instrumented_behavior_file_path)
        paths_to_cleanup.append(test_file.benchmarking_file_path)
    
    cleanup_paths(paths_to_cleanup)
    if hasattr(get_run_tmp_file, "tmpdir"):
        get_run_tmp_file.tmpdir.cleanup()
    Redundant Cleanup

    current_function_optimizer.cleanup_generated_files() is invoked both inside the loop and again in cleanup_temporary_paths, potentially causing duplicate operations or errors.

    if self.current_function_optimizer:
        self.current_function_optimizer.cleanup_generated_files()
    
    cleanup_paths([self.test_cfg.concolic_test_root_dir, self.replay_tests_dir])

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix console output call

    The Console API doesn’t have an out method, so using console.out will raise an
    AttributeError. Replace it with console.print to correctly emit each line.

    codeflash/cli_cmds/cmd_init.py [958]

    -console.out(stripped)
    +console.print(stripped)
    Suggestion importance[1-10]: 9

    __

    Why: Using console.out will raise an AttributeError at runtime; replacing it with console.print fixes this critical bug.

    High
    Ensure correct test file iteration

    Iterating directly over self.test_files may not yield all test file objects and can
    cause attribute errors. Use get_by_type(...) for each TestType to collect exactly
    the intended files.

    codeflash/optimization/function_optimizer.py [1324-1327]

     paths_to_cleanup = [self.test_cfg.concolic_test_root_dir]
    -for test_file in self.test_files:
    -    paths_to_cleanup.append(test_file.instrumented_behavior_file_path)
    -    paths_to_cleanup.append(test_file.benchmarking_file_path)
    +for test_type in [
    +    TestType.GENERATED_REGRESSION,
    +    TestType.EXISTING_UNIT_TEST,
    +    TestType.CONCOLIC_COVERAGE_TEST,
    +]:
    +    for tf in self.test_files.get_by_type(test_type).test_files:
    +        paths_to_cleanup.append(tf.instrumented_behavior_file_path)
    +for test_type in [TestType.GENERATED_REGRESSION, TestType.EXISTING_UNIT_TEST]:
    +    for tf in self.test_files.get_by_type(test_type).test_files:
    +        paths_to_cleanup.append(tf.benchmarking_file_path)
    Suggestion importance[1-10]: 7

    __

    Why: Iterating directly over self.test_files may skip intended test file groups and cause attribute errors, so using get_by_type ensures the correct files are collected.

    Medium
    Filter out None cleanup paths

    Passing None or falsy values to cleanup_paths can raise errors. Filter out any unset
    paths before calling cleanup_paths.

    codeflash/optimization/optimizer.py [302]

    -cleanup_paths([self.test_cfg.concolic_test_root_dir, self.replay_tests_dir])
    +paths = [self.test_cfg.concolic_test_root_dir]
    +if self.replay_tests_dir:
    +    paths.append(self.replay_tests_dir)
    +cleanup_paths(paths)
    Suggestion importance[1-10]: 6

    __

    Why: Passing None to cleanup_paths could lead to runtime errors; filtering out unset paths prevents this minor but useful safeguard.

    Low

    we don't want this event + slows down cleanup, and the user might exit the cleanup before we get a chance
    @misrasaurabh1 misrasaurabh1 merged commit 21e8fe8 into main Jun 24, 2025
    16 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.

    3 participants