Skip to content

Commit

Permalink
Refactor Leva's RunnerResult to add runner_class attribute
Browse files Browse the repository at this point in the history
This commit adds the `runner_class` attribute to the `RunnerResult` model in the Leva module. The `runner_class` attribute is used to store the name of the runner class associated with the result. This change includes modifications to the model, migration, and tests.

Related to recent code changes that added the `runner_class` attribute to the `RunnerResult` model and migration files.
  • Loading branch information
kieranklaassen committed Sep 12, 2024
1 parent 62cb6e5 commit f1a558f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/leva/runner_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# id :integer not null, primary key
# prediction :text
# prompt_version :integer
# runner_class :string
# created_at :datetime not null
# updated_at :datetime not null
# dataset_record_id :integer not null
Expand Down Expand Up @@ -32,6 +33,7 @@ class RunnerResult < ApplicationRecord

validates :prediction, presence: true
validates :prompt, presence: true
validates :runner_class, presence: true

delegate :ground_truth, to: :dataset_record

Expand All @@ -51,4 +53,4 @@ def runner
@runner ||= runner_class.constantize.new
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRunnerClassToLevaRunnerResults < ActiveRecord::Migration[7.2]
def change
add_column :leva_runner_results, :runner_class, :string
end
end
1 change: 1 addition & 0 deletions lib/leva.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def execute_and_store(experiment, dataset_record, prompt)
dataset_record: dataset_record,
prompt: prompt,
prediction: result,
runner_class: self.class.name
)
end

Expand Down
3 changes: 2 additions & 1 deletion test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_08_22_143201) do
ActiveRecord::Schema[7.2].define(version: 2024_09_12_183556) do
create_table "leva_dataset_records", force: :cascade do |t|
t.integer "dataset_id", null: false
t.string "recordable_type", null: false
Expand Down Expand Up @@ -75,6 +75,7 @@
t.datetime "updated_at", null: false
t.integer "prompt_version"
t.integer "prompt_id", null: false
t.string "runner_class"
t.index ["dataset_record_id"], name: "index_leva_runner_results_on_dataset_record_id"
t.index ["experiment_id"], name: "index_leva_runner_results_on_experiment_id"
t.index ["prompt_id"], name: "index_leva_runner_results_on_prompt_id"
Expand Down
1 change: 1 addition & 0 deletions test/models/leva/runner_result_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# id :integer not null, primary key
# prediction :text
# prompt_version :integer
# runner_class :string
# created_at :datetime not null
# updated_at :datetime not null
# dataset_record_id :integer not null
Expand Down

0 comments on commit f1a558f

Please sign in to comment.