libis-workflow 2.0.6 → 2.0.7
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/base/file_item.rb +15 -15
- data/lib/libis/workflow/base/job.rb +8 -9
- data/lib/libis/workflow/base/logging.rb +1 -1
- data/lib/libis/workflow/base/run.rb +1 -1
- data/lib/libis/workflow/base/work_item.rb +1 -1
- data/lib/libis/workflow/base/workflow.rb +16 -14
- data/lib/libis/workflow/status.rb +1 -1
- data/lib/libis/workflow/task.rb +10 -7
- data/lib/libis/workflow/tasks/analyzer.rb +2 -2
- data/lib/libis/workflow/version.rb +1 -1
- data/lib/libis/workflow/worker.rb +2 -1
- data/spec/workflow_spec.rb +19 -19
- 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: 9327567da6093380f849f0deacb992873af61e60
|
4
|
+
data.tar.gz: 5478d89b9e65716195e371dd0dcb667b89445161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ffe0fcc00964f7ec170d4b8595d220c0f9027735f22c8b76d6fa000c96ea4681854abb91452f13c274b6161b6deeaa9b9c59dfdc4efd0e9d72994b2778de25
|
7
|
+
data.tar.gz: 26accfb461c22d93319bf955eed26ff3dbbd60fe2de62b4debd32f5e73bfd04d7ced849b55412a6d9db89ea73af02bf05fd556f4990c127fad1d9d7c04c8d216
|
@@ -11,11 +11,11 @@ module Libis
|
|
11
11
|
include Libis::Workflow::Base::WorkItem
|
12
12
|
|
13
13
|
def filename
|
14
|
-
File.basename(self.properties[
|
14
|
+
File.basename(self.properties['filename']) || self.properties['link']
|
15
15
|
end
|
16
16
|
|
17
17
|
def name
|
18
|
-
self.properties[
|
18
|
+
self.properties['name'] || self.filename
|
19
19
|
end
|
20
20
|
|
21
21
|
def filelist
|
@@ -27,40 +27,40 @@ module Libis
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def fullpath
|
30
|
-
self.properties[
|
30
|
+
self.properties['filename']
|
31
31
|
end
|
32
32
|
|
33
33
|
def filename=(name)
|
34
34
|
begin
|
35
35
|
stats = ::File.stat name
|
36
|
-
self.properties[
|
37
|
-
self.properties[
|
38
|
-
self.properties[
|
39
|
-
self.properties[
|
40
|
-
self.properties[
|
41
|
-
self.properties[
|
42
|
-
self.properties[
|
36
|
+
self.properties['size'] = stats.size
|
37
|
+
self.properties['access_time'] = stats.atime
|
38
|
+
self.properties['modification_time'] = stats.mtime
|
39
|
+
self.properties['creation_time'] = stats.ctime
|
40
|
+
self.properties['mode'] = stats.mode
|
41
|
+
self.properties['uid'] = stats.uid
|
42
|
+
self.properties['gid'] = stats.gid
|
43
43
|
set_checksum(:MD5, ::Digest::MD5.hexdigest(File.read(name))) if File.file?(name)
|
44
44
|
rescue
|
45
45
|
# ignored
|
46
46
|
end
|
47
|
-
self.properties[
|
47
|
+
self.properties['filename'] = name
|
48
48
|
end
|
49
49
|
|
50
50
|
def checksum(checksum_type)
|
51
|
-
self.properties[('checksum_' + checksum_type.to_s.downcase)
|
51
|
+
self.properties[('checksum_' + checksum_type.to_s.downcase)]
|
52
52
|
end
|
53
53
|
|
54
54
|
def set_checksum(checksum_type, value)
|
55
|
-
self.properties[('checksum_' + checksum_type.to_s.downcase)
|
55
|
+
self.properties[('checksum_' + checksum_type.to_s.downcase)] = value
|
56
56
|
end
|
57
57
|
|
58
58
|
def link
|
59
|
-
self.properties[
|
59
|
+
self.properties['link']
|
60
60
|
end
|
61
61
|
|
62
62
|
def link=(name)
|
63
|
-
self.properties[
|
63
|
+
self.properties['link'] = name
|
64
64
|
end
|
65
65
|
|
66
66
|
def set_info(info)
|
@@ -47,11 +47,11 @@ module Libis
|
|
47
47
|
self.name ||= ''
|
48
48
|
self.description ||= ''
|
49
49
|
self.input ||= {}
|
50
|
-
self.name = cfg[
|
51
|
-
self.description = cfg[
|
52
|
-
self.workflow = cfg[
|
53
|
-
self.run_object = cfg[
|
54
|
-
self.input.merge!(cfg[
|
50
|
+
self.name = cfg['name'] if cfg.has_key?('name')
|
51
|
+
self.description = cfg['description'] if cfg.has_key?('description')
|
52
|
+
self.workflow = cfg['workflow'] if cfg.has_key?('workflow')
|
53
|
+
self.run_object = cfg['run_object'] if cfg.has_key?('run_object')
|
54
|
+
self.input.merge!(cfg['input'] || {})
|
55
55
|
end
|
56
56
|
|
57
57
|
# noinspection RubyResolve
|
@@ -61,10 +61,9 @@ module Libis
|
|
61
61
|
raise RuntimeError.new "Could not create instance of run object '#{self.run_object}'" unless run
|
62
62
|
|
63
63
|
run.job = self
|
64
|
-
opts.
|
65
|
-
|
66
|
-
run.
|
67
|
-
run.save
|
64
|
+
(opts.delete('run_config') || {}).each { |key,value| run.send(key, value) }
|
65
|
+
run.options = self.input.merge(opts)
|
66
|
+
run.save!
|
68
67
|
|
69
68
|
run.run
|
70
69
|
|
@@ -76,28 +76,29 @@ module Libis
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def configure(cfg)
|
79
|
-
self.name = cfg.delete(
|
80
|
-
self.description = cfg.delete(
|
81
|
-
self.config
|
79
|
+
self.name = cfg.delete('name') || self.class.name
|
80
|
+
self.description = cfg.delete('description') || ''
|
81
|
+
self.config['input'] = {}
|
82
|
+
self.config['tasks'] = []
|
82
83
|
self.config.merge! cfg
|
83
84
|
|
84
85
|
self.class.require_all
|
85
86
|
|
86
|
-
unless !self.config[
|
87
|
-
self.config[
|
88
|
-
self.config[
|
89
|
-
self.config[
|
87
|
+
unless !self.config['tasks'].empty? &&
|
88
|
+
self.config['tasks'].last['class'] &&
|
89
|
+
self.config['tasks'].last['class'].split('::').last == 'Analyzer'
|
90
|
+
self.config['tasks'] << {'class' => '::Libis::Workflow::Tasks::Analyzer'}
|
90
91
|
end
|
91
92
|
|
92
93
|
self.config
|
93
94
|
end
|
94
95
|
|
95
96
|
def input
|
96
|
-
self.config[:input].inject({}) do |hash, input_def|
|
97
|
-
name = input_def.first
|
97
|
+
self.config.key_strings_to_symbols(recursive: true)[:input].inject({}) do |hash, input_def|
|
98
|
+
name = input_def.first
|
98
99
|
default = input_def.last[:default]
|
99
100
|
parameter = ::Libis::Tools::Parameter.new name, default
|
100
|
-
input_def.last.each { |k, v| parameter[k
|
101
|
+
input_def.last.each { |k, v| parameter[k] = v }
|
101
102
|
hash[name] = parameter
|
102
103
|
hash
|
103
104
|
end
|
@@ -107,6 +108,7 @@ module Libis
|
|
107
108
|
|
108
109
|
# @param [Hash] options
|
109
110
|
def prepare_input(options)
|
111
|
+
options = options.key_strings_to_symbols
|
110
112
|
result = {}
|
111
113
|
self.input.each do |key, parameter|
|
112
114
|
if options.has_key?(key)
|
@@ -122,7 +124,7 @@ module Libis
|
|
122
124
|
result[key] = value if propagate_to.empty?
|
123
125
|
propagate_to.each do |target|
|
124
126
|
task_name, param_name = target.split('#')
|
125
|
-
param_name ||= key
|
127
|
+
param_name ||= key.to_s
|
126
128
|
result[task_name] ||= {}
|
127
129
|
result[task_name][param_name] = value
|
128
130
|
end
|
@@ -131,17 +133,17 @@ module Libis
|
|
131
133
|
end
|
132
134
|
|
133
135
|
def tasks(parent = nil)
|
134
|
-
self.config[
|
136
|
+
self.config['tasks'].map do |cfg|
|
135
137
|
instantize_task(parent || nil, cfg)
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
139
141
|
def instantize_task(parent, cfg)
|
140
142
|
task_class = Libis::Workflow::TaskGroup
|
141
|
-
task_class = cfg[
|
143
|
+
task_class = cfg['class'].constantize if cfg['class']
|
142
144
|
# noinspection RubyArgCount
|
143
145
|
task_instance = task_class.new(parent, cfg)
|
144
|
-
cfg[
|
146
|
+
cfg['tasks'] && cfg['tasks'].map do |task_cfg|
|
145
147
|
task_instance << instantize_task(task_instance, task_cfg)
|
146
148
|
end
|
147
149
|
task_instance
|
data/lib/libis/workflow/task.rb
CHANGED
@@ -17,7 +17,7 @@ module Libis
|
|
17
17
|
|
18
18
|
attr_accessor :parent, :name, :workitem
|
19
19
|
|
20
|
-
parameter quiet: false, description: '
|
20
|
+
parameter quiet: false, description: 'Prevent generating log output.'
|
21
21
|
parameter recursive: false, description: 'Run the task on all subitems recursively.'
|
22
22
|
parameter retry_count: 0, description: 'Number of times to retry the task if waiting for another process.'
|
23
23
|
parameter retry_interval: 10, description: 'Number of seconds to wait between retries.'
|
@@ -44,7 +44,10 @@ module Libis
|
|
44
44
|
|
45
45
|
case self.action
|
46
46
|
when :retry
|
47
|
-
|
47
|
+
if item.check_status(:DONE, self.namepath)
|
48
|
+
debug 'Retry: skipping task %s because it has finished successfully.', item, self.namepath
|
49
|
+
return
|
50
|
+
end
|
48
51
|
when :failed
|
49
52
|
return
|
50
53
|
else
|
@@ -90,7 +93,7 @@ module Libis
|
|
90
93
|
debug e.backtrace.join("\n")
|
91
94
|
|
92
95
|
ensure
|
93
|
-
item.save
|
96
|
+
item.save!
|
94
97
|
|
95
98
|
end
|
96
99
|
|
@@ -106,7 +109,6 @@ module Libis
|
|
106
109
|
o = {}
|
107
110
|
o.merge!(opts[self.class.to_s] || {})
|
108
111
|
o.merge!(opts[self.name] || opts[self.names.join('/')] || {})
|
109
|
-
o.key_symbols_to_strings!
|
110
112
|
|
111
113
|
if o and o.is_a? Hash
|
112
114
|
default_values.each do |name, _|
|
@@ -144,12 +146,13 @@ module Libis
|
|
144
146
|
def logger
|
145
147
|
(self.parent || self.get_run).logger
|
146
148
|
end
|
149
|
+
|
147
150
|
protected
|
148
151
|
|
149
152
|
def configure(cfg)
|
150
|
-
self.name = cfg[
|
151
|
-
(cfg[
|
152
|
-
cfg.reject { |k, _|
|
153
|
+
self.name = cfg['name'] || (cfg['class'] || self.class).to_s.split('::').last
|
154
|
+
(cfg['options'] || {}).merge(
|
155
|
+
cfg.reject { |k, _| %w(options name class).include? k }
|
153
156
|
).symbolize_keys.each do |k, v|
|
154
157
|
self.parameter(k, v)
|
155
158
|
end
|
@@ -12,7 +12,7 @@ module Libis
|
|
12
12
|
# @param [Libis::Workflow::Base::WorkItem] item
|
13
13
|
def run(item)
|
14
14
|
|
15
|
-
item.properties[
|
15
|
+
item.properties['ingest_failed'] = item.check_status(:FAILED)
|
16
16
|
|
17
17
|
item.summary = {}
|
18
18
|
item.log_history.each do |log|
|
@@ -36,7 +36,7 @@ module Libis
|
|
36
36
|
|
37
37
|
ensure
|
38
38
|
|
39
|
-
item.save
|
39
|
+
item.save!
|
40
40
|
|
41
41
|
end
|
42
42
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
|
-
VERSION = '2.0.
|
3
|
+
VERSION = '2.0.7' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
4
4
|
end
|
5
5
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sidekiq'
|
2
2
|
|
3
|
+
require 'libis/tools/extend/hash'
|
3
4
|
require 'libis/workflow/config'
|
4
5
|
require 'libis/workflow/workflow'
|
5
6
|
|
@@ -31,7 +32,7 @@ module Libis
|
|
31
32
|
|
32
33
|
def get_job(job_config)
|
33
34
|
job = ::Libis::Workflow::Job.new
|
34
|
-
job.configure job_config
|
35
|
+
job.configure job_config.key_symbols_to_strings(recursive: true)
|
35
36
|
job
|
36
37
|
end
|
37
38
|
|
data/spec/workflow_spec.rb
CHANGED
@@ -24,21 +24,21 @@ describe 'TestWorkflow' do
|
|
24
24
|
let(:workflow) {
|
25
25
|
workflow = ::Libis::Workflow::Workflow.new
|
26
26
|
workflow.configure(
|
27
|
-
name
|
28
|
-
description
|
29
|
-
tasks
|
30
|
-
{class
|
27
|
+
'name' => 'TestWorkflow',
|
28
|
+
'description' => 'Workflow for testing',
|
29
|
+
'tasks' => [
|
30
|
+
{'class' => 'CollectFiles', 'recursive' => true},
|
31
31
|
{
|
32
|
-
name
|
33
|
-
tasks
|
34
|
-
{class
|
35
|
-
{class
|
32
|
+
'name' => 'ProcessFiles', 'recursive' => false,
|
33
|
+
'tasks' => [
|
34
|
+
{'class' => 'ChecksumTester', 'recursive' => true},
|
35
|
+
{'class' => 'CamelizeName', 'recursive' => true}
|
36
36
|
]
|
37
37
|
}
|
38
38
|
],
|
39
|
-
input
|
40
|
-
dirname
|
41
|
-
checksum_type
|
39
|
+
'input' => {
|
40
|
+
'dirname' => {'default' => '.', 'propagate_to' => 'CollectFiles#location'},
|
41
|
+
'checksum_type' => {'default' => 'SHA1', 'propagate_to' => 'ChecksumTester'}
|
42
42
|
}
|
43
43
|
)
|
44
44
|
workflow
|
@@ -47,19 +47,19 @@ describe 'TestWorkflow' do
|
|
47
47
|
let(:job) {
|
48
48
|
job = ::Libis::Workflow::Job.new
|
49
49
|
job.configure(
|
50
|
-
name
|
51
|
-
description
|
52
|
-
workflow
|
53
|
-
run_object
|
54
|
-
input
|
50
|
+
'name' => 'TestJob',
|
51
|
+
'description' => 'Job for testing',
|
52
|
+
'workflow' => workflow,
|
53
|
+
'run_object' => 'TestRun',
|
54
|
+
'input' => {'dirname' => dirname, 'checksum_type' => 'SHA256'},
|
55
55
|
)
|
56
56
|
job
|
57
57
|
}
|
58
58
|
|
59
59
|
it 'should contain three tasks' do
|
60
|
-
expect(workflow.config[
|
61
|
-
expect(workflow.config[
|
62
|
-
expect(workflow.config[
|
60
|
+
expect(workflow.config['tasks'].size).to eq 3
|
61
|
+
expect(workflow.config['tasks'].first['class']).to eq 'CollectFiles'
|
62
|
+
expect(workflow.config['tasks'].last['class']).to eq '::Libis::Workflow::Tasks::Analyzer'
|
63
63
|
end
|
64
64
|
|
65
65
|
# noinspection RubyResolve
|
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.7
|
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-03-
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|