Module: Ripe::DSL

Defined in:
lib/ripe/dsl.rb,
lib/ripe/dsl/task_dsl.rb,
lib/ripe/dsl/workflow_dsl.rb

Overview

This module contains ‘domain-specific language` syntactic sugar for defining workflows and tasks.

Defined Under Namespace

Classes: TaskDSL, WorkflowDSL

Instance Method Summary collapse

Instance Method Details

#task(handle, vars = {type: 'bash'}, &block) ⇒ WorkingBlock?

Create a WorkingBlock using a DSL. It is syntactic sugar for

foo = WorkingBlock.new('/path/to/foo', {
  param1: 'val1',
  param2: 'val2',
})

in the form of:

foo = task 'foo' do
  param :param1, 'val1'
  param :param2, 'val2'
end

foo = task 'foo' do |t|
  t.param :param1, 'val1'
  t.param :param2, 'val2'
end

foo = task 'foo', task: 'bash' do |t|
  t.param :param1, 'val1'
end

It internally uses Ripe::DSL::TaskDSL to provide the DSL.

Parameters:

  • handle (String)

    the name of the task

  • block (Proc)

    executes block in the context of TaskDSL

Returns:

  • (WorkingBlock, nil)

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ripe/dsl/task_dsl.rb', line 39

def task(handle, vars = {type: 'bash'}, &block)
  # Obtain list of `WorkingBlock` types.
  working_block = Blocks::WorkingBlock.subclasses.select { |k| k.id == vars[:type] }.first

  filename = "#{handle}.#{working_block.extension}"
  full_filename = Library.find(:task, filename)

  if full_filename == nil
    abort "Could not find task `#{filename}`."
  # else
  #   puts "Found task `#{handle}` @ `#{full_filename}`."
  end

  params = TaskDSL.new(handle, &block).params
  working_block.new(full_filename, params)
end

#workflow(handle, &block) ⇒ Object

Create a Workflow using a DSL. It is syntactic sugar for

workflow 'foobar' do
  param :node_count,    1
  param :ppn,           8
  param :project_name,  'abc-012-ab'
  param :queue,         'queue'
  param :walltime,      '12:00:00'

  describe do |sample, params|
    # task
  end
end

The block given in describe has two mandatory arguments:

- sample: the name of the sample
- params: the parameters defined at the workflow-level

It internally uses Ripe::DSL::WorkflowDSL to provide the DSL.

Parameters:

  • handle (String)

    the name of the workflow

  • block (Proc)

    executes block in the context of WorkflowDSL

See Also:



33
34
35
# File 'lib/ripe/dsl/workflow_dsl.rb', line 33

def workflow(handle, &block)
  $workflow = WorkflowDSL.new(handle, &block)
end