Skip to content

Commit 5fa386a

Browse files
committed
sending the right trace id to avoid overwriting in the db
1 parent 9857c33 commit 5fa386a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def optimize_function(self) -> Result[BestOptimization, str]:
247247
file_path_to_helper_classes=file_path_to_helper_classes,
248248
exp_type=exp_type,
249249
)
250-
ph("cli-optimize-function-finished", {"function_trace_id": self.function_trace_id})
250+
ph("cli-optimize-function-finished", {"function_trace_id": self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id})
251251

252252
generated_tests = remove_functions_from_generated_tests(
253253
generated_tests=generated_tests, test_functions_to_remove=test_functions_to_remove
@@ -271,7 +271,7 @@ def optimize_function(self) -> Result[BestOptimization, str]:
271271
file_path=self.function_to_optimize.file_path,
272272
)
273273

274-
self.log_successful_optimization(explanation, generated_tests)
274+
self.log_successful_optimization(explanation, generated_tests, exp_type)
275275

276276
self.replace_function_and_helpers_with_optimized_code(
277277
code_context=code_context, optimized_code=best_optimization.candidate.source_code
@@ -309,7 +309,7 @@ def optimize_function(self) -> Result[BestOptimization, str]:
309309
explanation=explanation,
310310
existing_tests_source=existing_tests,
311311
generated_original_test_source=generated_tests_str,
312-
function_trace_id=self.function_trace_id,
312+
function_trace_id=self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id,
313313
coverage_message=coverage_message,
314314
git_remote=self.args.git_remote,
315315
)
@@ -477,16 +477,16 @@ def determine_best_candidate(
477477
logger.exception(f"Optimization interrupted: {e}")
478478
raise
479479

480-
self.aiservice_client.log_results(
481-
function_trace_id=self.function_trace_id,
480+
ai_service_client.log_results(
481+
function_trace_id=self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id,
482482
speedup_ratio=speedup_ratios,
483483
original_runtime=original_code_baseline.runtime,
484484
optimized_runtime=optimized_runtimes,
485485
is_correct=is_correct,
486486
)
487487
return best_optimization
488488

489-
def log_successful_optimization(self, explanation: Explanation, generated_tests: GeneratedTestsList) -> None:
489+
def log_successful_optimization(self, explanation: Explanation, generated_tests: GeneratedTestsList, exp_type: str) -> None:
490490
explanation_panel = Panel(
491491
f"⚡️ Optimization successful! 📄 {self.function_to_optimize.qualified_name} in {explanation.file_path}\n"
492492
f"📈 {explanation.perf_improvement_line}\n"
@@ -512,7 +512,7 @@ def log_successful_optimization(self, explanation: Explanation, generated_tests:
512512
ph(
513513
"cli-optimize-success",
514514
{
515-
"function_trace_id": self.function_trace_id,
515+
"function_trace_id": self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id,
516516
"speedup_x": explanation.speedup_x,
517517
"speedup_pct": explanation.speedup_pct,
518518
"best_runtime": explanation.best_runtime_ns,

0 commit comments

Comments
 (0)