rbbt-util 5.19.36 → 5.19.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rbbt/rest/client/adaptor.rb +1 -1
- data/lib/rbbt/rest/client/get.rb +6 -4
- data/lib/rbbt/rest/client/step.rb +30 -6
- data/lib/rbbt/rest/client.rb +3 -1
- data/lib/rbbt/tsv/accessor.rb +2 -1
- data/lib/rbbt/util/misc/inspect.rb +8 -4
- data/lib/rbbt/util/misc/multipart_payload.rb +14 -8
- data/lib/rbbt/util/misc/pipes.rb +9 -0
- data/lib/rbbt/workflow/step/run.rb +4 -33
- data/share/rbbt_commands/app/start +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 137e4838f414d232714269ef64c04ba299fa3f62
|
4
|
+
data.tar.gz: 7cc30b69428f3f33461d639c6657d101fb09547f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f901c235ed7ef31b1693b1d99282ad86f7f8f37c1b18e9e62a4c67adafa29e10d5fc3b53e12adba5803ce4571958401bd78a65723e1a9e17736e52a7acf755a
|
7
|
+
data.tar.gz: 2aa36eb9d0a80795a230187894e1f05dd51b1125cf890cda3f740e8e66d1c0320f3f2637ac7d10e38b16698935cb313b3a5498283e7ccf26e1848df3c8620523
|
@@ -61,6 +61,6 @@ class WorkflowRESTClient
|
|
61
61
|
@asynchronous_exports = task_exports["asynchronous"].collect{|task| task.to_sym }
|
62
62
|
@synchronous_exports = task_exports["synchronous"].collect{|task| task.to_sym }
|
63
63
|
@exec_exports = task_exports["exec"].collect{|task| task.to_sym }
|
64
|
-
|
64
|
+
@can_stream = task_exports["can_stream"]
|
65
65
|
end
|
66
66
|
end
|
data/lib/rbbt/rest/client/get.rb
CHANGED
@@ -57,11 +57,14 @@ class WorkflowRESTClient
|
|
57
57
|
Log.debug{ "RestClient get_raw: #{ url } - #{Misc.fingerprint params}" }
|
58
58
|
params = params.merge({ :_format => 'raw' })
|
59
59
|
params = fix_params params
|
60
|
-
capture_exception do
|
60
|
+
res = capture_exception do
|
61
61
|
Misc.insist(2, 0.5) do
|
62
|
-
RestClient.get(URI.encode(url), :params => params)
|
62
|
+
res = RestClient.get(URI.encode(url), :params => params)
|
63
|
+
raise TryAgain if res.code == 202
|
64
|
+
res
|
63
65
|
end
|
64
66
|
end
|
67
|
+
res
|
65
68
|
end
|
66
69
|
|
67
70
|
def self.get_json(url, params = {})
|
@@ -83,7 +86,6 @@ class WorkflowRESTClient
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def self.post_jobname(url, params = {})
|
86
|
-
Log.stack caller
|
87
89
|
Log.debug{ "RestClient post_jobname: #{ url } - #{Misc.fingerprint params}" }
|
88
90
|
params = params.merge({ :_format => 'jobname' })
|
89
91
|
params = fix_params params
|
@@ -96,7 +98,7 @@ class WorkflowRESTClient
|
|
96
98
|
|
97
99
|
name
|
98
100
|
end
|
99
|
-
|
101
|
+
|
100
102
|
def self.post_json(url, params = {})
|
101
103
|
if url =~ /_cache_type=:exec/
|
102
104
|
JSON.parse(Open.open(url, :nocache => true))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class WorkflowRESTClient
|
2
2
|
class RemoteStep < Step
|
3
3
|
|
4
|
-
attr_accessor :url, :base_url, :task, :base_name, :inputs, :result_type, :result_description, :is_exec
|
4
|
+
attr_accessor :url, :base_url, :task, :base_name, :inputs, :result_type, :result_description, :is_exec, :stream_input
|
5
5
|
|
6
6
|
def self.get_streams(inputs)
|
7
7
|
new_inputs = {}
|
@@ -17,9 +17,10 @@ class WorkflowRESTClient
|
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
-
def initialize(base_url, task = nil, base_name = nil, inputs = nil, result_type = nil, result_description = nil, is_exec = false)
|
20
|
+
def initialize(base_url, task = nil, base_name = nil, inputs = nil, result_type = nil, result_description = nil, is_exec = false, stream_input = nil)
|
21
21
|
@base_url, @task, @base_name, @inputs, @result_type, @result_description, @is_exec = base_url, task, base_name, inputs, result_type, result_description, is_exec
|
22
22
|
@mutex = Mutex.new
|
23
|
+
@stream_input = stream_input
|
23
24
|
@inputs = RemoteStep.get_streams @inputs
|
24
25
|
end
|
25
26
|
|
@@ -176,7 +177,34 @@ class WorkflowRESTClient
|
|
176
177
|
load_res get
|
177
178
|
end
|
178
179
|
|
180
|
+
def _stream_job(stream_input, cache_type = :exec)
|
181
|
+
require 'rbbt/util/misc/multipart_payload'
|
182
|
+
WorkflowRESTClient.capture_exception do
|
183
|
+
url = URI.encode(File.join(base_url, task.to_s))
|
184
|
+
Log.debug{ "RestClient stream: #{ url } #{stream_input} #{cache_type} - #{Misc.fingerprint inputs}" }
|
185
|
+
task_params = inputs.merge(:_cache_type => cache_type, :jobname => base_name, :_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json)
|
186
|
+
res = RbbtMutiplartPayload.issue url, task_params, :mutations, nil, nil, true
|
187
|
+
type = res.gets
|
188
|
+
case type.strip
|
189
|
+
when "LOCATION"
|
190
|
+
url = res.gets
|
191
|
+
url.sub!(/\?.*/,'')
|
192
|
+
WorkflowRESTClient.get_raw(url)
|
193
|
+
when "STREAM"
|
194
|
+
res
|
195
|
+
when "BULK"
|
196
|
+
res.read
|
197
|
+
else
|
198
|
+
raise "What? " + type
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
179
203
|
def _run_job(cache_type = :async)
|
204
|
+
#if cache_type == :stream and stream_input
|
205
|
+
if cache_type == :stream or cache_type == :exec and stream_input
|
206
|
+
return _stream_job(stream_input, cache_type)
|
207
|
+
end
|
180
208
|
WorkflowRESTClient.capture_exception do
|
181
209
|
url = URI.encode(File.join(base_url, task.to_s))
|
182
210
|
task_params = inputs.merge(:_cache_type => cache_type, :jobname => base_name, :_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json)
|
@@ -205,10 +233,6 @@ class WorkflowRESTClient
|
|
205
233
|
sin.close
|
206
234
|
@done = true
|
207
235
|
end
|
208
|
-
#nsout, nsin = Misc.pipe
|
209
|
-
#Misc.consume_stream(reader, true, nsin, true) do @done = true end
|
210
|
-
#iii :ret
|
211
|
-
#nsout
|
212
236
|
end
|
213
237
|
end
|
214
238
|
|
data/lib/rbbt/rest/client.rb
CHANGED
@@ -43,7 +43,9 @@ class WorkflowRESTClient
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
|
47
|
+
stream_input = @can_stream ? task_info(task)[:input_options].select{|k,o| o[:stream] }.collect{|k,o| k }.first : nil
|
48
|
+
RemoteStep.new(url, task, name, fixed_inputs, task_info[:result_type], task_info[:result_description], @exec_exports.include?(task), stream_input)
|
47
49
|
end
|
48
50
|
|
49
51
|
def load_id(id)
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -229,11 +229,15 @@ module Misc
|
|
229
229
|
when (defined? Step and Step)
|
230
230
|
"<Step #{obj.path}>"
|
231
231
|
else
|
232
|
-
|
233
|
-
|
234
|
-
obj_ins.gsub(/:0x[a-f0-9]+/,'')
|
232
|
+
if obj.respond_to? :filename
|
233
|
+
"<IO:" << obj.filename << ">"
|
235
234
|
else
|
236
|
-
obj_ins
|
235
|
+
obj_ins = obj.inspect
|
236
|
+
if obj_ins =~ /:0x0/
|
237
|
+
obj_ins.gsub(/:0x[a-f0-9]+/,'')
|
238
|
+
else
|
239
|
+
obj_ins
|
240
|
+
end
|
237
241
|
end
|
238
242
|
end
|
239
243
|
|
@@ -43,8 +43,11 @@ module RbbtMutiplartPayload
|
|
43
43
|
header = input_header(name, filename)
|
44
44
|
io.write "--" + BOUNDARY + EOL + header + EOL + EOL
|
45
45
|
|
46
|
-
while c = content.read(1024)
|
47
|
-
|
46
|
+
#while c = content.read(1024)
|
47
|
+
# io.write c
|
48
|
+
#end
|
49
|
+
while line = content.gets
|
50
|
+
io.puts line
|
48
51
|
end
|
49
52
|
content.close
|
50
53
|
end
|
@@ -56,9 +59,10 @@ module RbbtMutiplartPayload
|
|
56
59
|
end
|
57
60
|
|
58
61
|
def self.post_data_stream(inputs = nil, stream_input = nil, stream_io = nil, stream_filename = nil)
|
59
|
-
sout, sin = Misc.pipe
|
62
|
+
#sout, sin = Misc.pipe
|
60
63
|
|
61
|
-
Thread.new do
|
64
|
+
#Thread.new do
|
65
|
+
Misc.open_pipe do |sin|
|
62
66
|
inputs.each do |input,content|
|
63
67
|
input = input.to_s
|
64
68
|
next if stream_input and input == stream_input.to_s
|
@@ -82,12 +86,11 @@ module RbbtMutiplartPayload
|
|
82
86
|
|
83
87
|
RbbtMutiplartPayload.add_stream(sin, stream_input.to_s, stream_io, stream_filename) if stream_input
|
84
88
|
RbbtMutiplartPayload.close_stream(sin)
|
89
|
+
sin.close unless sin.closed?
|
85
90
|
end
|
86
|
-
|
87
|
-
sout
|
88
91
|
end
|
89
92
|
|
90
|
-
def self.issue(url, inputs = nil, stream_input = nil, stream_io = nil, stream_filename = nil)
|
93
|
+
def self.issue(url, inputs = nil, stream_input = nil, stream_io = nil, stream_filename = nil, report_type = false)
|
91
94
|
|
92
95
|
uri = URI(url)
|
93
96
|
req = Net::HTTP::Post.new(uri.path)
|
@@ -100,7 +103,7 @@ module RbbtMutiplartPayload
|
|
100
103
|
when String
|
101
104
|
inputs[stream_input]
|
102
105
|
when File
|
103
|
-
inputs[stream_input].
|
106
|
+
inputs[stream_input].path
|
104
107
|
else
|
105
108
|
'file'
|
106
109
|
end
|
@@ -121,12 +124,15 @@ module RbbtMutiplartPayload
|
|
121
124
|
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
122
125
|
http.request(req) do |res|
|
123
126
|
if Net::HTTPRedirection === res
|
127
|
+
sin.puts "LOCATION" if report_type
|
124
128
|
sin.write res["location"]
|
125
129
|
elsif stream_input
|
130
|
+
sin.puts "STREAM" if report_type
|
126
131
|
res.read_body do |c|
|
127
132
|
sin.write c
|
128
133
|
end
|
129
134
|
else
|
135
|
+
sin.puts "BULK" if report_type
|
130
136
|
sin.write res.body
|
131
137
|
end
|
132
138
|
sin.close
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -172,11 +172,13 @@ class Step
|
|
172
172
|
dependency.grace
|
173
173
|
|
174
174
|
if dependency.aborted?
|
175
|
+
Log.warn "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} aborted (clean and retry) -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
175
176
|
dependency.clean
|
176
177
|
raise TryAgain
|
177
178
|
end
|
178
179
|
|
179
180
|
if dependency.error?
|
181
|
+
Log.error "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} error -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
180
182
|
raise DependencyError, [dependency.path, dependency.messages.last] * ": " if dependency.error?
|
181
183
|
end
|
182
184
|
|
@@ -185,45 +187,14 @@ class Step
|
|
185
187
|
next
|
186
188
|
end
|
187
189
|
|
188
|
-
Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joining -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
189
190
|
begin
|
191
|
+
Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joining -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
190
192
|
dependency.join
|
191
193
|
raise TryAgain unless dependency.done?
|
194
|
+
Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joined -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
192
195
|
rescue Aborted
|
193
196
|
raise TryAgain
|
194
197
|
end
|
195
|
-
Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joined -- #{Log.color :blue, dependency.path} -- #{Log.color :yellow, self.short_path}"
|
196
|
-
|
197
|
-
#if not dependency.done?
|
198
|
-
# if dependency.started?
|
199
|
-
# dependency.grace
|
200
|
-
# if dependency.error?
|
201
|
-
# raise DependencyError, [dependency.path, dependency.messages.last] * ": " if dependency.error?
|
202
|
-
# elsif dependency.streaming?
|
203
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} streaming -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
204
|
-
# else
|
205
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joining -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
206
|
-
# begin
|
207
|
-
# dependency.join unless dependency.streaming?
|
208
|
-
# rescue Aborted
|
209
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} #{Log.color :red, "aborted"} -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
210
|
-
# if dependency.aborted?
|
211
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} #{Log.color :red, "aborted cleaning"} -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
212
|
-
# dependency.clean
|
213
|
-
# raise TryAgain
|
214
|
-
# end
|
215
|
-
# end
|
216
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} joined -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
217
|
-
# end
|
218
|
-
# else
|
219
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} starting -- #{Log.color :blue, dependency.path} -- #{Log.color :blue, self.short_path}"
|
220
|
-
# dependency.run(:stream)
|
221
|
-
# dependency.grace
|
222
|
-
# dependency.join unless dependency.streaming?
|
223
|
-
# end
|
224
|
-
#else
|
225
|
-
# Log.info "#{Log.color :cyan, "dependency"} #{Log.color :yellow, task.name.to_s || ""} => #{Log.color :yellow, dependency.task_name.to_s || ""} done -- #{Log.color :blue, dependency.short_path}"
|
226
|
-
#end
|
227
198
|
|
228
199
|
rescue TryAgain
|
229
200
|
retry
|
@@ -58,7 +58,7 @@ Misc.in_dir(app_dir) do
|
|
58
58
|
ENV["RBBT_VIEWS_DIR"] = options[:views] if options.include?(:views)
|
59
59
|
|
60
60
|
if options[:stream]
|
61
|
-
raise "No streaming available for any server other than puma" unless options[:server] =~ /^puma
|
61
|
+
raise "No streaming available for any server other than puma" unless options[:server] =~ /^puma/
|
62
62
|
ENV["RBBT_WORKFLOW_TASK_STREAM"] = 'true'
|
63
63
|
end
|
64
64
|
|