Class: Observ::DatasetRunsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Observ::DatasetRunsController
- Defined in:
- app/controllers/observ/dataset_runs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #review ⇒ Object
- #run_evaluators ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 30 def create @run = @dataset.runs.build(run_params) if @run.save # Initialize run items for all active dataset items @run.initialize_run_items! # Queue the run for async execution Observ::DatasetRunnerJob.perform_later(@run.id) redirect_to dataset_run_path(@dataset, @run), notice: "Run '#{@run.name}' created with #{@run.total_items} items. Execution will begin shortly." else render :new, status: :unprocessable_content end end |
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 47 def destroy name = @run.name @run.destroy redirect_to dataset_path(@dataset, tab: "runs"), notice: "Run '#{name}' deleted successfully." end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 8 def index @runs = @dataset.runs.order(created_at: :desc) if params[:status].present? @runs = @runs.where(status: params[:status]) end @runs = @runs.page(params[:page]).per(Observ.config.pagination_per_page) end |
#new ⇒ Object
26 27 28 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 26 def new @run = @dataset.runs.build end |
#review ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 62 def review @run_item = next_item_to_review(@run) if @run_item.nil? redirect_to dataset_run_path(@dataset, @run), notice: "All items have been reviewed!" return end @progress = review_progress(@run) @existing_manual = @run_item.score_for("manual", source: :manual) end |
#run_evaluators ⇒ Object
54 55 56 57 58 59 60 |
# File 'app/controllers/observ/dataset_runs_controller.rb', line 54 def run_evaluators evaluator_configs = @dataset.&.dig("evaluators") || [{ "type" => "exact_match" }] Observ::EvaluatorRunnerService.new(@run, evaluator_configs: evaluator_configs).call redirect_to dataset_run_path(@dataset, @run), notice: "Evaluators completed. #{@run.items_with_scores_count} items scored." end |