libis-workflow 2.0.32 → 2.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -8
- data/lib/libis/workflow/base/file_item.rb +1 -1
- data/lib/libis/workflow/base/workflow.rb +1 -1
- data/lib/libis/workflow/task.rb +69 -47
- data/lib/libis/workflow/version.rb +1 -1
- data/libis-workflow.gemspec +6 -5
- 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: b8ed3adeee0f666862bdedd0f695722d67619385
|
4
|
+
data.tar.gz: 8935af86aff161a31acb46e0a195b7a15b33d7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 707f1e5286e629a04b7d5b1b0623bf5d23d175d2b278c5d1a42d0b3502e529db433407f12b328f2b64860140a6f1b2ef88da245e1f03ca0b8213f2b80258cb4f
|
7
|
+
data.tar.gz: d81c44bfe8b845ffc6f46a54ef19b9458482aef798945b3daa034b56b0365ff1947e723f824175e9b1a0eba2600285a8ad8d1228676a481a7a7c4c0b80b44195
|
data/.travis.yml
CHANGED
@@ -3,8 +3,7 @@ sudo: false
|
|
3
3
|
bundler_args: --without development
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.2.0
|
6
|
+
- 2.2.2
|
8
7
|
- ruby-head
|
9
8
|
- jruby-9.0.1.0
|
10
9
|
jdk:
|
@@ -13,13 +12,9 @@ jdk:
|
|
13
12
|
- oraclejdk8
|
14
13
|
matrix:
|
15
14
|
exclude:
|
16
|
-
- rvm: 2.
|
15
|
+
- rvm: 2.2.2
|
17
16
|
jdk: oraclejdk7
|
18
|
-
- rvm: 2.
|
19
|
-
jdk: oraclejdk8
|
20
|
-
- rvm: 2.2.0
|
21
|
-
jdk: oraclejdk7
|
22
|
-
- rvm: 2.2.0
|
17
|
+
- rvm: 2.2.2
|
23
18
|
jdk: oraclejdk8
|
24
19
|
- rvm: ruby-head
|
25
20
|
jdk: oraclejdk7
|
data/lib/libis/workflow/task.rb
CHANGED
@@ -23,7 +23,7 @@ module Libis
|
|
23
23
|
parameter retry_interval: 10, description: 'Number of seconds to wait between retries.'
|
24
24
|
|
25
25
|
def self.task_classes
|
26
|
-
ObjectSpace.each_object(::Class).select {
|
26
|
+
ObjectSpace.each_object(::Class).select {|klass| klass < self}
|
27
27
|
end
|
28
28
|
|
29
29
|
def initialize(parent, cfg = {})
|
@@ -33,8 +33,8 @@ module Libis
|
|
33
33
|
configure cfg
|
34
34
|
end
|
35
35
|
|
36
|
-
def <<(
|
37
|
-
raise Libis::WorkflowError, "Processing task '#{
|
36
|
+
def <<(_task)
|
37
|
+
raise Libis::WorkflowError, "Processing task '#{namepath}' is not allowed to have subtasks."
|
38
38
|
end
|
39
39
|
|
40
40
|
# @param [Libis::Workflow::Base::WorkItem] item
|
@@ -42,23 +42,24 @@ module Libis
|
|
42
42
|
check_item_type ::Libis::Workflow::Base::WorkItem, item
|
43
43
|
self.workitem = item
|
44
44
|
|
45
|
-
case
|
45
|
+
case action
|
46
46
|
when :retry
|
47
|
-
if item.check_status(:DONE,
|
48
|
-
debug 'Retry: skipping task %s because it has finished successfully.', item,
|
47
|
+
if item.check_status(:DONE, namepath)
|
48
|
+
debug 'Retry: skipping task %s because it has finished successfully.', item, namepath
|
49
49
|
return item
|
50
50
|
end
|
51
51
|
when :failed
|
52
52
|
return item
|
53
53
|
else
|
54
|
+
# type code here
|
54
55
|
end
|
55
56
|
|
56
|
-
(parameter(:retry_count)+1).times do
|
57
|
+
(parameter(:retry_count) + 1).times do
|
57
58
|
|
58
59
|
i = run_item(item)
|
59
60
|
item = i if i.is_a?(Libis::Workflow::WorkItem)
|
60
61
|
|
61
|
-
case item.status(
|
62
|
+
case item.status(namepath)
|
62
63
|
when :DONE
|
63
64
|
self.action = :run
|
64
65
|
return item
|
@@ -79,7 +80,7 @@ module Libis
|
|
79
80
|
end
|
80
81
|
|
81
82
|
item.get_run.action = :failed
|
82
|
-
|
83
|
+
|
83
84
|
return item
|
84
85
|
|
85
86
|
rescue WorkflowError => e
|
@@ -90,7 +91,7 @@ module Libis
|
|
90
91
|
set_status item, :FAILED
|
91
92
|
raise e if parent
|
92
93
|
|
93
|
-
rescue
|
94
|
+
rescue => e
|
94
95
|
set_status item, :FAILED
|
95
96
|
fatal_error "Exception occured: #{e.message}", item
|
96
97
|
debug e.backtrace.join("\n")
|
@@ -101,43 +102,43 @@ module Libis
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def names
|
104
|
-
(
|
105
|
+
(parent.names rescue []).push(name).compact
|
105
106
|
end
|
106
107
|
|
107
|
-
def namepath
|
108
|
-
|
108
|
+
def namepath
|
109
|
+
names.join('/')
|
109
110
|
end
|
110
111
|
|
111
112
|
def apply_options(opts)
|
112
113
|
o = {}
|
113
114
|
o.merge!(opts[self.class.to_s] || {})
|
114
|
-
o.merge!(opts[
|
115
|
+
o.merge!(opts[name] || opts[names.join('/')] || {})
|
115
116
|
|
116
|
-
if o
|
117
|
+
if o && o.is_a?(Hash)
|
117
118
|
default_values.each do |name, _|
|
118
119
|
next unless o.key?(name.to_s)
|
119
120
|
next if o[name.to_s].nil?
|
120
121
|
paramdef = get_parameter_definition name.to_sym
|
121
122
|
value = paramdef.parse(o[name.to_s])
|
122
|
-
|
123
|
+
parameter(name.to_sym, value)
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
128
|
def message(severity, msg, *args)
|
128
|
-
taskname =
|
129
|
-
|
130
|
-
item =
|
129
|
+
taskname = namepath rescue nil
|
130
|
+
set_application(taskname)
|
131
|
+
item = workitem rescue nil
|
131
132
|
item = args.shift if args.size > 0 and args[0].is_a?(::Libis::Workflow::Base::WorkItem)
|
132
133
|
subject = item.namepath rescue nil
|
133
134
|
subject ||= item.name rescue nil
|
134
135
|
subject ||= item.to_s rescue nil
|
135
|
-
|
136
|
+
set_subject(subject)
|
136
137
|
super(severity, msg, *args)
|
137
138
|
end
|
138
139
|
|
139
140
|
def logger
|
140
|
-
(
|
141
|
+
(parent || get_run).logger
|
141
142
|
end
|
142
143
|
|
143
144
|
protected
|
@@ -145,16 +146,16 @@ module Libis
|
|
145
146
|
def configure(cfg)
|
146
147
|
self.name = cfg['name'] || (cfg['class'] || self.class).to_s.split('::').last
|
147
148
|
(cfg['options'] || {}).merge(
|
148
|
-
cfg.reject {
|
149
|
+
cfg.reject {|k, _| %w[options name class].include? k}
|
149
150
|
).symbolize_keys.each do |k, v|
|
150
|
-
|
151
|
+
parameter(k, v)
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
154
155
|
def run_item(item)
|
155
156
|
@item_skipper = false
|
156
157
|
|
157
|
-
return item if item.status(
|
158
|
+
return item if item.status(namepath) == :DONE
|
158
159
|
|
159
160
|
pre_process(item)
|
160
161
|
|
@@ -163,10 +164,10 @@ module Libis
|
|
163
164
|
else
|
164
165
|
set_status item, :STARTED
|
165
166
|
self.processing_item = item
|
166
|
-
|
167
|
-
item =
|
167
|
+
process item
|
168
|
+
item = processing_item
|
168
169
|
run_subitems(item) if parameter(:recursive)
|
169
|
-
set_status item, :DONE if item.check_status(:STARTED,
|
170
|
+
set_status item, :DONE if item.check_status(:STARTED, namepath)
|
170
171
|
end
|
171
172
|
|
172
173
|
post_process item
|
@@ -187,18 +188,40 @@ module Libis
|
|
187
188
|
return unless check_processing_subitems
|
188
189
|
|
189
190
|
items = subitems(parent_item)
|
190
|
-
return
|
191
|
+
return if items.empty?
|
191
192
|
|
192
193
|
status_count = Hash.new(0)
|
193
|
-
parent_item.status_progress(
|
194
|
+
parent_item.status_progress(namepath, 0, items.count)
|
194
195
|
items.each_with_index do |item, i|
|
195
|
-
debug 'Processing subitem (%d/%d): %s', parent_item, i+1, items.size, item.to_s
|
196
|
-
new_item =
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
196
|
+
debug 'Processing subitem (%d/%d): %s', parent_item, i + 1, items.size, item.to_s
|
197
|
+
new_item = item
|
198
|
+
|
199
|
+
begin
|
200
|
+
new_item = run_item(item)
|
201
|
+
|
202
|
+
rescue Libis::WorkflowError => e
|
203
|
+
item.set_status(namepath, :FAILED)
|
204
|
+
break if parameter(:abort_recursion_on_failure)
|
205
|
+
|
206
|
+
rescue Libis::WorkflowAbort => e
|
207
|
+
item.set_status(namepath, :FAILED)
|
208
|
+
break
|
209
|
+
|
210
|
+
rescue => e
|
211
|
+
item.set_status(namepath, :FAILED)
|
212
|
+
raise Libis::WorkflowAbort, e.message
|
213
|
+
|
214
|
+
else
|
215
|
+
item = new_item if new_item.is_a?(Libis::Workflow::WorkItem)
|
216
|
+
parent_item.status_progress(namepath, i + 1)
|
217
|
+
|
218
|
+
ensure
|
219
|
+
item_status = item.status(namepath)
|
220
|
+
status_count[item_status] += 1
|
221
|
+
break if parameter(:abort_recursion_on_failure) && item_status != :DONE
|
222
|
+
|
223
|
+
end
|
224
|
+
|
202
225
|
end
|
203
226
|
|
204
227
|
debug '%d of %d subitems passed', parent_item, status_count[:DONE], items.size
|
@@ -239,11 +262,11 @@ module Libis
|
|
239
262
|
end
|
240
263
|
|
241
264
|
def action=(action)
|
242
|
-
|
265
|
+
get_run.action = action
|
243
266
|
end
|
244
267
|
|
245
268
|
def action
|
246
|
-
|
269
|
+
get_run.action
|
247
270
|
end
|
248
271
|
|
249
272
|
def get_run(item = nil)
|
@@ -251,7 +274,7 @@ module Libis
|
|
251
274
|
end
|
252
275
|
|
253
276
|
def get_root_item(item = nil)
|
254
|
-
(item ||
|
277
|
+
(item || workitem).get_root
|
255
278
|
end
|
256
279
|
|
257
280
|
def get_work_dir(item = nil)
|
@@ -275,30 +298,30 @@ module Libis
|
|
275
298
|
end
|
276
299
|
|
277
300
|
def set_status(item, state)
|
278
|
-
item.set_status
|
301
|
+
item.set_status namepath, state
|
279
302
|
state
|
280
303
|
end
|
281
304
|
|
282
305
|
def check_item_type(klass, item = nil)
|
283
|
-
item ||=
|
306
|
+
item ||= workitem
|
284
307
|
unless item.is_a? klass.to_s.constantize
|
285
|
-
raise WorkflowError, "Workitem is of wrong type : #{item.class} - expected #{klass
|
308
|
+
raise WorkflowError, "Workitem is of wrong type : #{item.class} - expected #{klass}"
|
286
309
|
end
|
287
310
|
end
|
288
311
|
|
289
312
|
def item_type?(klass, item = nil)
|
290
|
-
item ||=
|
313
|
+
item ||= workitem
|
291
314
|
item.is_a? klass.to_s.constantize
|
292
315
|
end
|
293
316
|
|
294
317
|
private
|
295
318
|
|
296
319
|
def subtasks
|
297
|
-
|
320
|
+
tasks
|
298
321
|
end
|
299
322
|
|
300
323
|
def subitems(item = nil)
|
301
|
-
(item ||
|
324
|
+
(item || workitem).get_item_list
|
302
325
|
end
|
303
326
|
|
304
327
|
def default_values
|
@@ -306,9 +329,8 @@ module Libis
|
|
306
329
|
end
|
307
330
|
|
308
331
|
def self.default_values
|
309
|
-
parameter_defs.
|
332
|
+
parameter_defs.each_with_object({}) do |parameter, hash|
|
310
333
|
hash[parameter.first] = parameter.last[:default]
|
311
|
-
hash
|
312
334
|
end
|
313
335
|
end
|
314
336
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
|
-
VERSION = '2.0.
|
3
|
+
VERSION = '2.0.33' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
4
4
|
end
|
5
5
|
end
|
data/libis-workflow.gemspec
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
|
6
4
|
require 'libis/workflow/version'
|
5
|
+
require 'date'
|
7
6
|
|
8
7
|
Gem::Specification.new do |spec|
|
9
8
|
spec.name = 'libis-workflow'
|
10
9
|
spec.version = ::Libis::Workflow::VERSION
|
11
10
|
spec.date = Date.today.to_s
|
12
11
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
12
|
+
spec.summary = 'LIBIS Workflow framework.'
|
13
|
+
spec.description = 'A simple framework to build custom task/workflow solutions.'
|
15
14
|
|
16
15
|
spec.author = 'Kris Dekeyser'
|
17
16
|
spec.email = 'kris.dekeyser@libis.be'
|
18
17
|
spec.homepage = 'https://github.com/Kris-LIBIS/workflow'
|
19
18
|
spec.license = 'MIT'
|
20
19
|
|
21
|
-
|
20
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
21
|
+
spec.platform = Gem::Platform::JAVA
|
22
|
+
end
|
22
23
|
|
23
24
|
spec.files = `git ls-files -z`.split("\x0")
|
24
25
|
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|