module MiGA::Dataset::Hooks

Helper module including specific functions to handle dataset hooks. Supported events:

Supported hooks:

Internal hooks:

Public Instance Methods

default_hooks() click to toggle source

Dataset hooks triggered by default

# File lib/miga/dataset/hooks.rb, line 27
def default_hooks
  {
    on_create: [[:recalculate_status]],
    on_activate: [[:clear_run_counts], [:recalculate_status]],
    on_inactivate: [[:recalculate_status]],
    on_result_ready: [[:_pull_result_hooks]],
    on_preprocessing_ready: [[:clear_run_counts], [:recalculate_status]],
  }
end
hook__pull_result_hooks(_hook_args, event_args) click to toggle source

Dataset Action :pull_result_hooks([], [res]) Pull the hook specific to the type of result

# File lib/miga/dataset/hooks.rb, line 71
def hook__pull_result_hooks(_hook_args, event_args)
  pull_hook(:"on_result_ready_#{event_args.first}", *event_args)
  pull_hook(:on_preprocessing_ready) if done_preprocessing?
end
hook_clear_run_counts(_hook_args, _event_args) click to toggle source

Clear metadata from run counts

# File lib/miga/dataset/hooks.rb, line 39
def hook_clear_run_counts(_hook_args, _event_args)
  metadata
    .data.keys
    .select { |k| k.to_s =~ /^_try_/ }
    .each { |k| metadata[k] = nil }
  metadata[:_step] = nil
  save
end
hook_recalculate_status(_hook_args, _event_args) click to toggle source

Recalculate the dataset status and save in metadata

# File lib/miga/dataset/hooks.rb, line 50
def hook_recalculate_status(_hook_args, _event_args)
  recalculate_status
end
hook_run_cmd(hook_args, event_args) click to toggle source

Run cmd in the command-line with {{variables}}: dataset, project, miga, object (as defined for the event, if any)

  • hook_args: +[cmd]+

  • event_args: +[object (optional)]+

# File lib/miga/dataset/hooks.rb, line 59
def hook_run_cmd(hook_args, event_args)
  Process.wait(
    spawn hook_args.first.miga_variables(
      dataset: name, project: project.path, miga: MiGA::MiGA.root_path,
      object: event_args.first
    )
  )
end