libis-workflow 2.0.33 → 2.0.34

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8ed3adeee0f666862bdedd0f695722d67619385
4
- data.tar.gz: 8935af86aff161a31acb46e0a195b7a15b33d7de
3
+ metadata.gz: bb823bd0608daf4a967030f006907ea878a2f76b
4
+ data.tar.gz: ce590a7b9e6ad276081218e2c49af9742df33a11
5
5
  SHA512:
6
- metadata.gz: 707f1e5286e629a04b7d5b1b0623bf5d23d175d2b278c5d1a42d0b3502e529db433407f12b328f2b64860140a6f1b2ef88da245e1f03ca0b8213f2b80258cb4f
7
- data.tar.gz: d81c44bfe8b845ffc6f46a54ef19b9458482aef798945b3daa034b56b0365ff1947e723f824175e9b1a0eba2600285a8ad8d1228676a481a7a7c4c0b80b44195
6
+ metadata.gz: c999e3ff98da80b45e4709d789a4f1e15f54d39906ff025f8016b52c3573dd08eab94f2769fd36f655b0f60a7adfb3dd2a9e2fc5634fd8c02ae9a7bbfd1e52f2
7
+ data.tar.gz: 2a08d0d8d62e5c26bbb07540174ffd3d6ddefa3fd90d2c034ab47c6a68d3ede00c3c3a64e56ad9c526038ef0b54fd2b7b2e81258143dd18c5698418445e4ff00
@@ -39,6 +39,7 @@ module Libis
39
39
  # @param [Hash] message
40
40
  def add_log(message = {})
41
41
  msg = message_struct(message)
42
+ # noinspection RubyResolve
42
43
  add_log_entry(msg)
43
44
  self.save!
44
45
  end
@@ -53,6 +53,8 @@ module Libis
53
53
  # self.status_log << info
54
54
  # end
55
55
  #
56
+ # The implementation should also take care that the public methods #save and #save! are implemented.
57
+ # ActiveRecord and Mongoid are known to implement these, but others may not.
56
58
  #
57
59
  module WorkItem
58
60
  include Enumerable
@@ -133,7 +135,9 @@ module Libis
133
135
  return self unless item and item.is_a?(Libis::Workflow::Base::WorkItem)
134
136
  self.items << item
135
137
  item.parent = self
138
+ # noinspection RubyResolve
136
139
  self.save!
140
+ # noinspection RubyResolve
137
141
  item.save!
138
142
  self
139
143
  end
@@ -172,19 +176,7 @@ module Libis
172
176
  # @return [Libis::Workflow::Base::Run]
173
177
  def get_run
174
178
  return self if self.is_a?(Libis::Workflow::Base::Run)
175
- self.get_parent && self.get_parent.get_run || nil
176
- end
177
-
178
- # Dummy method. It is a placeholder for DB backed implementations. Wherever appropriate WorkItem#save will be
179
- # called to save the current item's state. If state needs to persisted, you should override this method or make
180
- # sure your persistence layer implements it in your class.
181
- def save
182
- end
183
-
184
- # Dummy method. It is a placeholder for DB backed implementations. Wherever appropriate WorkItem#save will be
185
- # called to save the current item's state. If state needs to persisted, you should override this method or make
186
- # sure your persistence layer implements it in your class.
187
- def save!
179
+ self.get_parent&.get_run
188
180
  end
189
181
 
190
182
  end
@@ -105,6 +105,7 @@ module Libis
105
105
  options = options.key_strings_to_symbols
106
106
  result = {}
107
107
  self.input.each do |key, parameter|
108
+ value = nil
108
109
  if options.has_key?(key)
109
110
  value = parameter.parse(options[key])
110
111
  elsif !parameter[:default].nil?
@@ -23,7 +23,9 @@ 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 {|klass| klass < self}
26
+ # noinspection RubyArgCount
27
+ ObjectSpace.each_object(::Class)
28
+ .select {|klass| klass < self && klass != Libis::Workflow::TaskRunner}
27
29
  end
28
30
 
29
31
  def initialize(parent, cfg = {})
@@ -43,15 +45,15 @@ module Libis
43
45
  self.workitem = item
44
46
 
45
47
  case action
46
- when :retry
47
- if item.check_status(:DONE, namepath)
48
- debug 'Retry: skipping task %s because it has finished successfully.', item, namepath
49
- return item
50
- end
51
- when :failed
48
+ when :retry
49
+ if item.check_status(:DONE, namepath)
50
+ debug 'Retry: skipping task %s because it has finished successfully.', item, namepath
52
51
  return item
53
- else
54
- # type code here
52
+ end
53
+ when :failed
54
+ return item
55
+ else
56
+ # type code here
55
57
  end
56
58
 
57
59
  (parameter(:retry_count) + 1).times do
@@ -59,18 +61,19 @@ module Libis
59
61
  i = run_item(item)
60
62
  item = i if i.is_a?(Libis::Workflow::WorkItem)
61
63
 
64
+ # noinspection RubyScope
62
65
  case item.status(namepath)
63
- when :DONE
64
- self.action = :run
65
- return item
66
- when :ASYNC_WAIT
67
- self.action = :retry
68
- when :ASYNC_HALT
69
- break
70
- when :FAILED
71
- break
72
- else
73
- return item
66
+ when :DONE
67
+ self.action = :run
68
+ return item
69
+ when :ASYNC_WAIT
70
+ self.action = :retry
71
+ when :ASYNC_HALT
72
+ break
73
+ when :FAILED
74
+ break
75
+ else
76
+ return item
74
77
  end
75
78
 
76
79
  self.action = :retry
@@ -201,9 +204,11 @@ module Libis
201
204
 
202
205
  rescue Libis::WorkflowError => e
203
206
  item.set_status(namepath, :FAILED)
207
+ error 'Error processing subitem (%d/%d): %s', item, i + 1, items.size, e.message
204
208
  break if parameter(:abort_recursion_on_failure)
205
209
 
206
210
  rescue Libis::WorkflowAbort => e
211
+ fatal_error 'Fatal error processing subitem (%d/%d): %s', item, i + 1, items.size, e.message
207
212
  item.set_status(namepath, :FAILED)
208
213
  break
209
214
 
@@ -216,7 +221,9 @@ module Libis
216
221
  parent_item.status_progress(namepath, i + 1)
217
222
 
218
223
  ensure
224
+ # noinspection RubyScope
219
225
  item_status = item.status(namepath)
226
+ # noinspection RubyScope
220
227
  status_count[item_status] += 1
221
228
  break if parameter(:abort_recursion_on_failure) && item_status != :DONE
222
229
 
@@ -224,6 +231,7 @@ module Libis
224
231
 
225
232
  end
226
233
 
234
+ # noinspection RubyScope
227
235
  debug '%d of %d subitems passed', parent_item, status_count[:DONE], items.size
228
236
  substatus_check(status_count, parent_item, 'item')
229
237
  end
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Workflow
3
- VERSION = '2.0.33' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
3
+ VERSION = '2.0.34' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
4
4
  end
5
5
  end
@@ -23,6 +23,12 @@ module Libis
23
23
  self.summary = {}
24
24
  end
25
25
 
26
+ def save
27
+ end
28
+
29
+ def save!
30
+ end
31
+
26
32
  protected
27
33
 
28
34
  def add_status_log(info)
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.33
4
+ version: 2.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-30 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler