Sha256: 686e1614143b5b14eb440f6862ea8cdb1f14c6a3ce0a00a01bbdcd28295e16f5

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

#!/usr/bin/env ruby

require 'rbbt/util/simpleopt'
require 'rbbt/workflow'
require 'rbbt/workflow/usage'

def run_task(workflow, task, name)
  Log.info "Running example #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"

  example_dir = workflow.libdir.examples[task][name].find
  Log.debug "Using #{example_dir}"

  ARGV.replace([workflow.to_s, task, '--load_inputs', example_dir, '--jobname', name,'--O','/dev/null'] + $saved_args)

  @pid = Process.fork{
    load Rbbt.share.rbbt_commands.workflow.task.find
  }
  Signal.trap(:INT) do
    begin
      Process.kill "INT", @pid
    ensure
      exit -1
    end
  end
  Process.wait @pid

  if $?.success?
    Log.info "#{Log.color :green, "SUCCESS"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
  else
    Log.info "#{Log.color :red, "ERROR"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
  end
end

workflow = ARGV.shift
raise ParameterException if workflow.nil?

task = ARGV.shift
task = nil if task == '--'

name = ARGV.shift if task
name = nil if name == '--'

$saved_args = ARGV.dup


workflow = Workflow.require_workflow workflow

tasks = task ? [task] : workflow.libdir.examples.glob('*').collect{|file| File.basename file }

tasks.each do |task|
  names = name ? [name] : workflow.libdir.examples[task].glob('*').collect{|file| File.basename file }
  names.each do |name|
    run_task workflow, task, name
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rbbt-util-5.8.2 share/rbbt_commands/workflow/example
rbbt-util-5.8.1 share/rbbt_commands/workflow/example
rbbt-util-5.8.0 share/rbbt_commands/workflow/example
rbbt-util-5.7.0 share/rbbt_commands/workflow/example
rbbt-util-5.6.17 share/rbbt_commands/workflow/example
rbbt-util-5.6.16 share/rbbt_commands/workflow/example
rbbt-util-5.6.15 share/rbbt_commands/workflow/example
rbbt-util-5.6.14 share/rbbt_commands/workflow/example
rbbt-util-5.6.13 share/rbbt_commands/workflow/example