From 1eeec8bc33155082f71dddd7d0d6c56eb1b56a7e Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 18:46:09 -0700 Subject: [PATCH 1/7] don't skip for our tests --- codeflash/discovery/functions_to_optimize.py | 6 ++++-- codeflash/optimization/function_optimizer.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/codeflash/discovery/functions_to_optimize.py b/codeflash/discovery/functions_to_optimize.py index 792a9fcff..c47de8eae 100644 --- a/codeflash/discovery/functions_to_optimize.py +++ b/codeflash/discovery/functions_to_optimize.py @@ -30,6 +30,8 @@ from codeflash.telemetry.posthog_cf import ph if TYPE_CHECKING: + from argparse import Namespace + from libcst import CSTNode from libcst.metadata import CodeRange @@ -423,7 +425,7 @@ def inspect_top_level_functions_or_methods( def was_function_previously_optimized( - function_to_optimize: FunctionToOptimize, code_context: CodeOptimizationContext + function_to_optimize: FunctionToOptimize, code_context: CodeOptimizationContext, args: Namespace ) -> bool: """Check which functions have already been optimized and filter them out. @@ -445,7 +447,7 @@ def was_function_previously_optimized( owner, repo = None, None pr_number = get_pr_number() - if not owner or not repo or pr_number is None: + if not owner or not repo or pr_number is None or args.no_pr: return False code_contexts = [] diff --git a/codeflash/optimization/function_optimizer.py b/codeflash/optimization/function_optimizer.py index c94759369..2a6859771 100644 --- a/codeflash/optimization/function_optimizer.py +++ b/codeflash/optimization/function_optimizer.py @@ -167,7 +167,7 @@ def optimize_function(self) -> Result[BestOptimization, str]: # noqa: PLR0911 # last time we could not find an optimization, maybe this time we do. # Random is before as a performance optimization, swapping the two 'and' statements has the same effect if random.random() > REPEAT_OPTIMIZATION_PROBABILITY and was_function_previously_optimized( # noqa: S311 - self.function_to_optimize, code_context + self.function_to_optimize, code_context, self.args ): return Failure("Function optimization previously attempted, skipping.") From f814c3a016d6d62cb3aa0402755c008e552bcad5 Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 18:46:20 -0700 Subject: [PATCH 2/7] pin to use 3.12 at most (3.13 builds numpy from src --- .python-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..e4fba2183 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 From cc0dfe3bb247389e70db2df3cbd79dffc8ac491e Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 18:49:48 -0700 Subject: [PATCH 3/7] Update functions_to_optimize.py --- codeflash/discovery/functions_to_optimize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeflash/discovery/functions_to_optimize.py b/codeflash/discovery/functions_to_optimize.py index c47de8eae..b4b548150 100644 --- a/codeflash/discovery/functions_to_optimize.py +++ b/codeflash/discovery/functions_to_optimize.py @@ -447,7 +447,7 @@ def was_function_previously_optimized( owner, repo = None, None pr_number = get_pr_number() - if not owner or not repo or pr_number is None or args.no_pr: + if not owner or not repo or pr_number is None or getattr(args, "no_pr", False): return False code_contexts = [] From d1f1813d5db0914d8d836e863205e4ff04ce682e Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 19:04:56 -0700 Subject: [PATCH 4/7] add 3.13 to the test suite --- .github/workflows/unit-tests.yaml | 2 +- tests/test_instrument_tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 4a04b105d..e5d1f7426 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] continue-on-error: true runs-on: ubuntu-latest steps: diff --git a/tests/test_instrument_tests.py b/tests/test_instrument_tests.py index a117c2205..189559263 100644 --- a/tests/test_instrument_tests.py +++ b/tests/test_instrument_tests.py @@ -129,7 +129,7 @@ def codeflash_wrap(wrapped, test_module_name, test_class_name, test_name, functi codeflash_test_index = codeflash_wrap.index[test_id] invocation_id = f'{{line_id}}_{{codeflash_test_index}}' """ - if sys.version_info < (3, 12): + if sys.version_info > (3, 12): expected += """test_stdout_tag = f"{{test_module_name}}:{{(test_class_name + '.' if test_class_name else '')}}{{test_name}}:{{function_name}}:{{loop_index}}:{{invocation_id}}" """ else: @@ -233,7 +233,7 @@ def codeflash_wrap(wrapped, test_module_name, test_class_name, test_name, functi codeflash_test_index = codeflash_wrap.index[test_id] invocation_id = f'{{line_id}}_{{codeflash_test_index}}' """ - if sys.version_info < (3, 12): + if sys.version_info > (3, 12): expected += """test_stdout_tag = f"{{test_module_name}}:{{(test_class_name + '.' if test_class_name else '')}}{{test_name}}:{{function_name}}:{{loop_index}}:{{invocation_id}}" """ else: From 4ab341cf30223e2e85d68803954da405bf7307c9 Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 19:14:04 -0700 Subject: [PATCH 5/7] test --- .github/workflows/unit-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index e5d1f7426..4a04b105d 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12"] continue-on-error: true runs-on: ubuntu-latest steps: From fc40857c41a141a587579e00255bc4682484aaf6 Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Fri, 20 Jun 2025 19:16:31 -0700 Subject: [PATCH 6/7] Revert "add 3.13 to the test suite" This reverts commit d1f1813d5db0914d8d836e863205e4ff04ce682e. --- tests/test_instrument_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_instrument_tests.py b/tests/test_instrument_tests.py index 189559263..a117c2205 100644 --- a/tests/test_instrument_tests.py +++ b/tests/test_instrument_tests.py @@ -129,7 +129,7 @@ def codeflash_wrap(wrapped, test_module_name, test_class_name, test_name, functi codeflash_test_index = codeflash_wrap.index[test_id] invocation_id = f'{{line_id}}_{{codeflash_test_index}}' """ - if sys.version_info > (3, 12): + if sys.version_info < (3, 12): expected += """test_stdout_tag = f"{{test_module_name}}:{{(test_class_name + '.' if test_class_name else '')}}{{test_name}}:{{function_name}}:{{loop_index}}:{{invocation_id}}" """ else: @@ -233,7 +233,7 @@ def codeflash_wrap(wrapped, test_module_name, test_class_name, test_name, functi codeflash_test_index = codeflash_wrap.index[test_id] invocation_id = f'{{line_id}}_{{codeflash_test_index}}' """ - if sys.version_info > (3, 12): + if sys.version_info < (3, 12): expected += """test_stdout_tag = f"{{test_module_name}}:{{(test_class_name + '.' if test_class_name else '')}}{{test_name}}:{{function_name}}:{{loop_index}}:{{invocation_id}}" """ else: From dd9374c05a3e8c53dda5d8265b9720842690e56a Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Fri, 27 Jun 2025 19:46:58 -0700 Subject: [PATCH 7/7] Delete .python-version --- .python-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .python-version diff --git a/.python-version b/.python-version deleted file mode 100644 index e4fba2183..000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12