Module: MiGA::Dataset::Result::Ignore

Included in:
MiGA::Dataset::Result
Defined in:
lib/miga/dataset/result/ignore.rb

Instance Method Summary collapse

Instance Method Details

#force_task?(task) ⇒ Boolean

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

Returns:

  • (Boolean)


131
132
133
# File 'lib/miga/dataset/result/ignore.rb', line 131

def force_task?(task)
  !!["run_#{task}"]
end

#ignore_by_type?(task, type) ⇒ Boolean

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

Returns:

  • (Boolean)


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# 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) ⇒ Boolean

Ignore task because it’s already done

Returns:

  • (Boolean)


45
46
47
# File 'lib/miga/dataset/result/ignore.rb', line 45

def ignore_complete?(task)
  !get_result(task).nil?
end

#ignore_empty?(_task) ⇒ Boolean

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

Returns:

  • (Boolean)


57
58
59
# File 'lib/miga/dataset/result/ignore.rb', line 57

def ignore_empty?(_task)
  first_preprocessing.nil?
end

#ignore_force?(task) ⇒ Boolean

Ignore task because the metadata says so

Returns:

  • (Boolean)


70
71
72
# File 'lib/miga/dataset/result/ignore.rb', line 70

def ignore_force?(task)
  !(["run_#{task}"].nil? || ["run_#{task}"])
end

#ignore_inactive?(_task) ⇒ Boolean

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

Returns:

  • (Boolean)


51
52
53
# File 'lib/miga/dataset/result/ignore.rb', line 51

def ignore_inactive?(_task)
  !active?
end

#ignore_multi?(task) ⇒ Boolean

Ignore task because it’s not a multi dataset

Returns:

  • (Boolean)


88
89
90
# File 'lib/miga/dataset/result/ignore.rb', line 88

def ignore_multi?(task)
  ignore_by_type?(task, :multi)
end

#ignore_nomarkers?(task) ⇒ Boolean

Ignore task because it’s not a markers dataset

Returns:

  • (Boolean)


100
101
102
# File 'lib/miga/dataset/result/ignore.rb', line 100

def ignore_nomarkers?(task)
  ignore_by_type?(task, :nomarkers)
end

#ignore_nonmulti?(task) ⇒ Boolean

Ignore task because it’s not a nonmulti dataset

Returns:

  • (Boolean)


94
95
96
# File 'lib/miga/dataset/result/ignore.rb', line 94

def ignore_nonmulti?(task)
  ignore_by_type?(task, :nonmulti)
end

#ignore_noref?(task) ⇒ Boolean

Ignore task because it’s not a reference dataset

Returns:

  • (Boolean)


82
83
84
# File 'lib/miga/dataset/result/ignore.rb', line 82

def ignore_noref?(task)
  ignore_by_type?(task, :noref)
end

#ignore_project?(task) ⇒ Boolean

Ignore task because the project is not compatible

Returns:

  • (Boolean)


76
77
78
# File 'lib/miga/dataset/result/ignore.rb', line 76

def ignore_project?(task)
  task == :taxonomy && project.option(:ref_project).nil?
end

#ignore_reasonsObject

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



23
24
25
26
27
28
# File 'lib/miga/dataset/result/ignore.rb', line 23

def ignore_reasons
  %i[
    empty inactive upstream force project
    noref multi nonmulti nomarkers complete
  ]
end

#ignore_task?(task) ⇒ Boolean

Should I ignore task for this dataset?

Returns:

  • (Boolean)


6
7
8
# File 'lib/miga/dataset/result/ignore.rb', line 6

def ignore_task?(task)
  why_ignore(task) != :execute
end

#ignore_upstream?(task) ⇒ Boolean

Ignore task because it’s upstream from the entry point

Returns:

  • (Boolean)


63
64
65
66
# 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) ⇒ Object

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



33
34
35
36
37
38
39
40
41
# 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