pwrake 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: 06576ed3f8e9a5ce1a3a551d325a1ff8f279e00e
4
- data.tar.gz: 4303b90a5506a9bb028c63dd8ba344e3ab275c08
3
+ metadata.gz: d3d87023233f03e030697675ddd3869f47f1784a
4
+ data.tar.gz: 984fc85baa604dfbd0092e833f193e74c56b5a71
5
5
  SHA512:
6
- metadata.gz: e07ed43f6036919a6741c5db56e8fce972e0cbdb454ba252300e232000b882617baa123a0b602c53dd43b3e63d47034788aa11658626d35bdd59d976a5155149
7
- data.tar.gz: 0da74c52c071489794a83e0eba0be5305c0eaa8e31e477dff4eedbd18cec229f8f5dd1ab66ec78f90a1c1e4170137fddd64e22ec08f133b1f1521b4219ee5791
6
+ metadata.gz: de7d46e56c7487ad87b70b47c5f6d60b0d8231c16b0f86f40aa3437f4618c949986cb14293b05af853a72573f9f110be6ce665905027673b3ad7c2e38a3e911e
7
+ data.tar.gz: 767e0e3e4a88dfc64224c4358023bde7761084265783386f981b78d60ecd3c573438929a0e426443be1f21b70ba4db5988c5bd9f198586004d3ac4ca8efcdde4
data/README.md CHANGED
@@ -1,18 +1,27 @@
1
1
  # Pwrake
2
2
 
3
- Parallel workflow extension for Rake
3
+ Parallel Workflow extension for Rake, runs on multicores, clusters, clouds.
4
4
  * Author: Masahiro Tanaka
5
5
 
6
- ([README in Japanese](https://github.com/masa16/pwrake/wiki/Pwrake.ja)),
7
- ([GitHub Repository](https://github.com/masa16/pwrake))
6
+ ([README in Japanese](https://github.com/masa16/pwrake/wiki/Pwrakeとは)),
7
+ ([GitHub Repository](https://github.com/masa16/pwrake)),
8
+ ([RubyGems](https://rubygems.org/gems/pwrake))
8
9
 
9
10
  ## Features
10
11
 
11
- * Parallelize all tasks; no need to modify Rakefile, no need to use `multitask`.
12
- * Tasks are executed in the given number of worker threads.
13
- * Remote exuecution using SSH.
14
- * Pwrake is an extension to Rake, not patch to Rake: Rake and Pwrake coexist.
15
- * High parallel I/O performance using Gfarm file system.
12
+ * Pwrake executes a workflow written in Rakefile in parallel.
13
+ * The specification of Rakefile is same as Rake.
14
+ * The tasks which do not have mutual dependencies are automatically executed in parallel.
15
+ * The `multitask` which is a parallel task definition of Rake is no more necessary.
16
+ * Parallel and distributed execution is possible using a computer cluster which consists of multiple compute nodes.
17
+ * Cluster settings: SSH login, and the directory sharing using a shared filesystem, e.g., NFS, Gfarm.
18
+ * Pwrake automatically connects to remote hosts using SSH. You do not need to start a daemon.
19
+ * Remote host names and the number of cores to use are provided in a hostfile.
20
+ * [Gfarm file system](http://sourceforge.net/projects/gfarm/) utilizes storage of compute nodes. It provides the high-performance parallel I/O.
21
+ * Parallel I/O access to local stroage of compute nodes enables scalable increase in the I/O performance.
22
+ * Gfarm schedules a compute node to store an output file, to local storage.
23
+ * Pwrake schedules a compute node to execute a task, to a node where input files are stored.
24
+ * Other supports for Gfarm: Automatic mount of the Gfarm file system, etc.
16
25
 
17
26
  ## Installation
18
27
 
@@ -97,7 +106,8 @@ Or, gem install:
97
106
  SHELL_COMMAND default=$SHELL
98
107
  SHELL_RC Run-Command when shell starts
99
108
  PASS_ENV (Array) Environment variables passed to SSH
100
- HEARTBEAT defulat=240 - Hearbeat interval in seconds
109
+ HEARTBEAT defulat=240 - Hearbeat interval in seconds
110
+ RETRY default=0 - The number of default task retry
101
111
  FAILED_TARGET rename(default)|delete|leave - Treatment of failed target files
102
112
  FAILURE_TERMINATION wait(default)|kill|continue - Behavior of other tasks when a task is failed
103
113
  QUEUE_PRIORITY LIHR(default)|FIFO|LIFO|RANK
@@ -123,10 +133,19 @@ Or, gem install:
123
133
 
124
134
  Example of Rakefile:
125
135
 
126
- desc "ncore=4 allow=ourhost*"
127
- rule ".o" => ".c" do
128
- sh "..."
129
- end
136
+ ``` ruby
137
+ desc "ncore=4 allow=ourhost*" # desc has no effect on rule in original Rake, but it is used for task property in Pwrake.
138
+ rule ".o" => ".c" do
139
+ sh "..."
140
+ end
141
+
142
+ (1..n).each do |i|
143
+ desc "ncore=2 steal=no" # desc should be inside of loop because it is effective only for the next task.
144
+ file "task#{i}" do
145
+ sh "..."
146
+ end
147
+ end
148
+ ```
130
149
 
131
150
  Properties (The leftmost item is default):
132
151
 
@@ -136,6 +155,7 @@ Properties (The leftmost item is default):
136
155
  deny=hostname - Deny this host to execute this task. (accepts wild card)
137
156
  order=deny,allow|allow,deny - The order of evaluation.
138
157
  steal=yes|no - Allow task stealing for this task.
158
+ retry=integer - The number of retry for this task.
139
159
 
140
160
  ## Note for Gfarm
141
161
 
@@ -125,7 +125,7 @@ module Pwrake
125
125
  # wait for remote shell open
126
126
  Fiber.new do
127
127
  if !shell.open
128
- errors << [comm.host,s]
128
+ errors << comm.host
129
129
  end
130
130
  Log.debug "Branch#setup_shells: end of fiber to open shell"
131
131
  end.resume
@@ -62,7 +62,7 @@ module Pwrake
62
62
  if default_channel
63
63
  return default_channel.run_fiber(s.chomp)
64
64
  else
65
- raise "No default_channel"
65
+ raise "No default_channel, received: #{s.chomp}"
66
66
  end
67
67
  else
68
68
  # End of IO
@@ -203,22 +203,24 @@ module Pwrake
203
203
  # check failure
204
204
  if tw.status == "fail"
205
205
  $stderr.puts %[task "#{tw.name}" failed.]
206
- if !@failed
207
- @failed = true
208
- case @option['FAILURE_TERMINATION']
209
- when 'kill'
210
- @hdl_set.kill("INT")
211
- @no_more_run = true
212
- $stderr.puts "... Kill running tasks."
213
- when 'continue'
214
- $stderr.puts "... Continue runable tasks."
215
- else # 'wait'
216
- @no_more_run = true
217
- $stderr.puts "... Wait for running tasks."
206
+ if !tw.retry
207
+ if !@failed
208
+ @failed = true
209
+ case @option['FAILURE_TERMINATION']
210
+ when 'kill'
211
+ @hdl_set.kill("INT")
212
+ @no_more_run = true
213
+ $stderr.puts "... Kill running tasks."
214
+ when 'continue'
215
+ $stderr.puts "... Continue runable tasks."
216
+ else # 'wait'
217
+ @no_more_run = true
218
+ $stderr.puts "... Wait for running tasks."
219
+ end
220
+ end
221
+ if tw.has_output_file? && File.exist?(tw.name)
222
+ handle_failed_target(tw.name)
218
223
  end
219
- end
220
- if tw.has_output_file? && File.exist?(tw.name)
221
- handle_failed_target(tw.name)
222
224
  end
223
225
  end
224
226
  # postprocess
@@ -122,12 +122,14 @@ module Pwrake
122
122
  info_list
123
123
  end
124
124
 
125
+ REGEX_RANGE = /\[\[([\w\d]+)-([\w\d]+)\]\]/o
126
+
125
127
  def parse_line(info_list,line)
126
128
  line = $1 if /^([^#]*)#/ =~ line
127
129
  host, ncore, weight, group = line.split
128
130
  if host
129
- if /\[\[([\w\d]+)-([\w\d]+)\]\]/o =~ host
130
- hosts = ($1..$2).map{|i| host.sub(re,i)}
131
+ if REGEX_RANGE =~ host
132
+ hosts = ($1..$2).map{|i| host.sub(REGEX_RANGE,i)}
131
133
  else
132
134
  hosts = [host]
133
135
  end
@@ -178,6 +178,7 @@ module Pwrake
178
178
  ['NUM_THREADS', proc{|v| v && v.to_i}],
179
179
  ['SHELL_START_INTERVAL', proc{|v| (v || 0.012).to_f}],
180
180
  ['HEARTBEAT', proc{|v| (v || 240).to_i}],
181
+ ['RETRY', proc{|v| (v || 0).to_i}],
181
182
  ['DISABLE_AFFINITY', proc{|v| v || ENV['AFFINITY']=='off'}],
182
183
  ['DISABLE_STEAL', proc{|v| v || ENV['STEAL']=='off'}],
183
184
  ['GFARM_BASEDIR', proc{|v| v || '/tmp'}],
@@ -69,8 +69,6 @@ module Pwrake
69
69
  (size-1).downto(0) do |i|
70
70
  if at(i).acceptable_for(host_info)
71
71
  return delete_at(i)
72
- #else
73
- # Log.debug "task[#{at(i).name}] is rejected"
74
72
  end
75
73
  end
76
74
  nil
@@ -3,12 +3,15 @@ module Pwrake
3
3
  class TaskProperty
4
4
 
5
5
  attr_reader :ncore, :exclusive, :allow, :deny, :order_allow_deny,
6
- :disable_steal
6
+ :retry, :disable_steal
7
7
 
8
8
  def parse_description(description)
9
9
  if /\bn_?cores?[=:]\s*([+-]?\d+)/i =~ description
10
10
  @ncore = $1.to_i
11
11
  end
12
+ if /\bretry[=:]\s*(\d+)/i =~ description
13
+ @retry = $1.to_i
14
+ end
12
15
  if /\bexclusive[=:]\s*(\S+)/i =~ description
13
16
  if /^(y|t)/i =~ $1
14
17
  @exclusive = true
@@ -27,6 +27,7 @@ module Pwrake
27
27
  @executed = false
28
28
  @assigned = []
29
29
  @exec_host = nil
30
+ @nretry = @property.retry || Rake.application.pwrake_options["RETRY"] || 0
30
31
  end
31
32
 
32
33
  def_delegators :@task, :name, :actions, :prerequisites, :subsequents
@@ -65,6 +66,19 @@ module Pwrake
65
66
  @time_start = Time.now
66
67
  end
67
68
 
69
+ def retry
70
+ if @nretry > 0
71
+ s="retry task: #{name}"
72
+ Log.debug(s)
73
+ $stderr.puts(s)
74
+ @nretry -= 1
75
+ Rake.application.task_queue.enq(self)
76
+ true
77
+ else
78
+ false
79
+ end
80
+ end
81
+
68
82
  def postprocess(location)
69
83
  @executed = true if !@task.actions.empty?
70
84
  tm_taskend = Time.now
@@ -1,3 +1,3 @@
1
1
  module Pwrake
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -32,12 +32,12 @@ module Pwrake
32
32
  begin
33
33
  @dir.open
34
34
  @dir.open_messages.each{|m| @log.info(m)}
35
+ @pid = Kernel.spawn(@shell_cmd,
36
+ :out=>@spawn_out,
37
+ :err=>@spawn_err,
38
+ :in=>@spawn_in,
39
+ :chdir=>@dir.current)
35
40
  begin
36
- @pid = Kernel.spawn(@shell_cmd,
37
- :out=>@spawn_out,
38
- :err=>@spawn_err,
39
- :in=>@spawn_in,
40
- :chdir=>@dir.current)
41
41
  @out.puts "#{@id}:open"
42
42
  @shell_rc.each do |cmd|
43
43
  run_rc(cmd)
@@ -50,10 +50,11 @@ module Pwrake
50
50
  ensure
51
51
  status = nil
52
52
  begin
53
- timeout(5){
53
+ Timeout.timeout(5){
54
54
  pid,status = Process.waitpid2(@pid)
55
55
  }
56
- rescue
56
+ rescue => exc
57
+ @log.error ([exc.to_s]+exc.backtrace).join("\n")
57
58
  @log.info("#{@id}:kill INT sh @pid=#{@pid}")
58
59
  Process.kill("INT",@pid)
59
60
  pid,status = Process.waitpid2(@pid)
@@ -62,7 +63,7 @@ module Pwrake
62
63
  end
63
64
  rescue => exc
64
65
  @out.puts "#{@id}:exc:#{exc}"
65
- @log.error exc
66
+ @log.error ([exc.to_s]+exc.backtrace).join("\n")
66
67
  ensure
67
68
  @dir.close_messages.each{|m| @log.info(m)}
68
69
  @dir.close
@@ -76,7 +76,7 @@ module Pwrake
76
76
  spawn_cmd "fusermount -u #{@gfarm_mountpoint}"
77
77
  rescue
78
78
  end
79
- system "sync"
79
+ #system "sync"
80
80
  begin
81
81
  FileUtils.rmdir @gfarm_mountpoint
82
82
  @log.info "rmdir #{@gfarm_mountpoint} @#{@@hostname}"
@@ -1,5 +1,3 @@
1
- require "timeout"
2
-
3
1
  module Pwrake
4
2
 
5
3
  class Invoker
@@ -158,7 +156,7 @@ module Pwrake
158
156
  end
159
157
  @log.info "worker:end:#{id_list.inspect}"
160
158
  begin
161
- timeout(20){@log.close}
159
+ Timeout.timeout(20){@log.close}
162
160
  rescue => e
163
161
  $stdout.puts e
164
162
  $stdout.puts e.backtrace.join("\n")
@@ -1,5 +1,6 @@
1
1
  require "thread"
2
2
  require "fileutils"
3
+ require "timeout"
3
4
 
4
5
  ncore = Marshal.load($stdin)
5
6
  opts = Marshal.load($stdin)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parallel workflow extension for Rake
14
14
  email:
@@ -24,7 +24,6 @@ files:
24
24
  - CHANGES_V2.md
25
25
  - Gemfile
26
26
  - MIT-LICENSE
27
- - README
28
27
  - README.md
29
28
  - Rakefile
30
29
  - bin/gfwhere-pipe
@@ -119,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
118
  version: '0'
120
119
  requirements: []
121
120
  rubyforge_project:
122
- rubygems_version: 2.4.5
121
+ rubygems_version: 2.5.1
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: Adding Parallel and Distributed feature to Rake
@@ -141,4 +140,3 @@ test_files:
141
140
  - spec/helper.rb
142
141
  - spec/hosts
143
142
  - spec/pwrake_spec.rb
144
- has_rdoc:
data/README DELETED
@@ -1,12 +0,0 @@
1
- Pwrake2 - Parallel Workflow extension for Rake
2
- Masahiro Tanaka 2012-04-14
3
-
4
- *** under development ***
5
-
6
- * Required package
7
-
8
- - Ruby 1.9.3 + Rake 0.9.2.2
9
-
10
- * Install
11
-
12
- $ ruby setup.rb