Sha256: ef2d4b9626d203e4313b57680c1d3e9d062866ab071ca346dcd4f3a89b9bca2c

Contents?: true

Size: 1.57 KB

Versions: 77

Compression:

Stored size: 1.57 KB

Contents

require 'rest_client'
require 'json'
require 'rbbt/workflow'
require 'rbbt/workflow/step'
require 'rbbt/util/misc'

require 'rbbt/rest/client/get'
require 'rbbt/rest/client/adaptor'
require 'rbbt/rest/client/step'

class WorkflowRESTClient 
  include Workflow

  attr_accessor :url, :name, :exec_exports, :synchronous_exports, :asynchronous_exports, :stream_exports

  def initialize(url, name)
    Log.debug{ "Loading remote workflow #{ name }: #{ url }" }
    @url, @name = url, name
    init_remote_tasks
  end
  
  def to_s
    name
  end

  def job(task, name, inputs)
    task_info = task_info(task)
    fixed_inputs = {}
    input_types = task_info[:input_types]

    inputs.each do |k,v| 
      k = k.to_sym
      if TSV === v
        fixed_inputs[k] = v.to_s
      else
        next if input_types[k].nil?
        case input_types[k].to_sym
        when :tsv, :array, :file, :text
          fixed_inputs[k] = (String === v and Open.exists?(v)) ? Open.open(v) : v
        else
          fixed_inputs[k] = v
        end
      end
    end

    stream_input = @can_stream ? task_info(task)[:input_options].select{|k,o| o[:stream] }.collect{|k,o| k }.first : nil
    RemoteStep.new(url, task, name, fixed_inputs, task_info[:result_type], task_info[:result_description], @exec_exports.include?(task), @stream_exports.include?(task), stream_input)
  end

  def load_id(id)
    task, name = id.split("/")
    step = RemoteStep.new url, task, nil
    step.name = name
    step.result_type = task_info(task)[:result_type]
    step.result_description = task_info(task)[:result_description]
    step
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
rbbt-util-5.26.157 lib/rbbt/rest/client.rb
rbbt-util-5.26.156 lib/rbbt/rest/client.rb
rbbt-util-5.26.155 lib/rbbt/rest/client.rb
rbbt-util-5.26.154 lib/rbbt/rest/client.rb
rbbt-util-5.26.153 lib/rbbt/rest/client.rb
rbbt-util-5.26.152 lib/rbbt/rest/client.rb
rbbt-util-5.26.151 lib/rbbt/rest/client.rb
rbbt-util-5.26.150 lib/rbbt/rest/client.rb
rbbt-util-5.26.149 lib/rbbt/rest/client.rb
rbbt-util-5.26.148 lib/rbbt/rest/client.rb
rbbt-util-5.26.147 lib/rbbt/rest/client.rb
rbbt-util-5.26.146 lib/rbbt/rest/client.rb
rbbt-util-5.26.145 lib/rbbt/rest/client.rb
rbbt-util-5.26.144 lib/rbbt/rest/client.rb
rbbt-util-5.26.143 lib/rbbt/rest/client.rb
rbbt-util-5.26.142 lib/rbbt/rest/client.rb
rbbt-util-5.26.141 lib/rbbt/rest/client.rb
rbbt-util-5.26.140 lib/rbbt/rest/client.rb
rbbt-util-5.26.139 lib/rbbt/rest/client.rb
rbbt-util-5.26.138 lib/rbbt/rest/client.rb