scout-gear 10.1.0 → 10.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab089af23ec3cb6d23db1190f712d2a981db96e818572aa5b561227a9601b9b8
4
- data.tar.gz: d72662def6d6b7207d015d7cea613a1882578efe201ed391f79d37027ab7c70e
3
+ metadata.gz: 3e807e8eea8b8ff3b40be002fcd9cdfa9fbc8d3fdb447f20b1b3c56f1c318de8
4
+ data.tar.gz: 8838111c9867b63671060c82b7224f2ac310b64d375f0cc62c26b42092da6f1d
5
5
  SHA512:
6
- metadata.gz: d5b67fdc030ad2ed3dd4d9da47d7f12068b71f14a1ae390f65c411bc2e835ac2da1648fccb554cbda4a3a56bdf6b16fc63080620453e75481590622cfd883247
7
- data.tar.gz: 97fa38ef8db895d3a8aa05d2e4e521bb98d28924b389429994f6e98bceb7bfa7ad74920676c17b8b124bf288700e80078909ea20a84c3c0b24efd0cf7b0632cb
6
+ metadata.gz: 2dcc68c9d612b208d6b6b94dd366ef37f2467b364d1da8367b1f6833d305d6ef8c35a1dc0f0e27c6e00ce481344e230e20ac6eb85236dd27c75c59e8ad3f0ec5
7
+ data.tar.gz: 85d8e7458a1453966e2e123fc8ced3a0c2bc8be884a7570f1bb57f4d260db582e90380d2ea0f8a91c91b68decb8439e8b556d294b9d71258c522fa06628ec22b
data/.vimproject CHANGED
@@ -8,6 +8,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
8
8
  alias
9
9
  find
10
10
  glob
11
+ log
11
12
  doc
12
13
  update
13
14
  template
@@ -16,7 +17,14 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
16
17
  task
17
18
  list
18
19
  info
20
+ write_info
19
21
  install
22
+ trace
23
+ prov
24
+ }
25
+ batch=batch{
26
+ list
27
+ clean
20
28
  }
21
29
  resource=resource{
22
30
  produce
@@ -72,6 +80,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
72
80
  unzip.rb
73
81
  reorder.rb
74
82
  sort.rb
83
+ melt.rb
75
84
  }
76
85
  parser.rb
77
86
  dumper.rb
@@ -122,6 +131,10 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
122
131
  test_tsv.rb
123
132
  test_work_queue.rb
124
133
  test_workflow.rb
134
+ work_queue=work_queue{
135
+ test_socket.rb
136
+ test_worker.rb
137
+ }
125
138
  workflow=workflow{
126
139
  test_definition.rb
127
140
  test_documentation.rb
@@ -140,10 +153,42 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
140
153
  test_dependencies.rb
141
154
  test_inputs.rb
142
155
  }
156
+ deployment=deployment{
157
+ test_orchestrator.rb
158
+ }
143
159
  }
144
- indiferent_hash=indiferent_hash{
145
- test_case_insensitive.rb
146
- test_options.rb
160
+ tsv=tsv{
161
+ test_attach.rb
162
+ test_change_id.rb
163
+ test_dumper.rb
164
+ test_index.rb
165
+ test_open.rb
166
+ test_parser.rb
167
+ test_persist.rb
168
+ test_stream.rb
169
+ test_transformer.rb
170
+ test_traverse.rb
171
+ test_util.rb
172
+ util=util{
173
+ test_filter.rb
174
+ test_melt.rb
175
+ test_process.rb
176
+ test_reorder.rb
177
+ test_select.rb
178
+ test_sort.rb
179
+ test_unzip.rb
180
+ }
181
+ persist=persist{
182
+ test_adapter.rb
183
+ test_fix_width_table.rb
184
+ test_tokyocabinet.rb
185
+ }
186
+ }
187
+ offsite=offsite{
188
+ test_ssh.rb
189
+ test_step.rb
190
+ test_sync.rb
191
+ test_task.rb
147
192
  }
148
193
  }
149
194
  }
@@ -524,6 +569,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
524
569
  test_filter.rb
525
570
  test_index.rb
526
571
  test_manipulate.rb
572
+ test_marshal.rb
527
573
  test_matrix.rb
528
574
  test_parallel.rb
529
575
  test_parser.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.1.0
1
+ 10.2.0
@@ -2,15 +2,16 @@ module TSV
2
2
  class Transformer
3
3
  attr_accessor :unnamed, :parser, :dumper
4
4
 
5
- def initialize(parser, dumper = nil, unnamed: false)
5
+ def initialize(parser, dumper = nil, unnamed: nil)
6
6
  if TSV::Parser === parser
7
7
  @parser = parser
8
8
  elsif TSV === parser
9
9
  @parser = parser
10
+ @unnamed = parser.unnamed
10
11
  else
11
12
  @parser = TSV::Parser.new parser
12
13
  end
13
- @unnamed = unnamed
14
+ @unnamed = unnamed unless unnamed.nil?
14
15
  if dumper.nil?
15
16
  @dumper = TSV::Dumper.new(@parser)
16
17
  @dumper.sep = "\t"
@@ -70,7 +71,7 @@ module TSV
70
71
  @dumper.init if @dumper.respond_to?(:init) && ! @dumper.initialized
71
72
  Log.debug "Transform #{Log.fingerprint @parser} into #{Log.fingerprint @dumper}"
72
73
  Open.traverse(@parser, *args, **kwargs) do |k,v|
73
- NamedArray.setup(v, @parser.fields, k) unless @unnamed
74
+ NamedArray.setup(v, @parser.fields, k) unless @unnamed || @parser.fields.nil?
74
75
  block.call k, v
75
76
  end
76
77
  end
@@ -112,16 +113,18 @@ module TSV
112
113
 
113
114
  def to_list
114
115
  res = self.annotate({})
115
- transformer = Transformer.new self, res
116
- transformer.type = :list
117
- transformer.traverse do |k,v|
118
- case self.type
119
- when :single
120
- [k, [v]]
121
- when :double
122
- [k, v.collect{|v| v.first }]
123
- when :flat
124
- [k, v.slice(0,1)]
116
+ self.with_unnamed do
117
+ transformer = Transformer.new self, res
118
+ transformer.type = :list
119
+ transformer.traverse do |k,v|
120
+ case self.type
121
+ when :single
122
+ [k, [v]]
123
+ when :double
124
+ [k, v.collect{|v| v.first }]
125
+ when :flat
126
+ [k, v.slice(0,1)]
127
+ end
125
128
  end
126
129
  end
127
130
  res
@@ -131,6 +134,7 @@ module TSV
131
134
  res = self.annotate({})
132
135
  transformer = Transformer.new self, res
133
136
  transformer.type = :single
137
+ transformer.unnamed = true
134
138
  transformer.traverse do |k,v|
135
139
  v = v.first while Array === v
136
140
  [k, v]
@@ -0,0 +1,13 @@
1
+ module TSV
2
+ def melt_columns(value_field, column_field)
3
+ target = TSV.setup({}, :key_field => "ID", :fields => [key_field, value_field, column_field], :type => :list, :cast => cast)
4
+ each do |k,values|
5
+ i = 0
6
+ values.zip(fields).each do |v,f|
7
+ target["#{k}:#{i}"] = [k,v,f]
8
+ i+=1
9
+ end
10
+ end
11
+ target
12
+ end
13
+ end
@@ -7,6 +7,7 @@ require_relative 'util/select'
7
7
  require_relative 'util/reorder'
8
8
  require_relative 'util/unzip'
9
9
  require_relative 'util/sort'
10
+ require_relative 'util/melt'
10
11
  module TSV
11
12
  def self.identify_field(key_field, fields, name, strict: nil)
12
13
  return :key if name == :key || (! strict && NamedArray.field_match(key_field, name))
data/lib/scout/tsv.rb CHANGED
@@ -34,11 +34,14 @@ module TSV
34
34
  end
35
35
 
36
36
  def self.open(file, options = {})
37
- persist, type, grep, invert_grep = IndiferentHash.process_options options, :persist, :persist_type, :grep, :invert_grep, :persist => false, :persist_type => "HDB"
38
- type = type.to_sym if type
37
+ grep, invert_grep = IndiferentHash.process_options options, :grep, :invert_grep, :persist => false
38
+
39
+ persist_options = IndiferentHash.pull_keys options, :persist
40
+ persist_options = IndiferentHash.add_defaults persist_options, :prefix => "TSV", :type => "HDB"
41
+
39
42
  file = StringIO.new file if String === file && ! (Path === file) && file.index("\n")
40
- Persist.persist(file, type, options.merge(:persist => persist, :prefix => "Tsv", :other_options => options)) do |filename|
41
- data = filename ? ScoutCabinet.open(filename, true, type) : nil
43
+ Persist.persist(file, persist_options[:type], persist_options.merge(:other_options => options)) do |filename|
44
+ data = filename ? ScoutCabinet.open(filename, true, persist_options[:type]) : nil
42
45
  options[:data] = data if data
43
46
  options[:filename] = file
44
47
 
@@ -84,8 +84,10 @@ module Workflow
84
84
  annotate_next_task :deps, [workflow, task, options, block, args]
85
85
  end
86
86
 
87
- def input(*args)
88
- annotate_next_task(:inputs, args)
87
+ def input(name, type = nil, *rest)
88
+ name = name.to_sym
89
+ type = type.to_sym if type
90
+ annotate_next_task(:inputs, [name, type] + rest)
89
91
  end
90
92
 
91
93
  def desc(description)
@@ -102,6 +104,8 @@ module Workflow
102
104
 
103
105
  def task(name_and_type, &block)
104
106
  name, type = name_and_type.collect.first
107
+ type = type.to_sym if String === type
108
+ name = name.to_sym if String === name
105
109
  @tasks ||= IndiferentHash.setup({})
106
110
  block = self.method(name) if block.nil?
107
111
  begin
@@ -132,8 +136,10 @@ module Workflow
132
136
  def task_alias(name, workflow, oname, *rest, &block)
133
137
  dep(workflow, oname, *rest, &block)
134
138
  extension :dep_task unless @extension
135
- returns workflow.tasks[oname].returns if @returns.nil?
136
- type = workflow.tasks[oname].type
139
+ task_proc = workflow.tasks[oname]
140
+ raise "Task #{name} not found" if task_proc.nil?
141
+ returns task_proc.returns if @returns.nil?
142
+ type = task_proc.type
137
143
  task name => type do
138
144
  raise RbbtException, "dep_task does not have any dependencies" if dependencies.empty?
139
145
  Step.wait_for_jobs dependencies.select{|d| d.streaming? }
@@ -5,7 +5,7 @@ class Step
5
5
  next if seen.include? dep.path
6
6
  next if connected && dep.done? && dep.updated?
7
7
  direct_deps << dep
8
- end
8
+ end if dependencies
9
9
  seen.concat direct_deps.collect{|d| d.path }
10
10
  direct_deps.inject(direct_deps){|acc,d| acc.concat(d.rec_dependencies(connected, seen)); acc }
11
11
  end
@@ -12,9 +12,10 @@ class Step
12
12
  end
13
13
  end
14
14
 
15
- def file(file)
15
+ def file(file = nil)
16
16
  dir = files_dir
17
17
  Path.setup(dir) unless Path === dir
18
+ return dir if file.nil?
18
19
  dir[file]
19
20
  end
20
21
 
@@ -68,7 +68,7 @@ class Step
68
68
  $inputs.each do |input|
69
69
  value = job_inputs[input]
70
70
  next if value.nil?
71
- value_str = Misc.fingerprint(value)
71
+ value_str = Log.fingerprint(value)
72
72
  str << "\t#{Log.color :magenta, input}=#{value_str}"
73
73
  end
74
74
  end
@@ -78,7 +78,7 @@ class Step
78
78
  IndiferentHash.setup(info)
79
79
  value = info[field]
80
80
  next if value.nil?
81
- value_str = Misc.fingerprint(value)
81
+ value_str = Log.fingerprint(value)
82
82
  str << "\t#{Log.color :magenta, field}=#{value_str}"
83
83
  end
84
84
  end
@@ -27,10 +27,10 @@ class Step
27
27
  @result = nil
28
28
  @info = nil
29
29
  @info_load_time = nil
30
- Open.rm path if Open.exist?(path)
31
- Open.rm tmp_path if Open.exist?(tmp_path)
32
- Open.rm info_file if Open.exist?(info_file)
33
- Open.rm_rf files_dir if Open.exist?(files_dir)
30
+ Open.rm path if Open.exist_or_link?(path)
31
+ Open.rm tmp_path if Open.exist_or_link?(tmp_path)
32
+ Open.rm info_file if Open.exist_or_link?(info_file)
33
+ Open.rm_rf files_dir if Open.exist_or_link?(files_dir)
34
34
  self
35
35
  end
36
36
 
@@ -76,10 +76,14 @@ class Step
76
76
 
77
77
  def task_name
78
78
  @task_name ||= @task.name if @task.respond_to?(:name)
79
+ @task_name ||= info[:task_name] if Open.exist?(info_file)
80
+ @task_name ||= path.split("/")[-2]
79
81
  end
80
82
 
81
83
  def workflow
82
- @task.workflow if @task
84
+ @workflow ||= @task.workflow if Task === @task
85
+ @workflow ||= info[:workflow] if Open.exist?(info_file)
86
+ @workflow ||= path.split("/")[-3]
83
87
  end
84
88
 
85
89
  def exec
@@ -130,6 +134,7 @@ class Step
130
134
  input_names = (task.respond_to?(:inputs) && task.inputs) ? task.inputs.collect{|name,_| name} : []
131
135
  merge_info :status => :start, :start => Time.now,
132
136
  :pid => Process.pid, :pid_hostname => Misc.hostname,
137
+ :task_name => task_name, :workflow => workflow.to_s,
133
138
  :inputs => MetaExtension.purge(inputs), :input_names => input_names, :type => type,
134
139
  :dependencies => dependencies.collect{|d| d.path }
135
140
 
@@ -232,11 +237,14 @@ class Step
232
237
  while @result && streaming? && stream = self.stream
233
238
  threads << Open.consume_stream(stream, true)
234
239
  end
240
+
241
+ threads.compact!
242
+
235
243
  threads.each do |t|
236
244
  begin
237
245
  t.join
238
246
  rescue Exception
239
- threads.each{|t| t.raise(Aborted); t.join }
247
+ threads.compact.each{|t| t.raise(Aborted); t.join }
240
248
  raise $!
241
249
  end
242
250
  end
@@ -252,6 +260,7 @@ class Step
252
260
  while ! present?
253
261
  sleep 0.1
254
262
  end
263
+ self
255
264
  end
256
265
 
257
266
  def terminated?
@@ -85,8 +85,12 @@ module Task
85
85
  input_file = File.join(directory, name.to_s)
86
86
 
87
87
  if Path.is_filename?(value)
88
- relative_file = save_file_input(value, directory)
89
- Open.write(input_file + ".as_file", relative_file)
88
+ if type == :path
89
+ Open.write(input_file + ".as_path", value)
90
+ else
91
+ relative_file = save_file_input(value, directory)
92
+ Open.write(input_file + ".as_file", relative_file)
93
+ end
90
94
  elsif Step === value
91
95
  Open.write(input_file + ".as_step", value.short_path)
92
96
  elsif type == :file
@@ -52,8 +52,9 @@ module Task
52
52
  inputs = task.inputs.reject{|name, _| seen.include? name }
53
53
  inputs = task.inputs.reject{|name, _| options.include? name }
54
54
  next unless inputs.any?
55
- task.inputs.select{|name, _| inputs.include? name }.each do |name,_,_,_,options|
56
- selects << [i, options[:select_options]] if options[:select_options]
55
+ input_names = inputs.collect{|name,_| name }
56
+ task.inputs.select{|name,_| input_names.include? name }.each do |name,_,_,_,options|
57
+ selects << [name, options[:select_options]] if options && options[:select_options]
57
58
  end
58
59
 
59
60
  dep = workflow.nil? || dep_workflow.name != workflow.name ? ["#{dep_workflow.name}", task_name.to_s] *"#" : task_name.to_s
@@ -291,6 +292,7 @@ module Workflow
291
292
  prov_tree = prov_tree(dep_tree)
292
293
  if prov_tree && ! prov_tree.empty? && prov_tree.split("\n").length > 2
293
294
 
295
+ str.puts
294
296
  str.puts Log.color :magenta, "## DEPENDENCY GRAPH (abridged)"
295
297
  str.puts
296
298
  prov_tree.split("\n").each do |line|
@@ -7,5 +7,10 @@ module Workflow
7
7
  mod.instance_eval(&block)
8
8
  mod
9
9
  end
10
+
11
+ def find_in_dependencies(name, dependencies)
12
+ name = name.to_sym
13
+ dependencies.select{|dep| dep.task_name.to_sym == name }
14
+ end
10
15
  end
11
16
 
data/scout-gear.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-gear 10.1.0 ruby lib
5
+ # stub: scout-gear 10.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "10.1.0"
9
+ s.version = "10.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2023-07-07"
14
+ s.date = "2023-07-27"
15
15
  s.description = "Temporary files, logs, path, resources, persistence, workflows, TSV, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
57
57
  "lib/scout/tsv/traverse.rb",
58
58
  "lib/scout/tsv/util.rb",
59
59
  "lib/scout/tsv/util/filter.rb",
60
+ "lib/scout/tsv/util/melt.rb",
60
61
  "lib/scout/tsv/util/process.rb",
61
62
  "lib/scout/tsv/util/reorder.rb",
62
63
  "lib/scout/tsv/util/select.rb",
@@ -89,9 +90,12 @@ Gem::Specification.new do |s|
89
90
  "lib/workflow-scout.rb",
90
91
  "scout-gear.gemspec",
91
92
  "scout_commands/alias",
93
+ "scout_commands/batch/clean",
94
+ "scout_commands/batch/list",
92
95
  "scout_commands/doc",
93
96
  "scout_commands/find",
94
97
  "scout_commands/glob",
98
+ "scout_commands/log",
95
99
  "scout_commands/offsite",
96
100
  "scout_commands/rbbt",
97
101
  "scout_commands/resource/produce",
@@ -100,7 +104,10 @@ Gem::Specification.new do |s|
100
104
  "scout_commands/workflow/info",
101
105
  "scout_commands/workflow/install",
102
106
  "scout_commands/workflow/list",
107
+ "scout_commands/workflow/prov",
103
108
  "scout_commands/workflow/task",
109
+ "scout_commands/workflow/trace",
110
+ "scout_commands/workflow/write_info",
104
111
  "share/color/color_names",
105
112
  "share/color/diverging_colors.hex",
106
113
  "share/software/install_helpers",
@@ -130,6 +137,7 @@ Gem::Specification.new do |s|
130
137
  "test/scout/tsv/test_traverse.rb",
131
138
  "test/scout/tsv/test_util.rb",
132
139
  "test/scout/tsv/util/test_filter.rb",
140
+ "test/scout/tsv/util/test_melt.rb",
133
141
  "test/scout/tsv/util/test_process.rb",
134
142
  "test/scout/tsv/util/test_reorder.rb",
135
143
  "test/scout/tsv/util/test_select.rb",
@@ -157,7 +165,7 @@ Gem::Specification.new do |s|
157
165
  ]
158
166
  s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
159
167
  s.licenses = ["MIT".freeze]
160
- s.rubygems_version = "3.4.13".freeze
168
+ s.rubygems_version = "3.5.0.dev".freeze
161
169
  s.summary = "basic gear for scouts".freeze
162
170
 
163
171
  s.specification_version = 4