module MiGA::Dataset::Result::Ignore

frozen_string_literal: true

Public Instance Methods

force_task?(task) click to toggle source

Force the task to be executed even if it should otherwise be ignored due to reasons: :noref, :multi, or :nonmulti. Other reasons to ignore a task are not affected by metadata forcing

# File lib/miga/dataset/result/ignore.rb, line 131
def force_task?(task)
  !!metadata["run_#{task}"]
end
ignore_by_type?(task, type) click to toggle source

Ignore task by type of dataset, one of: :noref, :multi, or :nonmulti, :nomarkers

# File lib/miga/dataset/result/ignore.rb, line 107
def ignore_by_type?(task, type)
  return false if force_task?(task)

  test, list =
    case type.to_sym
    when :noref
      [:ref?, self.class.EXCLUDE_NOREF_TASKS]
    when :multi
      [:multi?, self.class.ONLY_MULTI_TASKS]
    when :nonmulti
      [:nonmulti?, self.class.ONLY_NONMULTI_TASKS]
    when :nomarkers
      [:markers?, self.class.EXCLUDE_NOMARKER_TASKS]
    else
      raise "Unexpected error, unknown type reason: #{type}"
    end

  list.include?(task) && !send(test)
end
ignore_complete?(task) click to toggle source

Ignore task because it's already done

# File lib/miga/dataset/result/ignore.rb, line 45
def ignore_complete?(task)
  !get_result(task).nil?
end
ignore_empty?(_task) click to toggle source

Ignore any task because the dataset is empty (_task is ignored)

# File lib/miga/dataset/result/ignore.rb, line 57
def ignore_empty?(_task)
  first_preprocessing.nil?
end
ignore_force?(task) click to toggle source

Ignore task because the metadata says so

# File lib/miga/dataset/result/ignore.rb, line 70
def ignore_force?(task)
  !(metadata["run_#{task}"].nil? || metadata["run_#{task}"])
end
ignore_inactive?(_task) click to toggle source

Ignore any task because the dataset is inactive (_task is ignored)

# File lib/miga/dataset/result/ignore.rb, line 51
def ignore_inactive?(_task)
  !active?
end
ignore_multi?(task) click to toggle source

Ignore task because it's not a multi dataset

# File lib/miga/dataset/result/ignore.rb, line 88
def ignore_multi?(task)
  ignore_by_type?(task, :multi)
end
ignore_nomarkers?(task) click to toggle source

Ignore task because it's not a markers dataset

# File lib/miga/dataset/result/ignore.rb, line 100
def ignore_nomarkers?(task)
  ignore_by_type?(task, :nomarkers)
end
ignore_nonmulti?(task) click to toggle source

Ignore task because it's not a nonmulti dataset

# File lib/miga/dataset/result/ignore.rb, line 94
def ignore_nonmulti?(task)
  ignore_by_type?(task, :nonmulti)
end
ignore_noref?(task) click to toggle source

Ignore task because it's not a reference dataset

# File lib/miga/dataset/result/ignore.rb, line 82
def ignore_noref?(task)
  ignore_by_type?(task, :noref)
end
ignore_project?(task) click to toggle source

Ignore task because the project is not compatible

# File lib/miga/dataset/result/ignore.rb, line 76
def ignore_project?(task)
  task == :taxonomy && project.option(:ref_project).nil?
end
ignore_reasons() click to toggle source

Returns an array of symbols indicating all the possible reasons why a given task migh be ignored:

  • empty: the dataset has no data

  • inactive: the dataset is inactive

  • upstream: the task is upstream from dataset's input

  • force: forced to ignore by metadata

  • project: incompatible project

  • noref: incompatible dataset, only for reference

  • multi: incompatible dataset, only for multi

  • nomarkers: incompatible dataset, only for markers

  • nonmulti: incompatible dataset, only for nonmulti

  • complete: the task is already complete

# File lib/miga/dataset/result/ignore.rb, line 23
def ignore_reasons
  %[
    empty inactive upstream force project
    noref multi nonmulti nomarkers complete
  ]
end
ignore_task?(task) click to toggle source

Should I ignore task for this dataset?

# File lib/miga/dataset/result/ignore.rb, line 6
def ignore_task?(task)
  why_ignore(task) != :execute
end
ignore_upstream?(task) click to toggle source

Ignore task because it's upstream from the entry point

# File lib/miga/dataset/result/ignore.rb, line 63
def ignore_upstream?(task)
  self.class.PREPROCESSING_TASKS.index(task) <
    self.class.PREPROCESSING_TASKS.index(first_preprocessing)
end
why_ignore(task) click to toggle source

Return a code explaining why a task is ignored (see ignore_reasons) or the symbol :execute (do not ignore, execute the task)

# File lib/miga/dataset/result/ignore.rb, line 33
def why_ignore(task)
  # Find a reason to ignore it
  ignore_reasons.each do |i|
    return i if send(:"ignore_#{i}?", task)
  end

  # Otherwise, execute
  return :execute
end