Skip to content

Commit 6418e7d

Browse files
committed
better exception handling for line profiler
1 parent 97c3cac commit 6418e7d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ def establish_original_code_baseline(
781781
original_helper_code: dict[Path, str],
782782
file_path_to_helper_classes: dict[Path, set[str]],
783783
) -> Result[tuple[OriginalCodeBaseline, list[str]], str]:
784+
line_profile_results = {'timings':{},'unit':0, 'str_out':''}
784785
# For the original function - run the tests and get the runtime, plus coverage
785786
with progress_bar(f"Establishing original code baseline for {self.function_to_optimize.function_name}"):
786787
assert (test_framework := self.args.test_framework) in ["pytest", "unittest"]
@@ -842,12 +843,11 @@ def establish_original_code_baseline(
842843
self.write_code_and_helpers(
843844
self.function_to_optimize_source_code, original_helper_code, self.function_to_optimize.file_path
844845
)
845-
if not line_profile_results:
846+
if line_profile_results['str_out']=='':
846847
logger.warning(
847848
f"Couldn't run line profiler for original function {self.function_to_optimize.function_name}"
848849
)
849850
console.rule()
850-
line_profile_results = {'timings':{},'unit':0, 'str_out':''}
851851
benchmarking_results, _ = self.run_and_parse_tests(
852852
testing_type=TestingMode.PERFORMANCE,
853853
test_env=test_env,

0 commit comments

Comments
 (0)