Skip to content

Commit a54be51

Browse files
Merge pull request #361 from codeflash-ai/skip_context-check-for-our-tests
Skip context check for our tests
2 parents ed6ffe4 + d51f08b commit a54be51

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

codeflash/discovery/functions_to_optimize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from codeflash.telemetry.posthog_cf import ph
3131

3232
if TYPE_CHECKING:
33+
from argparse import Namespace
34+
3335
from libcst import CSTNode
3436
from libcst.metadata import CodeRange
3537

@@ -423,7 +425,7 @@ def inspect_top_level_functions_or_methods(
423425

424426

425427
def was_function_previously_optimized(
426-
function_to_optimize: FunctionToOptimize, code_context: CodeOptimizationContext
428+
function_to_optimize: FunctionToOptimize, code_context: CodeOptimizationContext, args: Namespace
427429
) -> bool:
428430
"""Check which functions have already been optimized and filter them out.
429431
@@ -445,7 +447,7 @@ def was_function_previously_optimized(
445447
owner, repo = None, None
446448
pr_number = get_pr_number()
447449

448-
if not owner or not repo or pr_number is None:
450+
if not owner or not repo or pr_number is None or getattr(args, "no_pr", False):
449451
return False
450452

451453
code_contexts = []

codeflash/optimization/function_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def can_be_optimized(self) -> Result[tuple[bool, CodeOptimizationContext, dict[P
170170
# last time we could not find an optimization, maybe this time we do.
171171
# Random is before as a performance optimization, swapping the two 'and' statements has the same effect
172172
if random.random() > REPEAT_OPTIMIZATION_PROBABILITY and was_function_previously_optimized( # noqa: S311
173-
self.function_to_optimize, code_context
173+
self.function_to_optimize, code_context, self.args
174174
):
175175
return Failure("Function optimization previously attempted, skipping.")
176176

0 commit comments

Comments
 (0)