scout-gear 10.0.1 → 10.1.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: 5af158e978a724dacd722c9584cb4fd3b7f46fff8a4619272b1d2c2258418600
4
- data.tar.gz: 6bd5da8eba38542376f4b5566154fc16105f3742ba0758a37139d0ff9679d06e
3
+ metadata.gz: ab089af23ec3cb6d23db1190f712d2a981db96e818572aa5b561227a9601b9b8
4
+ data.tar.gz: d72662def6d6b7207d015d7cea613a1882578efe201ed391f79d37027ab7c70e
5
5
  SHA512:
6
- metadata.gz: e9f6f4d2a5e223d740332b627c9606907d69536696f477401087b4f72bee09d1b374d060275ecb3fad5e38c27010417d36d661d985c58d71e3cec4bf04bbcbf7
7
- data.tar.gz: a7b8e5d1bfd1057bd93cfbd4a2439bccf0e28848f3e08923c81da8bcc2fe1a489ffb2e220587ecb4533ad0cf7edcf506f3c4557955dfa11356d816b87b379968
6
+ metadata.gz: d5b67fdc030ad2ed3dd4d9da47d7f12068b71f14a1ae390f65c411bc2e835ac2da1648fccb554cbda4a3a56bdf6b16fc63080620453e75481590622cfd883247
7
+ data.tar.gz: 97fa38ef8db895d3a8aa05d2e4e521bb98d28924b389429994f6e98bceb7bfa7ad74920676c17b8b124bf288700e80078909ea20a84c3c0b24efd0cf7b0632cb
data/.vimproject CHANGED
@@ -28,81 +28,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
28
28
  rbbt-scout.rb
29
29
  scout.rb
30
30
  scout=scout{
31
- meta_extension.rb
32
- exceptions.rb
33
-
34
- misc.rb
35
- misc=misc{
36
- format.rb
37
- insist.rb
38
- digest.rb
39
- filesystem.rb
40
- monitor.rb
41
- system.rb
42
- }
43
- named_array.rb
44
- indiferent_hash.rb
45
- indiferent_hash=indiferent_hash{
46
- case_insensitive.rb
47
- options.rb
48
- }
49
- log.rb
50
- log=log{
51
- color.rb
52
- color_class.rb
53
- fingerprint.rb
54
- progress.rb
55
- progress=progress{
56
- report.rb
57
- util.rb
58
- }
59
- trap.rb
60
- }
61
- tmpfile.rb
62
- simple_opt.rb
63
- simple_opt=simple_opt{
64
- accessor.rb
65
- doc.rb
66
- parse.rb
67
- get.rb
68
- setup.rb
69
- }
70
- path.rb
71
- path=path{
72
- find.rb
73
- util.rb
74
- tmpfile.rb
75
- }
76
- concurrent_stream.rb
77
- cmd.rb
78
- open.rb
79
- open=open{
80
- lock.rb
81
- remote.rb
82
- stream.rb
83
- util.rb
84
- lock=lock{
85
- lockfile.rb
86
- }
87
- }
88
- resource.rb
89
- resource=resource{
90
- produce.rb
91
- produce=produce{
92
- rake.rb
93
- }
94
- software.rb
95
- scout.rb
96
- util.rb
97
- path.rb
98
- }
99
- config.rb
100
- persist.rb
101
- persist=persist{
102
- serialize.rb
103
- open.rb
104
- path.rb
105
- }
106
31
  workflow.rb
107
32
  workflow=workflow{
108
33
  definition.rb
@@ -146,6 +71,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
146
71
  process.rb
147
72
  unzip.rb
148
73
  reorder.rb
74
+ sort.rb
149
75
  }
150
76
  parser.rb
151
77
  dumper.rb
@@ -173,9 +99,6 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
173
99
  sync.rb
174
100
  step.rb
175
101
  }
176
- hpc=hpc{
177
- slurm.rb
178
- }
179
102
  }
180
103
  }
181
104
  test=test {
data/Rakefile CHANGED
@@ -35,6 +35,7 @@ Juwelier::RubygemsDotOrgTasks.new
35
35
 
36
36
  require 'rake/testtask'
37
37
  Rake::TestTask.new(:test) do |test|
38
+ ENV["SCOUT_LOG"] = "NONE"
38
39
  test.libs << 'lib' << 'test'
39
40
  test.pattern = 'test/**/test_*.rb'
40
41
  test.verbose = true
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.0.1
1
+ 10.1.0
@@ -0,0 +1,74 @@
1
+ module TSV
2
+ def sort_by(field = nil, just_keys = false, &block)
3
+ field = :all if field.nil?
4
+
5
+ if field == :all
6
+ elems = collect
7
+ else
8
+ elems = []
9
+ case type
10
+ when :single
11
+ through :key, field do |key, field|
12
+ elems << [key, field]
13
+ end
14
+ when :list, :flat
15
+ through :key, field do |key, fields|
16
+ elems << [key, fields.first]
17
+ end
18
+ when :double
19
+ through :key, field do |key, fields|
20
+ elems << [key, fields.first]
21
+ end
22
+ end
23
+ end
24
+
25
+ if not block_given?
26
+ if fields == :all
27
+ if just_keys
28
+ keys = elems.sort_by{|key, value| key }.collect{|key, values| key}
29
+ keys = prepare_entity(keys, key_field, entity_options.merge(:dup_array => true))
30
+ else
31
+ elems.sort_by{|key, value| key }
32
+ end
33
+ else
34
+ sorted = elems.sort do |a, b|
35
+ a_value = a.last
36
+ b_value = b.last
37
+ a_empty = a_value.nil? or (a_value.respond_to?(:empty?) and a_value.empty?)
38
+ b_empty = b_value.nil? or (b_value.respond_to?(:empty?) and b_value.empty?)
39
+ case
40
+ when (a_empty and b_empty)
41
+ 0
42
+ when a_empty
43
+ -1
44
+ when b_empty
45
+ 1
46
+ when Array === a_value
47
+ if a_value.length == 1 and b_value.length == 1
48
+ a_value.first <=> b_value.first
49
+ else
50
+ a_value.length <=> b_value.length
51
+ end
52
+ else
53
+ a_value <=> b_value
54
+ end
55
+ end
56
+ if just_keys
57
+ keys = sorted.collect{|key, value| key}
58
+ keys = prepare_entity(keys, key_field, entity_options.merge(:dup_array => true)) unless @unnamed
59
+ keys
60
+ else
61
+ sorted.collect{|key, value| [key, self[key]]}
62
+ end
63
+ end
64
+ else
65
+ if just_keys
66
+ keys = elems.sort_by(&block).collect{|key, value| key}
67
+ keys = prepare_entity(keys, key_field, entity_options.merge(:dup_array => true)) unless @unnamed
68
+ keys
69
+ else
70
+ elems.sort_by(&block).collect{|key, value| [key, self[key]]}
71
+ end
72
+ end
73
+ end
74
+ end
@@ -6,6 +6,7 @@ require_relative 'util/process'
6
6
  require_relative 'util/select'
7
7
  require_relative 'util/reorder'
8
8
  require_relative 'util/unzip'
9
+ require_relative 'util/sort'
9
10
  module TSV
10
11
  def self.identify_field(key_field, fields, name, strict: nil)
11
12
  return :key if name == :key || (! strict && NamedArray.field_match(key_field, name))
@@ -31,6 +31,7 @@ class Step
31
31
  Open.rm tmp_path if Open.exist?(tmp_path)
32
32
  Open.rm info_file if Open.exist?(info_file)
33
33
  Open.rm_rf files_dir if Open.exist?(files_dir)
34
+ self
34
35
  end
35
36
 
36
37
  def self.clean(file)
@@ -124,62 +124,62 @@ class Step
124
124
  return @result || self.load if done?
125
125
  prepare_dependencies
126
126
  run_dependencies
127
- @result =
128
- begin
129
- Persist.persist(name, type, :path => path, :tee_copies => tee_copies) do
130
- clear_info
131
- input_names = (task.respond_to?(:inputs) && task.inputs) ? task.inputs.collect{|name,_| name} : []
132
- merge_info :status => :start, :start => Time.now,
133
- :pid => Process.pid, :pid_hostname => Misc.hostname,
134
- :inputs => MetaExtension.purge(inputs), :input_names => input_names, :type => type,
135
- :dependencies => dependencies.collect{|d| d.path }
136
-
137
- @result = exec
138
-
139
- if @result.nil? && File.exist?(self.tmp_path) && ! File.exist?(self.path)
140
- Open.mv self.tmp_path, self.path
141
- else
142
- @result = @result.stream if @result.respond_to?(:stream)
143
- end
127
+ begin
128
+ @result = Persist.persist(name, type, :path => path, :tee_copies => tee_copies) do
129
+ clear_info
130
+ input_names = (task.respond_to?(:inputs) && task.inputs) ? task.inputs.collect{|name,_| name} : []
131
+ merge_info :status => :start, :start => Time.now,
132
+ :pid => Process.pid, :pid_hostname => Misc.hostname,
133
+ :inputs => MetaExtension.purge(inputs), :input_names => input_names, :type => type,
134
+ :dependencies => dependencies.collect{|d| d.path }
135
+
136
+ @exec_result = exec
137
+
138
+ if @exec_result.nil? && File.exist?(self.tmp_path) && ! File.exist?(self.path)
139
+ Open.mv self.tmp_path, self.path
140
+ else
141
+ @exec_result = @exec_result.stream if @exec_result.respond_to?(:stream)
142
+ end
144
143
 
145
- @result
144
+ @exec_result
146
145
 
147
- if (IO === @result || StringIO === @result) && (ENV["SCOUT_NO_STREAM"] == "true" || ! stream)
148
- Open.sensible_write(self.path, @result)
149
- @result = nil
150
- else
151
- @result
152
- end
146
+ if (IO === @exec_result || StringIO === @exec_result) && (ENV["SCOUT_NO_STREAM"] == "true" || ! stream)
147
+ Open.sensible_write(self.path, @exec_result)
148
+ @exec_result = nil
149
+ else
150
+ @exec_result
153
151
  end
154
- rescue Exception => e
155
- merge_info :status => :error, :exception => e, :end => Time.now
156
- abort_dependencies
157
- raise e
158
- ensure
159
- if ! (error? || aborted?)
160
- if streaming?
161
- ConcurrentStream.setup(@result) do
162
- merge_info :status => :done, :end => Time.now
163
- end
152
+ end
153
+ rescue Exception => e
154
+ merge_info :status => :error, :exception => e, :end => Time.now
155
+ abort_dependencies
156
+ raise e
157
+ ensure
158
+ if ! (error? || aborted?)
159
+ if streaming?
160
+ ConcurrentStream.setup(@result) do
161
+ merge_info :status => :done, :end => Time.now
162
+ end
164
163
 
165
- @result.abort_callback = proc do |exception|
166
- if exception.nil? || Aborted === exception || Interrupt === exception
167
- merge_info :status => :aborted, :end => Time.now
168
- else
169
- begin
170
- merge_info :status => :error, :exception => exception, :end => Time.now
171
- rescue Exception
172
- Log.exception $!
173
- end
164
+ @result.abort_callback = proc do |exception|
165
+ if exception.nil? || Aborted === exception || Interrupt === exception
166
+ merge_info :status => :aborted, :end => Time.now
167
+ else
168
+ begin
169
+ merge_info :status => :error, :exception => exception, :end => Time.now
170
+ rescue Exception
171
+ Log.exception $!
174
172
  end
175
173
  end
176
-
177
- log :streaming
178
- else
179
- merge_info :status => :done, :end => Time.now
180
174
  end
175
+
176
+
177
+ log :streaming
178
+ else
179
+ merge_info :status => :done, :end => Time.now
181
180
  end
182
181
  end
182
+ end
183
183
  end
184
184
 
185
185
  def fork
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.0.1 ruby lib
5
+ # stub: scout-gear 10.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "10.0.1"
9
+ s.version = "10.1.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-04"
14
+ s.date = "2023-07-07"
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]
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
60
60
  "lib/scout/tsv/util/process.rb",
61
61
  "lib/scout/tsv/util/reorder.rb",
62
62
  "lib/scout/tsv/util/select.rb",
63
+ "lib/scout/tsv/util/sort.rb",
63
64
  "lib/scout/tsv/util/unzip.rb",
64
65
  "lib/scout/work_queue.rb",
65
66
  "lib/scout/work_queue/exceptions.rb",
@@ -132,6 +133,7 @@ Gem::Specification.new do |s|
132
133
  "test/scout/tsv/util/test_process.rb",
133
134
  "test/scout/tsv/util/test_reorder.rb",
134
135
  "test/scout/tsv/util/test_select.rb",
136
+ "test/scout/tsv/util/test_sort.rb",
135
137
  "test/scout/tsv/util/test_unzip.rb",
136
138
  "test/scout/work_queue/test_socket.rb",
137
139
  "test/scout/work_queue/test_worker.rb",
@@ -155,7 +157,7 @@ Gem::Specification.new do |s|
155
157
  ]
156
158
  s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
157
159
  s.licenses = ["MIT".freeze]
158
- s.rubygems_version = "3.5.0.dev".freeze
160
+ s.rubygems_version = "3.4.13".freeze
159
161
  s.summary = "basic gear for scouts".freeze
160
162
 
161
163
  s.specification_version = 4
@@ -54,10 +54,10 @@ if help
54
54
  exit 0
55
55
  end
56
56
 
57
+ job_inputs = task.get_SOPT
58
+
57
59
  if load_inputs
58
- job_inputs = workflow.tasks[task_name].load_inputs(load_inputs)
59
- else
60
- job_inputs = task.get_SOPT
60
+ job_inputs = job_inputs.merge(workflow.tasks[task_name].load_inputs(load_inputs))
61
61
  end
62
62
 
63
63
  if override_deps
@@ -137,7 +137,7 @@ row2 aa bb cc
137
137
  dumper = TSV::Dumper.new :key_field => "Key", :fields => ["Field"], type: :single
138
138
  dumper.init
139
139
  assert_raise ScoutException do
140
- Log.with_severity 0 do
140
+ Log.with_severity 7 do
141
141
  i = 0
142
142
  TSV.traverse lines, :into => dumper, cpus: 3 do |l|
143
143
  raise ScoutException if i > 10
@@ -0,0 +1,23 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+
6
+ class TestClass < Test::Unit::TestCase
7
+
8
+ def test_sort_by
9
+ content =<<-EOF
10
+ #ID ValueA ValueB Comment
11
+ row1 a B c
12
+ row2 A b C
13
+ EOF
14
+
15
+ TmpFile.with_file(content) do |filename|
16
+ tsv = TSV.open(File.open(filename), :type => :list, :sep => /\s/)
17
+ assert_equal %w(row2 row1), tsv.sort_by("ValueA").collect{|k,v| k}
18
+ assert_equal %w(row1 row2), tsv.sort_by("ValueB").collect{|k,v| k}
19
+ end
20
+ end
21
+
22
+ end
23
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-gear
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.1
4
+ version: 10.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-04 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout-essentials
@@ -172,6 +172,7 @@ files:
172
172
  - lib/scout/tsv/util/process.rb
173
173
  - lib/scout/tsv/util/reorder.rb
174
174
  - lib/scout/tsv/util/select.rb
175
+ - lib/scout/tsv/util/sort.rb
175
176
  - lib/scout/tsv/util/unzip.rb
176
177
  - lib/scout/work_queue.rb
177
178
  - lib/scout/work_queue/exceptions.rb
@@ -244,6 +245,7 @@ files:
244
245
  - test/scout/tsv/util/test_process.rb
245
246
  - test/scout/tsv/util/test_reorder.rb
246
247
  - test/scout/tsv/util/test_select.rb
248
+ - test/scout/tsv/util/test_sort.rb
247
249
  - test/scout/tsv/util/test_unzip.rb
248
250
  - test/scout/work_queue/test_socket.rb
249
251
  - test/scout/work_queue/test_worker.rb
@@ -283,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
285
  - !ruby/object:Gem::Version
284
286
  version: '0'
285
287
  requirements: []
286
- rubygems_version: 3.5.0.dev
288
+ rubygems_version: 3.4.13
287
289
  signing_key:
288
290
  specification_version: 4
289
291
  summary: basic gear for scouts