Skip to content

Commit 13b5284

Browse files
error message for baseline establishment failure
1 parent 35f7738 commit 13b5284

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

codeflash/errors/errors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ def function_optimization_attempted_error() -> CodeflashError:
3535
)
3636

3737

38-
def baseline_establishment_failed_error() -> CodeflashError:
38+
def baseline_establishment_failed_error(failure_msg: str) -> CodeflashError:
3939
return CodeflashError(
40-
"BASELINE_ESTABLISHMENT_FAILED_ERROR", "Failed to establish a baseline for the original code."
40+
"BASELINE_ESTABLISHMENT_FAILED_ERROR",
41+
"Failed to establish a baseline for the original code. {failure_msg}",
42+
**locals(),
4143
)
4244

4345

codeflash/optimization/function_optimizer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,7 @@ def establish_original_code_baseline(
14611461
)
14621462
)
14631463
console.rule()
1464+
failure_msg = ""
14641465

14651466
total_timing = benchmarking_results.total_passed_runtime() # caution: doesn't handle the loop index
14661467
functions_to_remove = [
@@ -1469,17 +1470,17 @@ def establish_original_code_baseline(
14691470
if (result.test_type == TestType.GENERATED_REGRESSION and not result.did_pass)
14701471
]
14711472
if total_timing == 0:
1472-
logger.warning(
1473-
"The overall summed benchmark runtime of the original function is 0, couldn't run tests."
1474-
)
1473+
failure_msg = "The overall summed benchmark runtime of the original function is 0, couldn't run tests."
1474+
logger.warning(failure_msg)
14751475
console.rule()
14761476
success = False
14771477
if not total_timing:
1478-
logger.warning("Failed to run the tests for the original function, skipping optimization")
1478+
failure_msg = "Failed to run the tests for the original function, skipping optimization"
1479+
logger.warning(failure_msg)
14791480
console.rule()
14801481
success = False
14811482
if not success:
1482-
return Failure(baseline_establishment_failed_error())
1483+
return Failure(baseline_establishment_failed_error(failure_msg))
14831484

14841485
loop_count = max([int(result.loop_index) for result in benchmarking_results.test_results])
14851486
logger.info(

0 commit comments

Comments
 (0)