scout-gear 10.7.3 → 10.7.5
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/.gitmodules +0 -4
- data/.vimproject +3 -14
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/bin/scout +15 -2
- data/lib/scout/association/index.rb +1 -1
- data/lib/scout/association.rb +5 -2
- data/lib/scout/entity/identifiers.rb +5 -2
- data/lib/scout/entity/property.rb +2 -3
- data/lib/scout/knowledge_base/entity.rb +12 -3
- data/lib/scout/knowledge_base/registry.rb +3 -1
- data/lib/scout/persist/engine/tokyocabinet.rb +85 -77
- data/lib/scout/persist/tsv/adapter/base.rb +8 -22
- data/lib/scout/tsv/change_id/translate.rb +8 -2
- data/lib/scout/tsv/open.rb +2 -0
- data/lib/scout/tsv/parser.rb +10 -0
- data/lib/scout/tsv/transformer.rb +12 -0
- data/lib/scout/tsv/util/process.rb +2 -2
- data/lib/scout/workflow/definition.rb +6 -2
- data/lib/scout/workflow/deployment/trace.rb +1 -1
- data/lib/scout/workflow/entity.rb +99 -0
- data/lib/scout/workflow/export.rb +66 -0
- data/lib/scout/workflow/step/dependencies.rb +3 -6
- data/lib/scout/workflow/step/file.rb +3 -3
- data/lib/scout/workflow/step/info.rb +12 -2
- data/lib/scout/workflow/step/provenance.rb +1 -2
- data/lib/scout/workflow/step/status.rb +1 -0
- data/lib/scout/workflow/step.rb +5 -3
- data/lib/scout/workflow/task/info.rb +99 -0
- data/lib/scout/workflow/task/inputs.rb +2 -1
- data/lib/scout/workflow/task.rb +1 -0
- data/lib/scout/workflow.rb +4 -2
- data/lib/scout-gear.rb +5 -1
- data/scout-gear.gemspec +10 -19
- data/scout_commands/doc +3 -3
- data/scout_commands/workflow/task +7 -2
- data/test/scout/knowledge_base/test_list.rb +4 -4
- data/test/scout/knowledge_base/test_registry.rb +19 -0
- data/test/scout/persist/test_tsv.rb +1 -0
- data/test/scout/test_association.rb +15 -0
- data/test/scout/test_tsv.rb +15 -0
- data/test/scout/tsv/test_parser.rb +4 -0
- data/test/scout/tsv/test_transformer.rb +13 -0
- data/test/scout/workflow/step/test_info.rb +11 -0
- data/test/scout/workflow/task/test_dependencies.rb +7 -7
- data/test/scout/workflow/task/test_info.rb +22 -0
- data/test/scout/workflow/test_definition.rb +2 -2
- data/test/scout/workflow/test_entity.rb +58 -0
- data/test/scout/workflow/test_step.rb +1 -1
- metadata +10 -61
- data/lib/scout/offsite/exceptions.rb +0 -9
- data/lib/scout/offsite/ssh.rb +0 -175
- data/lib/scout/offsite/step.rb +0 -100
- data/lib/scout/offsite/sync.rb +0 -55
- data/lib/scout/offsite.rb +0 -3
- data/scout_commands/offsite +0 -30
- data/test/scout/offsite/test_ssh.rb +0 -15
- data/test/scout/offsite/test_step.rb +0 -32
- data/test/scout/offsite/test_sync.rb +0 -36
- data/test/scout/offsite/test_task.rb +0 -0
- data/test/scout/test_offsite.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60a8c5a91d83e96aaa721154fa4f7fdd63d2699c691b8c99962c6ba5561365eb
|
4
|
+
data.tar.gz: 4b2303f3db25c1316286e8c6edbd8d76be66ba8b851626393f0c0b5ea34aac1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb9761f9cc9acab8842372de6bbe9f69413bc9d6b2c1b05ebae6c51e40ca292fbce9edce27d1c5d26a7e298273e700881bdd39f8bac3441b1e9af604c443eb0
|
7
|
+
data.tar.gz: cb46e73a548bca55f41e088167eff7494691a6fdd61ed17f7a06f6a1a0257679441b7d62a56e67a376943e4e0a96acd39d3a4ee5888550c1721c5d79e4f7e6a4
|
data/.gitmodules
CHANGED
data/.vimproject
CHANGED
@@ -8,6 +8,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
8
8
|
workflow.rb
|
9
9
|
workflow=workflow{
|
10
10
|
exceptions.rb
|
11
|
+
export.rb
|
11
12
|
definition.rb
|
12
13
|
documentation.rb
|
13
14
|
usage.rb
|
@@ -31,12 +32,14 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
31
32
|
task=task{
|
32
33
|
dependencies.rb
|
33
34
|
inputs.rb
|
35
|
+
info.rb
|
34
36
|
}
|
35
37
|
deployment.rb
|
36
38
|
deployment=deployment{
|
37
39
|
trace.rb
|
38
40
|
orchestrator.rb
|
39
41
|
}
|
42
|
+
entity.rb
|
40
43
|
}
|
41
44
|
work_queue.rb
|
42
45
|
work_queue=work_queue{
|
@@ -121,12 +124,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
121
124
|
enrichment.rb
|
122
125
|
list.rb
|
123
126
|
}
|
124
|
-
offsite.rb
|
125
|
-
offsite=offsite{
|
126
|
-
ssh.rb
|
127
|
-
sync.rb
|
128
|
-
step.rb
|
129
|
-
}
|
130
127
|
semaphore.rb
|
131
128
|
}
|
132
129
|
scout-gear.rb
|
@@ -143,7 +140,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
143
140
|
doc
|
144
141
|
update
|
145
142
|
template
|
146
|
-
offsite
|
147
143
|
kb=kb{
|
148
144
|
config
|
149
145
|
entities
|
@@ -185,7 +181,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
185
181
|
scout=scout{
|
186
182
|
test_association.rb
|
187
183
|
test_entity.rb
|
188
|
-
test_offsite.rb
|
189
184
|
test_semaphore.rb
|
190
185
|
test_tsv.rb
|
191
186
|
test_workflow.rb
|
@@ -247,12 +242,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
247
242
|
test_tokyocabinet.rb
|
248
243
|
}
|
249
244
|
}
|
250
|
-
offsite=offsite{
|
251
|
-
test_ssh.rb
|
252
|
-
test_step.rb
|
253
|
-
test_sync.rb
|
254
|
-
test_task.rb
|
255
|
-
}
|
256
245
|
}
|
257
246
|
}
|
258
247
|
share=share{
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ Juwelier::Tasks.new do |gem|
|
|
12
12
|
gem.homepage = "http://github.com/mikisvaz/scout-gear"
|
13
13
|
gem.license = "MIT"
|
14
14
|
gem.summary = %Q{basic gear for scouts}
|
15
|
-
gem.description = %Q{
|
15
|
+
gem.description = %Q{Scout gear: workflow, TSVs, persistence, entities, associations, and knowledge_bases.}
|
16
16
|
gem.email = "mikisvaz@gmail.com"
|
17
17
|
gem.authors = ["Miguel Vazquez"]
|
18
18
|
|
@@ -26,10 +26,7 @@ Juwelier::Tasks.new do |gem|
|
|
26
26
|
gem.add_runtime_dependency 'RubyInline'
|
27
27
|
#gem.add_runtime_dependency 'tokyocabinet'
|
28
28
|
|
29
|
-
gem.add_development_dependency "rdoc", "~> 3.12"
|
30
|
-
gem.add_development_dependency "bundler", "~> 1.0"
|
31
29
|
gem.add_development_dependency "juwelier", "~> 2.1.0"
|
32
|
-
gem.add_development_dependency "simplecov", ">= 0"
|
33
30
|
end
|
34
31
|
Juwelier::RubygemsDotOrgTasks.new
|
35
32
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
10.7.
|
1
|
+
10.7.5
|
data/bin/scout
CHANGED
@@ -52,6 +52,16 @@ if dev_dir
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
requires = nil
|
56
|
+
if _i = ARGV.index("--require")
|
57
|
+
requires = ARGV[_i+1].split(",")
|
58
|
+
ARGV.delete_at _i + 1
|
59
|
+
ARGV.delete_at _i
|
60
|
+
requires.each do |p|
|
61
|
+
require p
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
require 'scout-gear'
|
56
66
|
|
57
67
|
require 'scout/simple_opt'
|
@@ -97,8 +107,11 @@ if config_keys = options.delete(:config_keys)
|
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
100
|
-
|
101
|
-
|
110
|
+
#$scout_command_dir = Scout.bin.scout
|
111
|
+
#$scout_command_dir.path_maps[:scout_commands] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/scout_commands}")
|
112
|
+
|
113
|
+
$scout_command_dir = Scout.scout_commands
|
114
|
+
#$scout_command_dir.path_maps[:scout_commands] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/scout_commands}")
|
102
115
|
|
103
116
|
SOPT.description =<<EOF
|
104
117
|
This command controls many aspects of the Scout framework, from configuration tasks to running applications.
|
@@ -141,7 +141,7 @@ module Association
|
|
141
141
|
new.extend Index
|
142
142
|
new
|
143
143
|
else
|
144
|
-
|
144
|
+
Open.mkdir File.dirname(reverse_filename) unless Open.exist?(File.dirname(reverse_filename))
|
145
145
|
|
146
146
|
new = Persist.open_tokyocabinet(reverse_filename, true, serializer, TokyoCabinet::BDB)
|
147
147
|
|
data/lib/scout/association.rb
CHANGED
@@ -11,7 +11,9 @@ module Association
|
|
11
11
|
target = kwargs.delete :target if kwargs.include?(:target)
|
12
12
|
|
13
13
|
if Path.is_filename?(obj)
|
14
|
-
|
14
|
+
tsv_header_options = TSV.parse_options(obj)
|
15
|
+
tsv_header_options = tsv_header_options.slice(TSV.acceptable_parser_options)
|
16
|
+
options = tsv_header_options.merge(kwargs)
|
15
17
|
else
|
16
18
|
options = kwargs.dup
|
17
19
|
end
|
@@ -116,11 +118,12 @@ module Association
|
|
116
118
|
persist_options = IndiferentHash.pull_keys kwargs, :persist
|
117
119
|
|
118
120
|
database_persist_options = IndiferentHash.add_defaults persist_options.dup, persist: true,
|
119
|
-
prefix: "Association::Index", serializer: :
|
121
|
+
prefix: "Association::Index", serializer: :double,
|
120
122
|
other_options: kwargs
|
121
123
|
|
122
124
|
Persist.tsv(file, kwargs, engine: "BDB", persist_options: database_persist_options) do |data|
|
123
125
|
tsv = open(file, *args, **kwargs)
|
126
|
+
data.serializer = TSVAdapter.serializer_module(tsv.type) if data.respond_to?(:serializer)
|
124
127
|
if TSV::Transformer === tsv
|
125
128
|
tsv.tsv(merge: true, data: data)
|
126
129
|
elsif data.respond_to?(:persistence_path)
|
@@ -64,13 +64,16 @@ module Entity
|
|
64
64
|
Persist.memory("Entity index #{identity_type}: #{format} (from #{source || "All"})", :persist => true, :format => format, :source => source) do
|
65
65
|
source ||= self.respond_to?(:format)? self.format : nil
|
66
66
|
|
67
|
+
saved_exception = nil
|
67
68
|
begin
|
68
69
|
index = TSV.translation_index(identifier_files, source, format, :persist => true)
|
69
70
|
raise "No index from #{ Misc.fingerprint source } to #{ Misc.fingerprint format }: #{Misc.fingerprint identifier_files}" if index.nil?
|
70
71
|
index.unnamed = true
|
71
72
|
index
|
72
73
|
rescue
|
73
|
-
raise $! if source.nil?
|
74
|
+
raise saved_exception || $! if source.nil?
|
75
|
+
Log.debug "Retrying identifier index without specifying source"
|
76
|
+
saved_exception = $!
|
74
77
|
source = nil
|
75
78
|
retry
|
76
79
|
end
|
@@ -93,7 +96,7 @@ module Entity
|
|
93
96
|
|
94
97
|
name = default if name.nil?
|
95
98
|
|
96
|
-
self.send(:include, Entity::Identified) unless Entity::Identified
|
99
|
+
self.send(:include, Entity::Identified) unless self.include?(Entity::Identified)
|
97
100
|
|
98
101
|
self.format = all_fields
|
99
102
|
@formats ||= []
|
@@ -62,7 +62,6 @@ module Entity
|
|
62
62
|
|
63
63
|
properties.push name
|
64
64
|
|
65
|
-
|
66
65
|
entity_class = self
|
67
66
|
if type == :multiple
|
68
67
|
self.define_method(real_method) do |*args,**kwargs|
|
@@ -89,7 +88,7 @@ module Entity
|
|
89
88
|
|
90
89
|
new_responses = missing.instance_exec(*args, **kwargs, &block)
|
91
90
|
|
92
|
-
missing.each do |item
|
91
|
+
missing.each do |item|
|
93
92
|
responses[item] = Entity::Property.persist(name, item, type, options) do
|
94
93
|
Array === new_responses ? new_responses[item.container_index] : new_responses[item]
|
95
94
|
end
|
@@ -149,7 +148,7 @@ module Entity
|
|
149
148
|
|
150
149
|
def persist(name, type = :marshal, options = {})
|
151
150
|
options = IndiferentHash.add_defaults options, persist: true,
|
152
|
-
dir:
|
151
|
+
dir: Entity.entity_property_cache[self.to_s][name.to_s]
|
153
152
|
@persisted_methods ||= {}
|
154
153
|
@persisted_methods[name] = [type, options]
|
155
154
|
end
|
@@ -63,7 +63,7 @@ class KnowledgeBase
|
|
63
63
|
entities.collect{|entity| Entity.formats[entity] }.uniq
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def database_identifier_files(name)
|
67
67
|
get_database(name).identifier_files.dup + self.identifier_files
|
68
68
|
end
|
69
69
|
|
@@ -73,7 +73,11 @@ class KnowledgeBase
|
|
73
73
|
|
74
74
|
def source_index(name)
|
75
75
|
Persist.memory("Source index #{name}: KB directory #{dir}") do
|
76
|
-
identifier_files
|
76
|
+
if @identifier_files && @identifier_files.any?
|
77
|
+
identifier_files = @identifier_files
|
78
|
+
else
|
79
|
+
identifier_files = database_identifier_files(name)
|
80
|
+
end
|
77
81
|
identifier_files.concat Entity.identifier_files(source(name)) if defined? Entity
|
78
82
|
identifier_files.uniq!
|
79
83
|
identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
|
@@ -97,7 +101,12 @@ class KnowledgeBase
|
|
97
101
|
|
98
102
|
def identify_source(name, entity)
|
99
103
|
return :all if entity == :all
|
100
|
-
index = begin
|
104
|
+
index = begin
|
105
|
+
source_index(name)
|
106
|
+
rescue
|
107
|
+
Log.exception $!
|
108
|
+
nil
|
109
|
+
end
|
101
110
|
return entity if index.nil?
|
102
111
|
if Array === entity
|
103
112
|
entity.collect{|e| index[e] || e }
|
@@ -43,9 +43,11 @@ class KnowledgeBase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def undirected(name)
|
46
|
-
description(name)
|
46
|
+
description(name).length == 3
|
47
47
|
end
|
48
48
|
|
49
|
+
alias undirected? undirected
|
50
|
+
|
49
51
|
def get_index(name, options = {})
|
50
52
|
name = name.to_s
|
51
53
|
options[:namespace] ||= self.namespace unless self.namespace.nil?
|
@@ -1,105 +1,112 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if String === tokyocabinet_class && tokyocabinet_class.include?(":big")
|
9
|
-
big = true
|
10
|
-
tokyocabinet_class = tokyocabinet_class.split(":").first
|
11
|
-
else
|
12
|
-
big = false
|
13
|
-
end
|
1
|
+
begin
|
2
|
+
require 'tokyocabinet'
|
3
|
+
continue = true
|
4
|
+
rescue Exception
|
5
|
+
Log.warn "The Tokyocabinet gem could not be loaded: TSV persistence may not work"
|
6
|
+
continue = false
|
7
|
+
end
|
14
8
|
|
15
|
-
|
16
|
-
|
9
|
+
if continue
|
10
|
+
module ScoutCabinet
|
11
|
+
attr_accessor :persistence_path, :persistence_class
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def self.open(path, write = true, tokyocabinet_class = TokyoCabinet::HDB)
|
14
|
+
path = path.find if Path === path
|
15
|
+
if String === tokyocabinet_class && tokyocabinet_class.include?(":big")
|
16
|
+
big = true
|
17
|
+
tokyocabinet_class = tokyocabinet_class.split(":").first
|
18
|
+
else
|
19
|
+
big = false
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
database = Log.ignore_stderr do Persist::CONNECTIONS[path] ||= tokyocabinet_class.new end
|
22
|
+
dir = File.dirname(File.expand_path(path))
|
23
|
+
Open.mkdir(dir) unless File.exist?(dir)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
tokyocabinet_class = tokyocabinet_class.to_s if Symbol === tokyocabinet_class
|
26
|
+
tokyocabinet_class = TokyoCabinet::HDB if tokyocabinet_class == "HDB" or tokyocabinet_class.nil?
|
27
|
+
tokyocabinet_class = TokyoCabinet::BDB if tokyocabinet_class == "BDB"
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
# Hack - Ignore warning: undefining the allocator of T_DATA class
|
30
|
+
# TokyoCabinet::HDB_data
|
31
|
+
database = Log.ignore_stderr do Persist::CONNECTIONS[path] ||= tokyocabinet_class.new end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
33
|
+
if big and not Open.exists?(path)
|
34
|
+
database.tune(nil, nil, nil, tokyocabinet_class::TLARGE | tokyocabinet_class::TDEFLATE)
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
database.persistence_class = tokyocabinet_class
|
37
|
+
flags = (write ? tokyocabinet_class::OWRITER | tokyocabinet_class::OCREAT : tokyocabinet_class::OREADER)
|
38
|
+
database.close
|
41
39
|
|
42
|
-
|
40
|
+
if !database.open(path, flags)
|
41
|
+
ecode = database.ecode
|
42
|
+
raise "Open error: #{database.errmsg(ecode)}. Trying to open file #{path}"
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
+
database.extend ScoutCabinet
|
46
|
+
database.persistence_path ||= path
|
47
|
+
database.persistence_class = tokyocabinet_class
|
45
48
|
|
46
|
-
|
49
|
+
database.open(path, tokyocabinet_class::OREADER)
|
47
50
|
|
48
|
-
|
49
|
-
end
|
51
|
+
database.define_singleton_method(:fingerprint){ "#{self.persistence_class}:#{self.persistence_path}" }
|
50
52
|
|
51
|
-
|
52
|
-
@closed = true
|
53
|
-
@writable = false
|
54
|
-
super
|
55
|
-
end
|
53
|
+
Persist::CONNECTIONS[path] = database
|
56
54
|
|
57
|
-
|
58
|
-
return if ! @writable && ! @closed && ! force
|
59
|
-
self.close
|
60
|
-
if !self.open(@persistence_path, persistence_class::OREADER)
|
61
|
-
ecode = self.ecode
|
62
|
-
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
55
|
+
database
|
63
56
|
end
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
def close
|
59
|
+
@closed = true
|
60
|
+
@writable = false
|
61
|
+
super
|
62
|
+
end
|
70
63
|
|
71
|
-
|
72
|
-
|
73
|
-
|
64
|
+
def read(force = false)
|
65
|
+
return if ! @writable && ! @closed && ! force
|
66
|
+
self.close
|
67
|
+
if !self.open(@persistence_path, persistence_class::OREADER)
|
68
|
+
ecode = self.ecode
|
69
|
+
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
70
|
+
end
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
72
|
+
@writable = false
|
73
|
+
@closed = false
|
78
74
|
|
75
|
+
self
|
76
|
+
end
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
def write?
|
79
|
+
@writable
|
80
|
+
end
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
82
|
+
def closed?
|
83
|
+
@closed
|
87
84
|
end
|
88
85
|
|
89
|
-
@writable = true
|
90
|
-
@closed = false
|
91
86
|
|
92
|
-
|
93
|
-
|
87
|
+
def write(force = true)
|
88
|
+
return if write? && ! closed? && ! force
|
89
|
+
self.close
|
94
90
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
if !self.open(@persistence_path, persistence_class::OWRITER)
|
92
|
+
ecode = self.ecode
|
93
|
+
raise "Open error: #{self.errmsg(ecode)}. Trying to open file #{@persistence_path}"
|
94
|
+
end
|
95
|
+
|
96
|
+
@writable = true
|
97
|
+
@closed = false
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
def write_and_read
|
103
|
+
begin
|
104
|
+
write
|
105
|
+
yield
|
106
|
+
ensure
|
107
|
+
read
|
108
|
+
end
|
101
109
|
end
|
102
|
-
end
|
103
110
|
|
104
111
|
def write_and_close
|
105
112
|
begin
|
@@ -139,4 +146,5 @@ module ScoutCabinet
|
|
139
146
|
end
|
140
147
|
|
141
148
|
alias load_stream importtsv
|
149
|
+
end
|
142
150
|
end
|
@@ -23,6 +23,7 @@ module TSVAdapter
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def save_annotation_hash
|
26
|
+
self.close
|
26
27
|
self.with_write do
|
27
28
|
self.orig_set(ANNOTATION_ATTR_HASH_KEY, ANNOTATION_ATTR_HASH_SERIALIZER.dump(self.annotation_hash))
|
28
29
|
end
|
@@ -165,15 +166,6 @@ module TSVAdapter
|
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
168
|
-
def with_write(*args, &block)
|
169
|
-
if @write
|
170
|
-
yield
|
171
|
-
elsif @closed
|
172
|
-
write_and_close &block
|
173
|
-
else
|
174
|
-
write_and_read &block
|
175
|
-
end
|
176
|
-
end
|
177
169
|
|
178
170
|
def close(*args)
|
179
171
|
begin
|
@@ -250,12 +242,11 @@ module TSVAdapter
|
|
250
242
|
|
251
243
|
lock do
|
252
244
|
write(true) if closed? || ! write?
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
res
|
245
|
+
begin
|
246
|
+
yield
|
247
|
+
ensure
|
248
|
+
close
|
249
|
+
end
|
259
250
|
end
|
260
251
|
end
|
261
252
|
|
@@ -272,18 +263,13 @@ module TSVAdapter
|
|
272
263
|
return yield
|
273
264
|
else
|
274
265
|
if self.read?
|
275
|
-
self.write_and_read
|
276
|
-
return yield
|
277
|
-
end
|
266
|
+
self.write_and_read(&block)
|
278
267
|
else
|
279
|
-
self.write_and_close
|
280
|
-
return yield
|
281
|
-
end
|
268
|
+
self.write_and_close(&block)
|
282
269
|
end
|
283
270
|
end
|
284
271
|
end
|
285
272
|
|
286
|
-
|
287
273
|
def read_and_close
|
288
274
|
if read? || write?
|
289
275
|
begin
|
@@ -40,7 +40,7 @@ module TSV
|
|
40
40
|
target_file = target_files.select{|file| fields = file_fields[file]; (fields & middle_fields).any? }.collect{|file,f| file }.first
|
41
41
|
[source_file, middle_file, target_file]
|
42
42
|
else
|
43
|
-
raise "Could not traverse identifier path from #{Log.fingerprint source} to #{Log.fingerprint target}
|
43
|
+
raise "Could not traverse identifier path from #{Log.fingerprint source} to #{Log.fingerprint target}. #{file_fields.empty? ? "No identifier files" : Log.fingerprint(file_fields)}"
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -55,7 +55,13 @@ module TSV
|
|
55
55
|
files = [files] unless Array === files
|
56
56
|
|
57
57
|
files.each do |file|
|
58
|
-
next if Path === file && ! Open.exist?(file)
|
58
|
+
#next if Path === file && ! Open.exist?(file)
|
59
|
+
begin
|
60
|
+
file = file.produce if Path === file
|
61
|
+
rescue
|
62
|
+
Log.warn $!.message
|
63
|
+
next
|
64
|
+
end
|
59
65
|
file = file.find if Path === file
|
60
66
|
file_fields[file] = all_fields(file)
|
61
67
|
end
|
data/lib/scout/tsv/open.rb
CHANGED
@@ -151,6 +151,8 @@ module Open
|
|
151
151
|
res = block.call(line)
|
152
152
|
callback.call res if callback
|
153
153
|
end
|
154
|
+
obj.close
|
155
|
+
obj.join if obj.respond_to? :join
|
154
156
|
else
|
155
157
|
Log.low "Traverse stream with parser #{Log.fingerprint obj}"
|
156
158
|
parser = options[:sep].nil? ? TSV::Parser.new(obj) : TSV::Parser.new(obj, sep: options[:sep])
|
data/lib/scout/tsv/parser.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require 'scout/named_array'
|
2
2
|
module TSV
|
3
|
+
def self.acceptable_parser_options(func = nil)
|
4
|
+
if func.nil?
|
5
|
+
TSV.method(:parse_line).parameters.collect{|a| a.last } +
|
6
|
+
TSV.method(:parse_stream).parameters.collect{|a| a.last } +
|
7
|
+
TSV.method(:parse).parameters.collect{|a| a.last } - [:line, :block]
|
8
|
+
else
|
9
|
+
TSV.method(func).parameters.collect{|a| a.last }
|
10
|
+
end.uniq
|
11
|
+
end
|
12
|
+
|
3
13
|
def self.cast_value(value, cast)
|
4
14
|
if Array === value
|
5
15
|
value.collect{|e| cast_value(e, cast) }
|
@@ -175,5 +175,17 @@ module TSV
|
|
175
175
|
end
|
176
176
|
res
|
177
177
|
end
|
178
|
+
|
179
|
+
def head(max=10)
|
180
|
+
res = self.annotate({})
|
181
|
+
transformer = Transformer.new self, res
|
182
|
+
i = 0
|
183
|
+
transformer.traverse do |k,v|
|
184
|
+
i += 1
|
185
|
+
break if i > max
|
186
|
+
[k, v]
|
187
|
+
end
|
188
|
+
res
|
189
|
+
end
|
178
190
|
end
|
179
191
|
|
@@ -30,9 +30,9 @@ module TSV
|
|
30
30
|
when type == :flat
|
31
31
|
self[key] = new_values
|
32
32
|
else
|
33
|
-
if ! values[field_pos].frozen? && ((String === values[field_pos] && String === new_values) ||
|
33
|
+
if ! values[field_pos].frozen? && ! NamedArray === values && ((String === values[field_pos] && String === new_values) ||
|
34
34
|
(Array === values[field_pos] && Array === new_values))
|
35
|
-
|
35
|
+
values[field_pos].replace new_values
|
36
36
|
else
|
37
37
|
values[field_pos] = new_values
|
38
38
|
end
|
@@ -13,8 +13,12 @@ module Workflow
|
|
13
13
|
|
14
14
|
end
|
15
15
|
|
16
|
+
def to_s
|
17
|
+
@name || super
|
18
|
+
end
|
19
|
+
|
16
20
|
def name
|
17
|
-
@name
|
21
|
+
@name || to_s
|
18
22
|
end
|
19
23
|
|
20
24
|
def helpers
|
@@ -192,7 +196,7 @@ module Workflow
|
|
192
196
|
when 'true'
|
193
197
|
dep.clean
|
194
198
|
when 'recursive'
|
195
|
-
(dep.dependencies + dep.rec_dependencies).uniq.each do |d|
|
199
|
+
(dep.dependencies.to_a + dep.rec_dependencies.to_a).uniq.each do |d|
|
196
200
|
next if d.overriden
|
197
201
|
d.clean unless Scout::Config.get(:remove_dep, "task:#{d.task_signature}", "task:#{d.task_name}", "workflow:#{d.workflow.name}", :default => true).to_s == 'false'
|
198
202
|
end
|
@@ -164,7 +164,7 @@ module Workflow
|
|
164
164
|
def self.trace(seed_jobs, options = {})
|
165
165
|
jobs = []
|
166
166
|
seed_jobs.each do |step|
|
167
|
-
jobs += step.rec_dependencies + [step]
|
167
|
+
jobs += step.rec_dependencies.to_a + [step]
|
168
168
|
step.info[:archived_info].each do |path,ainfo|
|
169
169
|
next unless Hash === ainfo
|
170
170
|
archived_step = Step.new path
|