Class: Pwrake::TaskProperty
- Inherits:
-
Object
- Object
- Pwrake::TaskProperty
- Defined in:
- lib/pwrake/task/task_property.rb
Instance Attribute Summary collapse
-
#allow ⇒ Object
readonly
Returns the value of attribute allow.
-
#deny ⇒ Object
readonly
Returns the value of attribute deny.
-
#disable_steal ⇒ Object
readonly
Returns the value of attribute disable_steal.
-
#exclusive ⇒ Object
readonly
Returns the value of attribute exclusive.
-
#ncore ⇒ Object
readonly
Returns the value of attribute ncore.
-
#order_allow_deny ⇒ Object
readonly
Returns the value of attribute order_allow_deny.
-
#reserve ⇒ Object
readonly
Returns the value of attribute reserve.
-
#retry ⇒ Object
readonly
Returns the value of attribute retry.
-
#subflow ⇒ Object
Returns the value of attribute subflow.
Instance Method Summary collapse
- #accept_host(host_info) ⇒ Object
- #merge(prop) ⇒ Object
- #parse_description(description) ⇒ Object
- #use_cores(arg) ⇒ Object
Instance Attribute Details
#allow ⇒ Object (readonly)
Returns the value of attribute allow.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def allow @allow end |
#deny ⇒ Object (readonly)
Returns the value of attribute deny.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def deny @deny end |
#disable_steal ⇒ Object (readonly)
Returns the value of attribute disable_steal.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def disable_steal @disable_steal end |
#exclusive ⇒ Object (readonly)
Returns the value of attribute exclusive.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def exclusive @exclusive end |
#ncore ⇒ Object (readonly)
Returns the value of attribute ncore.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def ncore @ncore end |
#order_allow_deny ⇒ Object (readonly)
Returns the value of attribute order_allow_deny.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def order_allow_deny @order_allow_deny end |
#reserve ⇒ Object (readonly)
Returns the value of attribute reserve.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def reserve @reserve end |
#retry ⇒ Object (readonly)
Returns the value of attribute retry.
5 6 7 |
# File 'lib/pwrake/task/task_property.rb', line 5 def retry @retry end |
#subflow ⇒ Object
Returns the value of attribute subflow.
7 8 9 |
# File 'lib/pwrake/task/task_property.rb', line 7 def subflow @subflow end |
Instance Method Details
#accept_host(host_info) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/pwrake/task/task_property.rb', line 103 def accept_host(host_info) return true unless host_info if @disable_steal && host_info.steal_flag #Log.debug("@disable_steal && host_info.steal_flag") return false end hn = host_info.name if @allow if @deny if @order_allow_deny return false if !File.fnmatch(@allow,hn) || File.fnmatch(@deny,hn) else return false if File.fnmatch(@deny,hn) && !File.fnmatch(@allow,hn) end else return false if !File.fnmatch(@allow,hn) end else if @deny return false if File.fnmatch(@deny,hn) end end return true end |
#merge(prop) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pwrake/task/task_property.rb', line 62 def merge(prop) @ncore = prop.ncore if prop.ncore @exclusive = prop.exclusive if prop.exclusive @reserve = prop.reserve if prop.reserve @allow = prop.allow if prop.allow @deny = prop.deny if prop.deny @order_allow_deny = prop.order_allow_deny if prop.order_allow_deny @retry = prop.retry if prop.retry @disable_steal = prop.disable_steal if prop.disable_steal @subflow = prop.subflow if prop.subflow end |
#parse_description(description) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pwrake/task/task_property.rb', line 9 def parse_description(description) if /\bn_?cores?[=:]\s*(-?[\/\d]+)/i =~ description case x = $1 when /^\/\d+$/ @ncore = ('1'+x).to_r when /^\d+\/\d+$/ @ncore = x.to_r when /^-?\d+$/ @ncore = x.to_i else m = "invalid task property: ncore=#{x.inspect}" Log.fatal m raise RuntimeError,m end end if /\bretry[=:]\s*(\d+)/i =~ description @retry = $1.to_i end if /\bexclusive[=:]\s*(\S+)/i =~ description if /^(y|t)/i =~ $1 @exclusive = true end end @reserve = Rake.application.["RESERVE_NODE"] if /\breserve[=:]\s*(\S+)/i =~ description case $1 when /^(y|t|on)/i @reserve = true when /^(n|f|off)/i @reserve = false end end if /\ballow[=:]\s*(\S+)/i =~ description @allow = $1 end if /\bdeny[=:]\s*(\S+)/i =~ description @deny = $1 end if /\border[=:]\s*(\S+)/i =~ description case $1 when /allow,deny/i @order_allow_deny = true when /deny,allow/i @order_allow_deny = false end end if /\bsteal[=:]\s*(\S+)/i =~ description if /^(n|f)/i =~ $1 @disable_steal = true end end end |
#use_cores(arg) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/pwrake/task/task_property.rb', line 74 def use_cores(arg) case arg when HostInfo ppn = arg.ncore when Integer ppn = arg if ppn < 1 raise "invalid ppn: #{ppn}" end else raise "invalid ppn: #{ppn}" end if @exclusive return ppn end case @ncore when nil return 1 when 1-ppn..ppn return (@ncore>0) ? @ncore : @ncore+ppn end m = "ncore=#{@ncore} is out of range of cores per node: #{ppn}" Log.fatal m raise RuntimeError,m end |