Class: Rukawa::JobNet
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from AbstractJob
add_skip_rule, #name, #skip?, skip_rules, #skip_rules
Constructor Details
#initialize(variables = {}) ⇒ JobNet
Returns a new instance of JobNet.
14
15
16
17
|
# File 'lib/rukawa/job_net.rb', line 14
def initialize(variables = {})
@variables = variables
@dag = Dag.new(self, self.class.dependencies)
end
|
Instance Attribute Details
#dag ⇒ Object
Returns the value of attribute dag.
6
7
8
|
# File 'lib/rukawa/job_net.rb', line 6
def dag
@dag
end
|
Class Method Details
.dependencies ⇒ Object
9
10
11
|
# File 'lib/rukawa/job_net.rb', line 9
def dependencies
raise NotImplementedError, "Please override"
end
|
Instance Method Details
#dataflows ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/rukawa/job_net.rb', line 19
def dataflows
flat_map do |j|
if j.respond_to?(:dataflows)
j.dataflows
else
[j.dataflow]
end
end
end
|
#each(&block) ⇒ Object
74
75
76
|
# File 'lib/rukawa/job_net.rb', line 74
def each(&block)
@dag.each(&block)
end
|
#leaves ⇒ Object
70
71
72
|
# File 'lib/rukawa/job_net.rb', line 70
def leaves
@dag.leaves
end
|
#nodes_as_from ⇒ Object
39
40
41
|
# File 'lib/rukawa/job_net.rb', line 39
def nodes_as_from
leaves
end
|
#nodes_as_to ⇒ Object
43
44
45
|
# File 'lib/rukawa/job_net.rb', line 43
def nodes_as_to
roots
end
|
#output_dot(filename) ⇒ Object
35
36
37
|
# File 'lib/rukawa/job_net.rb', line 35
def output_dot(filename)
File.open(filename, 'w') { |f| f.write(to_dot) }
end
|
#roots ⇒ Object
66
67
68
|
# File 'lib/rukawa/job_net.rb', line 66
def roots
@dag.roots
end
|
#state ⇒ Object
29
30
31
32
33
|
# File 'lib/rukawa/job_net.rb', line 29
def state
inject(Rukawa::State::Waiting) do |state, j|
state.merge(j.state)
end
end
|
#to_dot(subgraph = false) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rukawa/job_net.rb', line 47
def to_dot(subgraph = false)
graphdef = subgraph ? "subgraph" : "digraph"
buf = %Q|#{graphdef} "#{subgraph ? "cluster_" : ""}#{name}" {\n|
buf += %Q{label = "#{name}";\n}
buf += "color = blue;\n" if subgraph
dag.each do |j|
buf += j.to_dot_def
end
dag.edges.each do |edge|
buf += %Q|"#{edge.from.name}" -> "#{edge.to.name}";\n|
end
buf += "}\n"
end
|
#to_dot_def ⇒ Object
62
63
64
|
# File 'lib/rukawa/job_net.rb', line 62
def to_dot_def
to_dot(true)
end
|