libis-workflow 2.0.29 → 2.0.30
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/libis/workflow/status.rb +10 -6
- data/lib/libis/workflow/task.rb +8 -8
- data/lib/libis/workflow/task_group.rb +3 -3
- data/lib/libis/workflow/version.rb +1 -1
- data/spec/workflow_spec.rb +1 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4df3c5f29975a0cd1cf20d24ba44a943bc5bc34c
|
4
|
+
data.tar.gz: 7933d28eb59d222c33dad47ad57f09a0104ff51d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e27bd1cb5b0d2ca8b1798bc619bb0062dcba00f5e087056a3b31afcacfb97914358ab9e4bdbf23f81a0d0196d1e76e7ef3742d7200b6a0698e36f31f063e444
|
7
|
+
data.tar.gz: 393f6adcb0f7702c6f2114de0d3ede2373fad13af3f85cc56fa86bea6b76e0e7a09fcc2f73e7fb84eac56156ac2e7ceddf6c6aec0f76476ded26202f7fbe8237
|
@@ -2,11 +2,13 @@ module Libis
|
|
2
2
|
module Workflow
|
3
3
|
module Status
|
4
4
|
|
5
|
+
protected
|
6
|
+
|
5
7
|
STATUS = {
|
6
8
|
NOT_STARTED: 0,
|
7
9
|
STARTED: 1,
|
8
|
-
|
9
|
-
|
10
|
+
ASYNC_WAIT: 2,
|
11
|
+
DONE: 3,
|
10
12
|
ASYNC_HALT: 4,
|
11
13
|
FAILED: 5
|
12
14
|
}
|
@@ -14,12 +16,14 @@ module Libis
|
|
14
16
|
STATUS_TEXT = [
|
15
17
|
'not started',
|
16
18
|
'started',
|
17
|
-
'done',
|
18
19
|
'waiting for running async process',
|
20
|
+
'done',
|
19
21
|
'waiting for halted async process',
|
20
22
|
'failed'
|
21
23
|
]
|
22
24
|
|
25
|
+
public
|
26
|
+
|
23
27
|
# Changes the status of the object. The status changed is logged in the status_log with the current timestamp.
|
24
28
|
#
|
25
29
|
# @param [String] task namepath of the task
|
@@ -27,7 +31,7 @@ module Libis
|
|
27
31
|
def set_status(task, status)
|
28
32
|
task = task.namepath if task.is_a?(Libis::Workflow::Task)
|
29
33
|
log_entry = self.status_entry(task)
|
30
|
-
if log_entry.nil? || status
|
34
|
+
if log_entry.nil? || STATUS[status_symbol(log_entry['status'])] > STATUS[status_symbol(status)]
|
31
35
|
log_entry = self.add_status_log('task' => task, 'status' => status, 'created' => DateTime.now)
|
32
36
|
end
|
33
37
|
log_entry['status'] = status
|
@@ -74,7 +78,7 @@ module Libis
|
|
74
78
|
# Compare status with current status of the object.
|
75
79
|
#
|
76
80
|
# @param [Symbol] state
|
77
|
-
# @return [Integer] 1, 0 or -1
|
81
|
+
# @return [Integer] 1, 0 or -1 depending on which status is higher in rank
|
78
82
|
def compare_status(state, task = nil)
|
79
83
|
STATUS[self.status(task)] <=> STATUS[state]
|
80
84
|
end
|
@@ -83,7 +87,7 @@ module Libis
|
|
83
87
|
# @param [String] task namepath of the task
|
84
88
|
# @param [Integer] progress progress indicator (as <progress> of <max> or as % if <max> not set). Default: 0
|
85
89
|
# @param [Integer] max max count.
|
86
|
-
def status_progress(task, progress, max = nil)
|
90
|
+
def status_progress(task, progress = nil, max = nil)
|
87
91
|
log_entry = self.status_entry(task)
|
88
92
|
log_entry ||= self.add_status_log('task' => task, 'status' => :STARTED, 'created' => DateTime.now)
|
89
93
|
log_entry['progress'] = progress ? progress : (log_entry['progress'] || 0) + 1
|
data/lib/libis/workflow/task.rb
CHANGED
@@ -189,7 +189,7 @@ module Libis
|
|
189
189
|
items = subitems(parent_item)
|
190
190
|
return unless items.size > 0
|
191
191
|
|
192
|
-
|
192
|
+
status_count = Hash.new(0)
|
193
193
|
parent_item.status_progress(self.namepath, 0, items.count)
|
194
194
|
items.each_with_index do |item, i|
|
195
195
|
debug 'Processing subitem (%d/%d): %s', parent_item, i+1, items.size, item.to_s
|
@@ -197,28 +197,28 @@ module Libis
|
|
197
197
|
item = new_item if new_item.is_a?(Libis::Workflow::WorkItem)
|
198
198
|
parent_item.status_progress(self.namepath, i+1)
|
199
199
|
item_status = item.status(self.namepath)
|
200
|
-
|
200
|
+
status_count[item_status] += 1
|
201
201
|
break if parameter(:abort_recursion_on_failure) && item_status != :DONE
|
202
202
|
end
|
203
203
|
|
204
|
-
debug '%d of %d subitems passed', parent_item,
|
205
|
-
substatus_check(
|
204
|
+
debug '%d of %d subitems passed', parent_item, status_count[:DONE], items.size
|
205
|
+
substatus_check(status_count, parent_item, 'item')
|
206
206
|
end
|
207
207
|
|
208
|
-
def substatus_check(
|
208
|
+
def substatus_check(status_count, item, task_or_item)
|
209
209
|
item_status = :DONE
|
210
210
|
|
211
|
-
if (waiting =
|
211
|
+
if (waiting = status_count[:ASYNC_WAIT]) > 0
|
212
212
|
info "waiting for %d sub#{task_or_item}(s) in async process", item, waiting
|
213
213
|
item_status = :ASYNC_WAIT
|
214
214
|
end
|
215
215
|
|
216
|
-
if (halted =
|
216
|
+
if (halted = status_count[:ASYNC_HALT]) > 0
|
217
217
|
warn "%d sub#{task_or_item}(s) halted in async process", item, halted
|
218
218
|
item_status = :ASYNC_HALT
|
219
219
|
end
|
220
220
|
|
221
|
-
if (failed =
|
221
|
+
if (failed = status_count[:FAILED]) > 0
|
222
222
|
error "%d sub#{task_or_item}(s) failed", item, failed
|
223
223
|
item_status = :FAILED
|
224
224
|
end
|
@@ -37,7 +37,7 @@ module Libis
|
|
37
37
|
tasks = subtasks
|
38
38
|
return unless tasks.size > 0
|
39
39
|
|
40
|
-
|
40
|
+
status_count = Hash.new(0)
|
41
41
|
item.status_progress(self.namepath, 0, tasks.count)
|
42
42
|
tasks.each_with_index do |task, i|
|
43
43
|
info 'Running subtask (%d/%d): %s', item, i+1, tasks.size, task.name
|
@@ -45,11 +45,11 @@ module Libis
|
|
45
45
|
item = new_item if new_item.is_a?(Libis::Workflow::WorkItem)
|
46
46
|
item.status_progress(self.namepath, i+1)
|
47
47
|
item_status = item.status(task.namepath)
|
48
|
-
|
48
|
+
status_count[item_status] += 1
|
49
49
|
break if parameter(:abort_on_failure) && item_status != :DONE
|
50
50
|
end
|
51
51
|
|
52
|
-
substatus_check(
|
52
|
+
substatus_check(status_count, item, 'task')
|
53
53
|
|
54
54
|
info item.status_text(self.namepath).capitalize, item
|
55
55
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
|
-
VERSION = '2.0.
|
3
|
+
VERSION = '2.0.30' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
4
4
|
end
|
5
5
|
end
|
data/spec/workflow_spec.rb
CHANGED
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,4 +206,3 @@ test_files:
|
|
206
206
|
- spec/tasks/checksum_tester.rb
|
207
207
|
- spec/tasks/collect_files.rb
|
208
208
|
- spec/workflow_spec.rb
|
209
|
-
has_rdoc:
|