-
Notifications
You must be signed in to change notification settings - Fork 22
No Generated Tests Argument #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Codeflash Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Code Review for PR #988: No Generated Tests ArgumentThanks for adding this feature! I've reviewed the changes and have some feedback on code quality, potential bugs, and improvements. 🐛 Critical Bug: Logic Issue in generate_testsLocation: codeflash/optimization/function_optimizer.py:1347-1350 Problem: This implementation has a significant logic flaw. The function still performs all the expensive test generation work (lines 1299-1340) including:
Then it simply discards the results at the end if --no-gen-test is set. This wastes computational resources and time. Impact:
Recommended Fix:
|
codeflash/cli_cmds/cli.py
Outdated
| "--no-pr", action="store_true", help="Do not create a PR for the optimization, only update the code locally." | ||
| ) | ||
| parser.add_argument( | ||
| "--no-gen-test", action="store_true", help="Do not generate tests, use only existing tests for optimization." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--no-gen-tests
| logger.info(f"!lsp|Generated '{count_tests}' tests for '{self.function_to_optimize.function_name}'") | ||
|
|
||
| generated_tests = GeneratedTestsList(generated_tests=tests) | ||
| if self.args.no_gen_test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont do this this way! dont generate the tests in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, was done in a hurry, i've fixed it, will add/modify an end-to-end ci to ensure it works
Pull Request Review: No Generated Tests ArgumentThank you for this PR! The feature to disable test generation is useful for optimization workflows. However, I've identified several issues that need to be addressed. Critical Bug: Undefined Variable ErrorLocation: codeflash/optimization/function_optimizer.py:1298-1320 The code has a critical bug that will cause a NameError when --no-gen-tests is enabled. When self.args.no_gen_tests is True, the variable future_tests is never defined (line 1300), but it's referenced in lines 1314 and 1320. Both references are inside if not self.args.no_gen_tests: blocks, so they won't execute when the flag is enabled. However, this is fragile code structure. Fix: Initialize future_tests before the conditional: Logic Issue: Empty Tests List Not Handled ProperlyLocation: codeflash/optimization/function_optimizer.py:1340-1342 When --no-gen-tests is set, the warning and failure return are skipped, which means the tests list remains empty, count_tests will be 0, and the function returns Success with an empty GeneratedTestsList. Recommendation: Add a comment explaining that an empty tests list is valid when --no-gen-tests is set. Code Quality Issues
Test Coverage ConcernsCritical: No tests found for this new feature. The PR should include:
Performance ConsiderationsPositive: This change should improve performance when users don't need generated tests, as it skips expensive AI test generation calls. Summary of Required ChangesMust Fix:
Should Consider:
Overall AssessmentThe core concept is solid and useful, but the implementation has a critical scoping issue that needs to be fixed. With the suggested changes and proper test coverage, this will be a valuable addition to the codebase. |
PR Type
Enhancement
Description
Add '--no-gen-test' CLI flag
Disable test generation when flag set
Honor flag in optimization test pipeline
Diagram Walkthrough
File Walkthrough
cli.py
Introduce '--no-gen-test' CLI argumentcodeflash/cli_cmds/cli.py
--no-gen-test.function_optimizer.py
Conditionally disable test generation in optimizercodeflash/optimization/function_optimizer.py
args.no_gen_testto skip generated tests.GeneratedTestsListwhen flag enabled.