libis-workflow-mongoid 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/workflow/mongoid/base.rb +2 -14
- data/lib/libis/workflow/mongoid/job.rb +3 -21
- data/lib/libis/workflow/mongoid/log_entry.rb +5 -0
- data/lib/libis/workflow/mongoid/version.rb +1 -1
- data/lib/libis/workflow/mongoid/work_item.rb +4 -16
- data/lib/libis/workflow/mongoid/workflow.rb +3 -20
- data/spec/items/test_dir_item.rb +1 -1
- data/spec/items/test_file_item.rb +3 -3
- data/spec/tasks/camelize_name.rb +1 -1
- data/spec/workflow_spec.rb +35 -35
- metadata +2 -10
- data/lib/map_with_indifferent_access/list.rb +0 -867
- data/lib/map_with_indifferent_access/map.rb +0 -833
- data/lib/map_with_indifferent_access/normalization/deep_normalizer.rb +0 -104
- data/lib/map_with_indifferent_access/normalization.rb +0 -92
- data/lib/map_with_indifferent_access/values.rb +0 -39
- data/lib/map_with_indifferent_access/version.rb +0 -3
- data/lib/map_with_indifferent_access/wraps_collection.rb +0 -152
- data/lib/map_with_indifferent_access.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a97ed4107bf80afa5dc836eda58f8476c3d863b5
|
4
|
+
data.tar.gz: 3ba0b9532f2a929e626fe6e2a8cbd4d90e5abb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9763f51354b51451354dd54849c8e4b7a44cc96f91ee6c0a7c7286e22e02f933c4653e553fb149692c375f5d518c00914e23f0b3da905bdab3537d304b62304
|
7
|
+
data.tar.gz: 9513f8c35aaf0a7c3d28b5534c18c385cee0b767fdb787871b79e6278cb45ab65231978921aaf6b5289759b69ed2f3500b227a702a64bd2d3764ae78a580f57f
|
@@ -2,7 +2,6 @@ require 'mongoid'
|
|
2
2
|
require 'mongoid/document'
|
3
3
|
require 'yaml'
|
4
4
|
require 'libis/tools/extend/hash'
|
5
|
-
require 'map_with_indifferent_access'
|
6
5
|
|
7
6
|
require_relative 'sequence'
|
8
7
|
|
@@ -34,8 +33,8 @@ module Libis
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def create_from_hash(hash, id_tags, &block)
|
37
|
-
hash = hash.
|
38
|
-
id_tags = id_tags.map(&:
|
36
|
+
hash = hash.key_symbols_to_strings(recursive: true)
|
37
|
+
id_tags = id_tags.map(&:to_s)
|
39
38
|
return nil unless id_tags.empty? || id_tags.any? { |k| hash.include?(k) }
|
40
39
|
tags = id_tags.inject({}) do |h, k|
|
41
40
|
v = hash.delete(k)
|
@@ -51,17 +50,6 @@ module Libis
|
|
51
50
|
item
|
52
51
|
end
|
53
52
|
|
54
|
-
def indifferent_hash(field_name, method_name)
|
55
|
-
define_method method_name do
|
56
|
-
MapWithIndifferentAccess::Map.new(self.read_attribute(field_name))
|
57
|
-
end
|
58
|
-
|
59
|
-
define_method "#{method_name}=" do |value|
|
60
|
-
self.write_attribute(field_name, value)
|
61
|
-
self.send(method_name)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
53
|
end
|
66
54
|
|
67
55
|
def dup
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'map_with_indifferent_access'
|
2
1
|
require 'libis/workflow/base/job'
|
3
2
|
require 'libis/workflow/mongoid/base'
|
4
3
|
|
@@ -15,7 +14,7 @@ module Libis
|
|
15
14
|
|
16
15
|
field :name, type: String
|
17
16
|
field :description, type: String
|
18
|
-
field :
|
17
|
+
field :input, type: Hash, default: -> { Hash.new }
|
19
18
|
field :run_object, type: String
|
20
19
|
field :log_to_file, type: Boolean, default: false
|
21
20
|
field :log_each_run, type: Boolean, default: false
|
@@ -31,27 +30,10 @@ module Libis
|
|
31
30
|
|
32
31
|
def self.from_hash(hash)
|
33
32
|
self.create_from_hash(hash, [:name]) do |item, cfg|
|
34
|
-
item.workflow = Libis::Workflow::Mongoid.from_hash(name: cfg.delete(
|
33
|
+
item.workflow = Libis::Workflow::Mongoid.from_hash(name: cfg.delete('workflow'))
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
# def input
|
39
|
-
# MapWithIndifferentAccess::Map.new(self.read_attribute(:_input))
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# def input=(hash)
|
43
|
-
# self.write_attribute(:_input, hash)
|
44
|
-
# self.input
|
45
|
-
# end
|
46
|
-
|
47
|
-
indifferent_hash :_input, :input
|
48
|
-
|
49
|
-
def to_hash
|
50
|
-
result = super
|
51
|
-
result[:input] = result.delete(:_input)
|
52
|
-
result
|
53
|
-
end
|
54
|
-
|
55
37
|
def logger
|
56
38
|
return ::Libis::Workflow::Mongoid::Config.logger unless self.log_to_file
|
57
39
|
logger = ::Logging::Repository[self.name]
|
@@ -76,7 +58,7 @@ module Libis
|
|
76
58
|
# noinspection RubyStringKeysInHashInspection
|
77
59
|
def execute(opts = {})
|
78
60
|
if self.log_each_run
|
79
|
-
opts[
|
61
|
+
opts['run_config'] = {
|
80
62
|
'log_to_file=' => true,
|
81
63
|
'log_level=' => self.log_level
|
82
64
|
}
|
@@ -19,6 +19,11 @@ module Libis
|
|
19
19
|
field :status, type: String
|
20
20
|
field :run_id
|
21
21
|
|
22
|
+
index({logger_type: 1, logger_id: 1, c_at: 1}, {background: true, name: 'by_logger'})
|
23
|
+
index({logger_type: 1, logger_id: 1, c_at: 1, task: 1}, {background: true, name: 'by_logger_task'})
|
24
|
+
index({logger_type: 1, logger_id: 1, c_at: 1, }, {background: true, name: 'by_logger'})
|
25
|
+
index({logger_type: 1, logger_id: 1, c_at: 1, status: 1}, {background: true, sparse: true, name: 'status_by_logger'})
|
26
|
+
|
22
27
|
belongs_to :logger, polymorphic: true
|
23
28
|
|
24
29
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Libis
|
2
2
|
module Workflow
|
3
3
|
module Mongoid
|
4
|
-
VERSION = '2.0.
|
4
|
+
VERSION = '2.0.6' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -11,12 +11,12 @@ module Libis
|
|
11
11
|
|
12
12
|
store_in collection: 'workflow_items'
|
13
13
|
|
14
|
-
field :
|
15
|
-
field :
|
16
|
-
field :
|
14
|
+
field :options, type: Hash, default: -> { Hash.new }
|
15
|
+
field :properties, type: Hash, default: -> { Hash.new }
|
16
|
+
field :summary, type: Hash, default: -> { Hash.new }
|
17
17
|
|
18
18
|
has_many :logs, as: :logger, class_name: Libis::Workflow::Mongoid::LogEntry.to_s,
|
19
|
-
dependent: :destroy, autosave: true, order: :
|
19
|
+
dependent: :destroy, autosave: true, order: :c_at.asc do
|
20
20
|
def log_history
|
21
21
|
where(:status.exists => false)
|
22
22
|
end
|
@@ -36,18 +36,6 @@ module Libis
|
|
36
36
|
document.logs.each { |log| log.destroy! }
|
37
37
|
end
|
38
38
|
|
39
|
-
indifferent_hash :_options, :options
|
40
|
-
indifferent_hash :_properties, :properties
|
41
|
-
indifferent_hash :_summary, :summary
|
42
|
-
|
43
|
-
def to_hash
|
44
|
-
result = super
|
45
|
-
result[:options] = result.delete(:_options)
|
46
|
-
result[:properties] = result.delete(:_properties)
|
47
|
-
result[:summary] = result.delete(:_summary)
|
48
|
-
result
|
49
|
-
end
|
50
|
-
|
51
39
|
def log_history
|
52
40
|
# noinspection RubyResolve
|
53
41
|
self.logs.log_history.all || []
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'map_with_indifferent_access'
|
2
1
|
require 'libis/workflow/base/workflow'
|
3
2
|
require 'libis/workflow/mongoid/base'
|
4
3
|
require 'libis/tools/config_file'
|
@@ -17,7 +16,7 @@ module Libis
|
|
17
16
|
|
18
17
|
field :name, type: String
|
19
18
|
field :description, type: String
|
20
|
-
field :
|
19
|
+
field :config, type: Hash, default: -> { Hash.new }
|
21
20
|
|
22
21
|
index({name: 1}, {unique: 1})
|
23
22
|
|
@@ -25,11 +24,7 @@ module Libis
|
|
25
24
|
|
26
25
|
def self.from_hash(hash)
|
27
26
|
self.create_from_hash(hash, [:name]) do |item, cfg|
|
28
|
-
|
29
|
-
item.write_attribute(:_config, value)
|
30
|
-
item.remove_attribute(:config)
|
31
|
-
end
|
32
|
-
item.configure(cfg.key_strings_to_symbols(recursive: true).merge(name: item.name))
|
27
|
+
item.configure(cfg.merge('name' => item.name))
|
33
28
|
cfg.clear
|
34
29
|
end
|
35
30
|
end
|
@@ -39,22 +34,10 @@ module Libis
|
|
39
34
|
config << file_or_hash
|
40
35
|
return nil if config.empty?
|
41
36
|
workflow = self.new
|
42
|
-
workflow.configure(config.to_hash.
|
37
|
+
workflow.configure(config.to_hash.key_symbols_to_strings(recursive: true))
|
43
38
|
workflow
|
44
39
|
end
|
45
40
|
|
46
|
-
indifferent_hash :_config, :config
|
47
|
-
|
48
|
-
def to_hash
|
49
|
-
result = super
|
50
|
-
result[:config] = result.delete(:_config)
|
51
|
-
result
|
52
|
-
end
|
53
|
-
|
54
|
-
def input
|
55
|
-
Libis::Tools::DeepStruct.new(super)
|
56
|
-
end
|
57
|
-
|
58
41
|
end
|
59
42
|
end
|
60
43
|
end
|
data/spec/items/test_dir_item.rb
CHANGED
@@ -15,15 +15,15 @@ class TestFileItem < TestItem
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def name
|
18
|
-
self.properties[
|
18
|
+
self.properties['name'] || super
|
19
19
|
end
|
20
20
|
|
21
21
|
def filesize
|
22
|
-
properties[
|
22
|
+
properties['size']
|
23
23
|
end
|
24
24
|
|
25
25
|
def fixity_check(checksum)
|
26
|
-
properties[
|
26
|
+
properties['checksum'] == checksum
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/spec/tasks/camelize_name.rb
CHANGED
data/spec/workflow_spec.rb
CHANGED
@@ -38,40 +38,40 @@ describe 'TestWorkflow' do
|
|
38
38
|
let(:workflow) {
|
39
39
|
wf = TestWorkflow.find_or_initialize_by(name: 'TestWorkflow')
|
40
40
|
wf.configure(
|
41
|
-
name
|
42
|
-
description
|
43
|
-
tasks
|
44
|
-
{class
|
41
|
+
'name' => 'TestWorkflow',
|
42
|
+
'description' => 'Workflow for testing',
|
43
|
+
'tasks' => [
|
44
|
+
{'class' => 'CollectFiles', 'recursive' => true},
|
45
45
|
{
|
46
|
-
name
|
47
|
-
subitems
|
48
|
-
tasks
|
49
|
-
{class
|
50
|
-
{class
|
46
|
+
'name' => 'ProcessFiles',
|
47
|
+
'subitems' => true,
|
48
|
+
'tasks' => [
|
49
|
+
{'class' => 'ChecksumTester', 'recursive' => true},
|
50
|
+
{'class' => 'CamelizeName', 'recursive' => true}
|
51
51
|
]
|
52
52
|
}
|
53
53
|
],
|
54
|
-
input
|
55
|
-
dirname
|
56
|
-
checksum_type
|
54
|
+
'input' => {
|
55
|
+
'dirname' => {'default' => '.', 'propagate_to' => 'CollectFiles#location'},
|
56
|
+
'checksum_type' => {'default' => 'SHA1', 'propagate_to' => 'ProcessFiles/ChecksumTester'}
|
57
57
|
}
|
58
58
|
)
|
59
|
-
wf.save
|
59
|
+
wf.save!
|
60
60
|
wf
|
61
61
|
}
|
62
62
|
let(:job) {
|
63
63
|
job = TestJob.find_or_initialize_by(name: 'TestJob')
|
64
64
|
job.configure(
|
65
|
-
name
|
66
|
-
description
|
67
|
-
workflow
|
68
|
-
run_object
|
69
|
-
input
|
65
|
+
'name' => 'TestJob',
|
66
|
+
'description' => 'Job for testing',
|
67
|
+
'workflow' => workflow,
|
68
|
+
'run_object' => 'TestRun',
|
69
|
+
'input' => {'dirname' => dirname, 'checksum_type' => 'SHA256'},
|
70
70
|
)
|
71
71
|
|
72
72
|
# noinspection RubyResolve
|
73
73
|
job.runs.each { |run| run.destroy! }
|
74
|
-
job.save
|
74
|
+
job.save!
|
75
75
|
job
|
76
76
|
}
|
77
77
|
|
@@ -81,9 +81,9 @@ describe 'TestWorkflow' do
|
|
81
81
|
|
82
82
|
it 'should contain three tasks' do
|
83
83
|
|
84
|
-
expect(workflow.config[
|
85
|
-
expect(workflow.config[
|
86
|
-
expect(workflow.config[
|
84
|
+
expect(workflow.config['tasks'].size).to eq 3
|
85
|
+
expect(workflow.config['tasks'].first['class']).to eq 'CollectFiles'
|
86
|
+
expect(workflow.config['tasks'].last['class']).to eq '::Libis::Workflow::Tasks::Analyzer'
|
87
87
|
|
88
88
|
end
|
89
89
|
|
@@ -162,17 +162,17 @@ STR
|
|
162
162
|
expect(wf.description).to eq 'Workflow for testing'
|
163
163
|
expect(wf.input.count).to eq 2
|
164
164
|
expect(wf.input[:dirname][:default]).to eq '.'
|
165
|
-
expect(wf.config[
|
166
|
-
expect(wf.config[
|
167
|
-
expect(wf.config[
|
168
|
-
expect(wf.config[
|
169
|
-
expect(wf.config[
|
170
|
-
expect(wf.config[
|
171
|
-
expect(wf.config[
|
172
|
-
expect(wf.config[
|
173
|
-
expect(wf.config[
|
174
|
-
expect(wf.config[
|
175
|
-
expect(wf.config[
|
165
|
+
expect(wf.config['tasks'].count).to eq 3
|
166
|
+
expect(wf.config['tasks'][0]['class']).to eq 'CollectFiles'
|
167
|
+
expect(wf.config['tasks'][0]['recursive']).to eq true
|
168
|
+
expect(wf.config['tasks'][1]['name']).to eq 'ProcessFiles'
|
169
|
+
expect(wf.config['tasks'][1]['subitems']).to eq true
|
170
|
+
expect(wf.config['tasks'][1]['tasks'].count).to eq 2
|
171
|
+
expect(wf.config['tasks'][1]['tasks'][0]['class']).to eq 'ChecksumTester'
|
172
|
+
expect(wf.config['tasks'][1]['tasks'][0]['recursive']).to eq true
|
173
|
+
expect(wf.config['tasks'][1]['tasks'][1]['class']).to eq 'CamelizeName'
|
174
|
+
expect(wf.config['tasks'][1]['tasks'][1]['recursive']).to eq true
|
175
|
+
expect(wf.config['tasks'][2]['class']).to eq '::Libis::Workflow::Tasks::Analyzer'
|
176
176
|
end
|
177
177
|
|
178
178
|
# noinspection RubyResolve
|
@@ -190,8 +190,8 @@ STR
|
|
190
190
|
item = run.items.first
|
191
191
|
expect(item.nil?).to eq false
|
192
192
|
expect(item.is_a? TestDirItem).to eq true
|
193
|
-
expect(item.properties[
|
194
|
-
expect(item.properties[
|
193
|
+
expect(item.properties['name']).to eq 'Items'
|
194
|
+
expect(item.properties['ingest_failed']).to eq false
|
195
195
|
end
|
196
196
|
|
197
197
|
it 'move item in relation' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-workflow-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
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: libis-workflow
|
@@ -122,14 +122,6 @@ files:
|
|
122
122
|
- lib/libis/workflow/mongoid/work_item.rb
|
123
123
|
- lib/libis/workflow/mongoid/worker.rb
|
124
124
|
- lib/libis/workflow/mongoid/workflow.rb
|
125
|
-
- lib/map_with_indifferent_access.rb
|
126
|
-
- lib/map_with_indifferent_access/list.rb
|
127
|
-
- lib/map_with_indifferent_access/map.rb
|
128
|
-
- lib/map_with_indifferent_access/normalization.rb
|
129
|
-
- lib/map_with_indifferent_access/normalization/deep_normalizer.rb
|
130
|
-
- lib/map_with_indifferent_access/values.rb
|
131
|
-
- lib/map_with_indifferent_access/version.rb
|
132
|
-
- lib/map_with_indifferent_access/wraps_collection.rb
|
133
125
|
- libis-workflow-mongoid.gemspec
|
134
126
|
- mongoid.yml
|
135
127
|
- spec/db_env.sh
|