module MiGA::Dataset::Result

Helper module including specific functions to add dataset results

Public Instance Methods

cleanup_distances!(metrics = %i[haai aai ani]) click to toggle source

Clean-up all the stored distances, removing values for datasets no longer in the project as reference datasets. All metrics are processed unless metric is passed (Array, including :haai, :aai, :ani)

# File lib/miga/dataset/result.rb, line 102
def cleanup_distances!(metrics = %[haai aai ani])
  return if get_result(:distances).nil?

  require 'miga/sqlite'
  ref = project.dataset_ref_active.map(&:name)
  metrics.each { |metric| cleanup_distances_by_metric!(ref, metric) }
end
done_preprocessing?(save = false) click to toggle source

Are all the dataset-specific tasks done? Passes save to add_result

# File lib/miga/dataset/result.rb, line 49
def done_preprocessing?(save = false)
  !first_preprocessing(save).nil? && next_preprocessing(save).nil?
end
first_preprocessing(save = false) click to toggle source

Returns the key symbol of the first registered result (sorted by the execution order). This typically corresponds to the result used as the initial input. Passes save to add_result.

# File lib/miga/dataset/result.rb, line 33
def first_preprocessing(save = false)
  @first_processing ||= @@PREPROCESSING_TASKS.find do |t|
    !add_result(t, save).nil?
  end
end
next_preprocessing(save = false) click to toggle source

Returns the key symbol of the next task that needs to be executed or nil. Passes save to add_result.

# File lib/miga/dataset/result.rb, line 42
def next_preprocessing(save = false)
  first_preprocessing(save) if save
  next_task(nil, save)
end
profile_advance(save = false) click to toggle source

Returns an array indicating the stage of each task (sorted by execution order). The values are integers:

  • 0 for an undefined result (a task before the initial input).

  • 1 for a registered result (a completed task).

  • 2 for a queued result (a task yet to be executed).

It passes save to add_result

# File lib/miga/dataset/result.rb, line 60
def profile_advance(save = false)
  # Determine the start point
  first_task = first_preprocessing(save) or
    return Array.new(self.class.PREPROCESSING_TASKS.size, 0)

  # Traverse all tasks and determine the corresponding state
  state = 0
  next_task = next_preprocessing(save)
  self.class.PREPROCESSING_TASKS.map do |task|
    state = 1 if first_task == task
    state = 2 if !next_task.nil? && next_task == task
    state
  end
end
result_base() click to toggle source

Return the basename for results

# File lib/miga/dataset/result.rb, line 25
def result_base
  name
end
result_status(task) click to toggle source

Returns the status of task. The status values are symbols:

  • -: the task is upstream from the initial input

  • ignore_*: the task is to be ignored, see codes in why_ignore

  • complete: a task with registered results

  • pending: a task queued to be performed

# File lib/miga/dataset/result.rb, line 88
def result_status(task)
  reason = why_ignore(task)
  case reason
  when :upstream then :-
  when :execute  then :pending
  when :complete then :complete
  else; :"ignore_#{reason}"
  end
end
results_status() click to toggle source

Returns a Hash with tasks as key and status as value. See result_status for possible values

# File lib/miga/dataset/result.rb, line 78
def results_status
  Hash[@@PREPROCESSING_TASKS.map { |task| [task, result_status(task)] }]
end