Skip to content

Commit

Permalink
Refactor Leva's RunnerResult to update runner_class attribute handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kieranklaassen committed Sep 12, 2024
1 parent f1a558f commit 0446807
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
leva (0.1.6)
leva (0.1.7)
liquid (~> 5.5.0)
rails (>= 7.2.0)

Expand Down
6 changes: 3 additions & 3 deletions app/models/leva/runner_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class RunnerResult < ApplicationRecord

# @return [Array<String>] 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
2 changes: 1 addition & 1 deletion app/views/leva/workbench/_results_section.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<% if @dataset_record && (runner_result = @dataset_record.runner_results.last) %>
<div class="mb-3">
<h4 class="text-xs font-semibold text-indigo-200 mb-1">Ground Truth:</h4>
<pre class="text-sm text-gray-300 whitespace-pre-wrap bg-gray-700 p-2 rounded"><%= @dataset_record.ground_truth %></pre>
<pre class="text-sm text-gray-300 whitespace-pre-wrap bg-gray-700 p-2 rounded"><%= runner_result.ground_truth %></pre>
</div>
<div>
<h4 class="text-xs font-semibold text-indigo-200 mb-1">Raw Prediction:</h4>
Expand Down
2 changes: 1 addition & 1 deletion lib/leva/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Leva
VERSION = "0.1.6"
VERSION = "0.1.7"
end

0 comments on commit 0446807

Please sign in to comment.