rbbt-util 5.21.97 → 5.21.98
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/resource.rb +7 -1
- data/lib/rbbt/rest/client/step.rb +1 -0
- data/lib/rbbt/util/misc/inspect.rb +10 -0
- data/lib/rbbt/util/misc/multipart_payload.rb +11 -0
- data/lib/rbbt/util/tar.rb +0 -16
- data/lib/rbbt/workflow/accessor.rb +18 -19
- data/lib/rbbt/workflow/step.rb +1 -1
- data/lib/rbbt/workflow/step/run.rb +49 -1
- data/share/Rlib/util.R +11 -2
- data/share/rbbt_commands/app/start +4 -3
- data/share/rbbt_commands/workflow/info +17 -14
- data/share/rbbt_commands/workflow/task +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12d10e9ae9d12ed354fe3d8df24a14ea030bb1eb
|
4
|
+
data.tar.gz: 13416b83ec00f7dae0fc97479746cd636cf53a5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d86681d7392cd8a0dae501a10a792e91ca93a026adb918d386d5a5b83916525f66947d233bbe5302cf65c2c02ae2b19582ce52872946b98265c5d8752f02ea2f
|
7
|
+
data.tar.gz: a93dc769c50f8d08e74d8088caa7c953aee25a78b47576f0015fd8b73f113d736a234534e1faf791eee6e938686db4dcd03a9f1ac44e6643ce5aaca8b8da0a56
|
data/lib/rbbt/resource.rb
CHANGED
@@ -24,13 +24,19 @@ module Resource
|
|
24
24
|
base.subdir = ''
|
25
25
|
base.resources = {}
|
26
26
|
base.rake_dirs = {}
|
27
|
+
base.search_paths = Path::SEARCH_PATHS.dup
|
27
28
|
base.remote_server = Resource.remote_servers[base.to_s]
|
28
29
|
base
|
29
30
|
end
|
30
31
|
|
31
32
|
attr_accessor :pkgdir, :subdir, :resources, :rake_dirs, :remote_server, :search_paths
|
32
33
|
|
33
|
-
def
|
34
|
+
def set_libdir(value = nil)
|
35
|
+
_libdir = value || Path.caller_lib_dir
|
36
|
+
search_paths.merge!(:lib => File.join(_libdir, '{TOPLEVEL}', '{SUBPATH}'))
|
37
|
+
end
|
38
|
+
|
39
|
+
def root
|
34
40
|
Path.setup @subdir || "", @pkgdir, self, @search_paths
|
35
41
|
end
|
36
42
|
|
@@ -234,6 +234,16 @@ module Misc
|
|
234
234
|
"{"<< obj.collect{|k,v| obj2str(k) + '=>' << obj2str(v)}*"," << "}"
|
235
235
|
when Symbol
|
236
236
|
obj.to_s
|
237
|
+
when (defined? Path and Path)
|
238
|
+
if obj.exists?
|
239
|
+
if obj.directory?
|
240
|
+
"directory: #{obj.glob("**/*")}"
|
241
|
+
else
|
242
|
+
"file md5: #{digest(obj.read)}"
|
243
|
+
end
|
244
|
+
else
|
245
|
+
obj + " (file missing)"
|
246
|
+
end
|
237
247
|
when String
|
238
248
|
if obj.length > HASH2MD5_MAX_STRING_LENGTH
|
239
249
|
sample_large_obj(obj, HASH2MD5_MAX_STRING_LENGTH)
|
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'rbbt-util'
|
3
3
|
|
4
|
+
class Net::HTTPGenericRequest
|
5
|
+
alias send_request_with_body_stream_orig send_request_with_body_stream
|
6
|
+
def send_request_with_body_stream(*args)
|
7
|
+
Thread.new do
|
8
|
+
send_request_with_body_stream_orig(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
4
13
|
module RbbtMutiplartPayload
|
5
14
|
BOUNDARY = "Rbbt_Param_Stream"
|
6
15
|
EOL = "\r\n"
|
@@ -97,6 +106,7 @@ module RbbtMutiplartPayload
|
|
97
106
|
|
98
107
|
req = Net::HTTP::Post.new(uri.path)
|
99
108
|
if stream_input
|
109
|
+
Log.low "Streaming input #{stream_input.to_s}"
|
100
110
|
req.content_type = "multipart/form-data; boundary=" + RbbtMutiplartPayload::BOUNDARY + '; stream=' + stream_input.to_s
|
101
111
|
req.body_stream = post_data_stream
|
102
112
|
else
|
@@ -110,6 +120,7 @@ module RbbtMutiplartPayload
|
|
110
120
|
timeout = 60 * timeout_minutes
|
111
121
|
Misc.open_pipe do |sin|
|
112
122
|
Net::HTTP.start(uri.hostname, uri.port, :read_timeout => timeout) do |http|
|
123
|
+
Log.low "Starting connection for streaming job"
|
113
124
|
http.request(req) do |res|
|
114
125
|
if Net::HTTPSuccess === res
|
115
126
|
url_path = res["RBBT-STREAMING-JOB-URL"]
|
data/lib/rbbt/util/tar.rb
CHANGED
@@ -93,22 +93,6 @@ module Misc
|
|
93
93
|
# directory
|
94
94
|
def self.untar(io, destination)
|
95
95
|
return _untar_cmd(io, destination)
|
96
|
-
|
97
|
-
#Gem::Package::TarReader.new io do |tar|
|
98
|
-
# tar.each do |tarfile|
|
99
|
-
# destination_file = File.join destination, tarfile.full_name
|
100
|
-
|
101
|
-
# if tarfile.directory?
|
102
|
-
# FileUtils.mkdir_p destination_file
|
103
|
-
# else
|
104
|
-
# destination_directory = File.dirname(destination_file)
|
105
|
-
# FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
|
106
|
-
# File.open destination_file, "wb" do |f|
|
107
|
-
# f.print tarfile.read
|
108
|
-
# end
|
109
|
-
# end
|
110
|
-
# end
|
111
|
-
#end
|
112
96
|
end
|
113
97
|
end
|
114
98
|
|
@@ -730,11 +730,12 @@ module Workflow
|
|
730
730
|
_inputs
|
731
731
|
end
|
732
732
|
|
733
|
-
def real_dependencies(task,
|
733
|
+
def real_dependencies(task, orig_jobname, inputs, dependencies)
|
734
734
|
real_dependencies = []
|
735
735
|
path_deps = {}
|
736
736
|
dependencies.each do |dependency|
|
737
737
|
_inputs = IndiferentHash.setup(inputs.dup)
|
738
|
+
jobname = orig_jobname
|
738
739
|
jobname = _inputs[:jobname] if _inputs.include? :jobname
|
739
740
|
|
740
741
|
real_dep = case dependency
|
@@ -803,26 +804,24 @@ module Workflow
|
|
803
804
|
|
804
805
|
TAG = :hash
|
805
806
|
def step_path(taskname, jobname, inputs, dependencies, extension = nil)
|
806
|
-
#
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
end
|
807
|
+
raise "Jobname makes an invalid path: #{ jobname }" if jobname =~ /\.\./
|
808
|
+
if inputs.length > 0 or dependencies.any?
|
809
|
+
tagged_jobname = case TAG
|
810
|
+
when :hash
|
811
|
+
hash_str = Misc.obj2digest({:inputs => inputs, :dependencies => dependencies})
|
812
|
+
jobname + '_' << hash_str
|
813
|
+
else
|
814
|
+
jobname
|
815
|
+
end
|
816
|
+
else
|
817
|
+
tagged_jobname = jobname
|
818
|
+
end
|
819
819
|
|
820
|
-
|
821
|
-
|
822
|
-
|
820
|
+
if extension and not extension.empty?
|
821
|
+
tagged_jobname = tagged_jobname + ('.' << extension.to_s)
|
822
|
+
end
|
823
823
|
|
824
|
-
|
825
|
-
#}
|
824
|
+
workdir[taskname][tagged_jobname].find
|
826
825
|
end
|
827
826
|
|
828
827
|
def id_for(path)
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -72,7 +72,7 @@ class Step
|
|
72
72
|
|
73
73
|
load_inputs_from_info if @inputs.nil?
|
74
74
|
|
75
|
-
NamedArray.setup(@inputs, task.inputs) if task && task.inputs && !
|
75
|
+
NamedArray.setup(@inputs, task.inputs) if task && task.inputs && !(NamedArray === @inputs)
|
76
76
|
|
77
77
|
@inputs || []
|
78
78
|
end
|
@@ -145,6 +145,53 @@ class Step
|
|
145
145
|
raise $!
|
146
146
|
end
|
147
147
|
|
148
|
+
new_inputs = []
|
149
|
+
@inputs.each_with_index do |input,i|
|
150
|
+
name = @task.inputs[i]
|
151
|
+
type = @task.input_types[name]
|
152
|
+
|
153
|
+
if type == :directory
|
154
|
+
directory_inputs = file('directory_inputs')
|
155
|
+
input_source = directory_inputs['.source'][name].find
|
156
|
+
input_dir = directory_inputs[name].find
|
157
|
+
|
158
|
+
case input
|
159
|
+
when Path
|
160
|
+
if input.directory?
|
161
|
+
new_inputs << input
|
162
|
+
else
|
163
|
+
input.open do |io|
|
164
|
+
begin
|
165
|
+
Misc.untar(io, input_source)
|
166
|
+
rescue
|
167
|
+
raise ParameterException, "Error unpackaging tar directory input '#{name}':\n\n#{$!.message}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
tar_1 = input_source.glob("*")
|
171
|
+
raise ParameterException, "When using tar.gz files for directories, the directory must be the single first level entry" if tar_1.length != 1
|
172
|
+
FileUtils.ln_s Misc.path_relative_to(directory_inputs, tar_1.first), input_dir
|
173
|
+
new_inputs << input_dir
|
174
|
+
end
|
175
|
+
when File, IO, Tempfile
|
176
|
+
begin
|
177
|
+
Misc.untar(Open.gunzip(input), input_source)
|
178
|
+
rescue
|
179
|
+
raise ParameterException, "Error unpackaging tar directory input '#{name}':\n\n#{$!.message}"
|
180
|
+
end
|
181
|
+
tar_1 = input_source.glob("*")
|
182
|
+
raise ParameterException, "When using tar.gz files for directories, the directory must be the single first level entry" if tar_1.length != 1
|
183
|
+
FileUtils.ln_s Misc.path_relative_to(directory_inputs, tar_1.first), input_dir
|
184
|
+
new_inputs << input_dir
|
185
|
+
else
|
186
|
+
raise ParameterException, "Format of directory input '#{name}' not understood: #{Misc.fingerprint input}"
|
187
|
+
end
|
188
|
+
else
|
189
|
+
new_inputs << input
|
190
|
+
end
|
191
|
+
end if @inputs
|
192
|
+
|
193
|
+
@inputs = new_inputs if @inputs
|
194
|
+
|
148
195
|
if not task.inputs.nil?
|
149
196
|
info_inputs = @inputs.collect do |i|
|
150
197
|
if Path === i
|
@@ -200,7 +247,8 @@ class Step
|
|
200
247
|
end
|
201
248
|
end
|
202
249
|
begin
|
203
|
-
|
250
|
+
status = self.status
|
251
|
+
if status != :done and status != :error and status != :aborted
|
204
252
|
Misc.insist do
|
205
253
|
set_info :done, (done_time = Time.now)
|
206
254
|
set_info :total_time_elapsed, (total_time_elapsed = done_time - issue_time)
|
data/share/Rlib/util.R
CHANGED
@@ -654,7 +654,15 @@ rbbt.install.github <- function(pkg, ...){
|
|
654
654
|
|
655
655
|
rbbt.require <- function(pkg, ...){
|
656
656
|
list.of.packages <- c(pkg)
|
657
|
-
|
657
|
+
|
658
|
+
clean.packages <- c()
|
659
|
+
for (pkg in list.of.packages){
|
660
|
+
parts = strsplit(pkg,'/')[[1]]
|
661
|
+
clean.packages <- c(clean.packages, parts[length(parts)])
|
662
|
+
}
|
663
|
+
|
664
|
+
new.packages <- list.of.packages[!(clean.packages %in% installed.packages()[,"Package"])]
|
665
|
+
|
658
666
|
for (pkg in new.packages){
|
659
667
|
if (!rbbt.install.github(pkg, ...)){
|
660
668
|
if (!rbbt.install.CRAN(pkg, ...)){
|
@@ -664,6 +672,7 @@ rbbt.require <- function(pkg, ...){
|
|
664
672
|
}
|
665
673
|
}
|
666
674
|
}
|
667
|
-
|
675
|
+
|
676
|
+
library(clean.packages, character.only=T)
|
668
677
|
}
|
669
678
|
|
@@ -62,7 +62,8 @@ Misc.in_dir(app_dir) do
|
|
62
62
|
ENV["RBBT_VIEWS_DIR"] = options[:views] if options.include?(:views)
|
63
63
|
|
64
64
|
if options[:stream]
|
65
|
-
raise "No streaming available for any server other than puma" unless options[:server] =~ /^puma/
|
65
|
+
#raise "No streaming available for any server other than puma" unless options[:server] =~ /^puma/
|
66
|
+
raise "No streaming available for any server other than unicorn" unless options[:server] =~ /^unicorn/
|
66
67
|
ENV["RBBT_WORKFLOW_TASK_STREAM"] = 'true'
|
67
68
|
end
|
68
69
|
|
@@ -77,8 +78,8 @@ Misc.in_dir(app_dir) do
|
|
77
78
|
end
|
78
79
|
|
79
80
|
case server
|
80
|
-
when '
|
81
|
-
system ENV, "
|
81
|
+
when 'passenger'
|
82
|
+
system ENV, "env RBBT_LOG=0 passenger start -R '#{config_ru_file}' -p #{options[:port] || "2887"}"
|
82
83
|
when 'puma_alt'
|
83
84
|
system ENV, "puma '#{config_ru_file}' -p #{options[:Port] || "2887"} -w 3 -t 8:32 --preload"
|
84
85
|
else
|
@@ -126,8 +126,8 @@ if all
|
|
126
126
|
end
|
127
127
|
|
128
128
|
if recursive
|
129
|
-
puts Log.color(:magenta, "Recursive inputs") << ": "
|
130
129
|
inputs = step.info[:inputs]
|
130
|
+
inputs = {}
|
131
131
|
deps = step.info[:dependencies].collect{|v| get_step v.last }
|
132
132
|
|
133
133
|
while deps.any? do
|
@@ -137,19 +137,22 @@ if recursive
|
|
137
137
|
deps.concat (dep.info[:dependencies] || []).collect{|v| get_step v.last }
|
138
138
|
end
|
139
139
|
|
140
|
-
inputs.
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
140
|
+
if inputs.any?
|
141
|
+
puts Log.color(:magenta, "Recursive inputs") << ": "
|
142
|
+
inputs.each do |input,value|
|
143
|
+
case value
|
144
|
+
when nil
|
145
|
+
puts Misc.format_definition_list_item(" " << input.to_s, 'nil', 80, 20, :blue)
|
146
|
+
when Array
|
147
|
+
puts Misc.format_definition_list_item(" " << input.to_s, (value.length > 6 ? (value[0..5])*"\n\n" << "\n\n" << "..." : value * "\n\n" ), 80, 20, :blue).gsub("\n\n","\n")
|
148
|
+
when TrueClass, FalseClass
|
149
|
+
puts Misc.format_definition_list_item(" " << input.to_s, value.to_s, 80, 20, :blue)
|
150
|
+
else
|
151
|
+
lines = value.to_s.split("\n").collect{|l| l.length >= 60 ? l[0..45] + " ..." : l }
|
152
|
+
text = lines[0..5].compact * "\n\n"
|
153
|
+
text << "\n\n...\n\n" if lines.length > 6
|
154
|
+
puts Misc.format_definition_list_item(" " << input.to_s, text, 80, 20, :blue).gsub("\n\n","\n")
|
155
|
+
end
|
153
156
|
end
|
154
157
|
end
|
155
158
|
end
|
@@ -108,6 +108,8 @@ def fix_options(workflow, task, job_options)
|
|
108
108
|
when :array
|
109
109
|
if input_options[name] and input_options[name][:stream] and String === value and Misc.is_filename? value
|
110
110
|
get_value_stream(value)
|
111
|
+
elsif input_options[name] and input_options[name][:stream] and value == "-"
|
112
|
+
STDIN
|
111
113
|
else
|
112
114
|
if Array === value
|
113
115
|
value
|
@@ -146,6 +148,8 @@ def fix_options(workflow, task, job_options)
|
|
146
148
|
TSV.open(StringIO.new(value), :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
|
147
149
|
end
|
148
150
|
end
|
151
|
+
when :directory
|
152
|
+
Path.setup(File.expand_path(value))
|
149
153
|
else
|
150
154
|
value
|
151
155
|
end
|
@@ -321,7 +325,7 @@ begin
|
|
321
325
|
|
322
326
|
if do_exec or (job.respond_to?(:is_exec) and job.is_exec)
|
323
327
|
res = job.exec(:stream)
|
324
|
-
res = JSON.parse(res.read) if (defined?(WorkflowRESTClient) and WorkflowRESTClient::RemoteStep === job)
|
328
|
+
#res = JSON.parse(res.read) if (defined?(WorkflowRESTClient) and WorkflowRESTClient::RemoteStep === job)
|
325
329
|
|
326
330
|
case
|
327
331
|
when res.respond_to?(:gets)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.21.
|
4
|
+
version: 5.21.98
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|