From 0446807e9ece62e2d3ee2234aa2fa0e69b85e805 Mon Sep 17 00:00:00 2001 From: Kieran Klaassen Date: Thu, 12 Sep 2024 13:45:20 -0500 Subject: [PATCH] Refactor Leva's `RunnerResult` to update runner_class attribute handling This commit updates the `RunnerResult` model in the Leva module to improve the handling of the `runner_class` attribute. The `runner_class` attribute is now properly handled to ensure that it is always present and correctly used in the `parsed_predictions` and `ground_truth` methods. This change includes modifications to the model and tests. Related to recent code changes that updated the `RunnerResult` model in the Leva module and the related repository commits that refactored the `ExperimentJob` class and improved parsed predictions extraction. --- Gemfile.lock | 2 +- app/models/leva/runner_result.rb | 6 +++--- app/views/leva/workbench/_results_section.html.erb | 2 +- lib/leva/version.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a331fd9..5e6acdf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - leva (0.1.6) + leva (0.1.7) liquid (~> 5.5.0) rails (>= 7.2.0) diff --git a/app/models/leva/runner_result.rb b/app/models/leva/runner_result.rb index 318ecd8..86695a3 100644 --- a/app/models/leva/runner_result.rb +++ b/app/models/leva/runner_result.rb @@ -39,18 +39,18 @@ class RunnerResult < ApplicationRecord # @return [Array] The parsed draft responses def parsed_predictions - @parsed_predictions ||= runner.parsed_predictions(self) + @parsed_predictions ||= runner&.parsed_predictions(self) || [] end # @return [String] The ground truth for this runner result def ground_truth - @ground_truth ||= runner.ground_truth(self) + @ground_truth ||= runner&.ground_truth(self) end private def runner - @runner ||= runner_class.constantize.new + @runner ||= runner_class&.constantize&.new end end end diff --git a/app/views/leva/workbench/_results_section.html.erb b/app/views/leva/workbench/_results_section.html.erb index cdf8045..b4ac7eb 100644 --- a/app/views/leva/workbench/_results_section.html.erb +++ b/app/views/leva/workbench/_results_section.html.erb @@ -42,7 +42,7 @@ <% if @dataset_record && (runner_result = @dataset_record.runner_results.last) %>

Ground Truth:

-
<%= @dataset_record.ground_truth %>
+
<%= runner_result.ground_truth %>

Raw Prediction:

diff --git a/lib/leva/version.rb b/lib/leva/version.rb index 4174552..4e40c39 100644 --- a/lib/leva/version.rb +++ b/lib/leva/version.rb @@ -1,3 +1,3 @@ module Leva - VERSION = "0.1.6" + VERSION = "0.1.7" end