Skip to content

Commit 083a983

Browse files
render the code markdown to the console
1 parent cc2cc1b commit 083a983

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
from codeflash.either import Result
9494
from codeflash.models.models import (
9595
BenchmarkKey,
96+
CodeStringsMarkdown,
9697
CoverageData,
9798
FunctionCalledInTest,
9899
FunctionSource,
@@ -164,7 +165,7 @@ def can_be_optimized(self) -> Result[tuple[bool, CodeOptimizationContext, dict[P
164165
helper_code = f.read()
165166
original_helper_code[helper_function_path] = helper_code
166167

167-
if has_any_async_functions(code_context.read_writable_code):
168+
if has_any_async_functions(code_context.read_writable_code.__str__):
168169
return Failure("Codeflash does not support async functions in the code to optimize.")
169170
# Random here means that we still attempt optimization with a fractional chance to see if
170171
# last time we could not find an optimization, maybe this time we do.
@@ -283,7 +284,7 @@ def optimize_function(self) -> Result[BestOptimization, str]:
283284

284285
should_run_experiment, code_context, original_helper_code = initialization_result.unwrap()
285286

286-
code_print(code_context.read_writable_code)
287+
code_print(code_context.read_writable_code.__str__)
287288

288289
test_setup_result = self.generate_and_instrument_tests( # also generates optimizations
289290
code_context, should_run_experiment=should_run_experiment
@@ -756,7 +757,7 @@ def instrument_existing_tests(self, function_to_all_tests: dict[str, set[Functio
756757
def generate_tests_and_optimizations(
757758
self,
758759
testgen_context_code: str,
759-
read_writable_code: str,
760+
read_writable_code: CodeStringsMarkdown,
760761
read_only_context_code: str,
761762
helper_functions: list[FunctionSource],
762763
generated_test_paths: list[Path],
@@ -777,7 +778,7 @@ def generate_tests_and_optimizations(
777778
)
778779
future_optimization_candidates = executor.submit(
779780
self.aiservice_client.optimize_python_code,
780-
read_writable_code,
781+
read_writable_code.__str__,
781782
read_only_context_code,
782783
self.function_trace_id[:-4] + "EXP0" if run_experiment else self.function_trace_id,
783784
N_CANDIDATES,
@@ -796,7 +797,7 @@ def generate_tests_and_optimizations(
796797
if run_experiment:
797798
future_candidates_exp = executor.submit(
798799
self.local_aiservice_client.optimize_python_code,
799-
read_writable_code,
800+
read_writable_code.__str__,
800801
read_only_context_code,
801802
self.function_trace_id[:-4] + "EXP1",
802803
N_CANDIDATES,

0 commit comments

Comments
 (0)