rukawa 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -104
- data/lib/rukawa/cli.rb +2 -2
- data/lib/rukawa/dag.rb +5 -7
- data/lib/rukawa/job.rb +5 -5
- data/lib/rukawa/job_net.rb +1 -1
- data/lib/rukawa/version.rb +1 -1
- data/sample/job_nets/sample_job_net.rb +28 -1
- data/sample/jobnet.png +0 -0
- data/sample/jobs/sample_job.rb +21 -0
- data/sample/result.png +0 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a389842b98a975ff2ed0ee853e8ffff2bd4e4a70
|
4
|
+
data.tar.gz: c9771aba374409856f6970c9facc5a6c2fcc168e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7121c4dab817fcdd3c08e669a03336eb34ba6bd6f1550a7c1a3c37f91133b5af6143a513cec690ef0149f2aea871ab7157c56dbe7de551a5a2c55c90ce8b2a30
|
7
|
+
data.tar.gz: b011617ab7508d79e5db4bb62fe65691301434b33894f4b5fb8fcc8ae105853b24ac20ac793ce774f8a377948545362cac7b81adfd16880d7b688cf71482c54f
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Rukawa
|
2
|
+
[](https://badge.fury.io/rb/rukawa)
|
2
3
|
[](https://travis-ci.org/joker1007/rukawa)
|
3
4
|
[](https://codeclimate.com/github/joker1007/rukawa)
|
4
5
|
|
@@ -28,112 +29,13 @@ Or install it yourself as:
|
|
28
29
|
|
29
30
|
### Job Definition
|
30
31
|
|
31
|
-
|
32
|
-
# jobs/sample_job.rb
|
33
|
-
|
34
|
-
module ExecuteLog
|
35
|
-
def self.store
|
36
|
-
@store ||= {}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class SampleJob < Rukawa::Job
|
41
|
-
def run
|
42
|
-
sleep rand(5)
|
43
|
-
ExecuteLog.store[self.class] = Time.now
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Job1 < SampleJob
|
48
|
-
end
|
49
|
-
class Job2 < SampleJob
|
50
|
-
end
|
51
|
-
class Job3 < SampleJob
|
52
|
-
end
|
53
|
-
class Job4 < SampleJob
|
54
|
-
end
|
55
|
-
class Job5 < SampleJob
|
56
|
-
def run
|
57
|
-
raise "job5 error"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
class Job6 < SampleJob
|
61
|
-
end
|
62
|
-
class Job7 < SampleJob
|
63
|
-
end
|
64
|
-
class Job8 < SampleJob
|
65
|
-
end
|
66
|
-
|
67
|
-
class InnerJob1 < SampleJob
|
68
|
-
end
|
69
|
-
|
70
|
-
class InnerJob2 < SampleJob
|
71
|
-
def run
|
72
|
-
raise "inner job2 error"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class InnerJob3 < SampleJob
|
77
|
-
end
|
78
|
-
|
79
|
-
class InnerJob4 < SampleJob
|
80
|
-
end
|
81
|
-
|
82
|
-
class InnerJob5 < SampleJob
|
83
|
-
add_skip_rule ->(job) { job.is_a?(SampleJob) }
|
84
|
-
end
|
85
|
-
|
86
|
-
class InnerJob6 < SampleJob
|
87
|
-
end
|
88
|
-
```
|
32
|
+
See [sample/jobs/sample_job.rb](https://github.com/joker1007/rukawa/blob/master/sample/jobs/sample_job.rb).
|
89
33
|
|
90
34
|
### JobNet Definition
|
91
|
-
```rb
|
92
|
-
# job_nets/sample_job_net.rb
|
93
|
-
|
94
|
-
class InnerJobNet < Rukawa::JobNet
|
95
|
-
class << self
|
96
|
-
def dependencies
|
97
|
-
{
|
98
|
-
InnerJob3 => [],
|
99
|
-
InnerJob1 => [],
|
100
|
-
InnerJob2 => [InnerJob1, InnerJob3],
|
101
|
-
}
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class InnerJobNet2 < Rukawa::JobNet
|
107
|
-
class << self
|
108
|
-
def dependencies
|
109
|
-
{
|
110
|
-
InnerJob4 => [],
|
111
|
-
InnerJob5 => [],
|
112
|
-
InnerJob6 => [InnerJob4, InnerJob5],
|
113
|
-
}
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
class SampleJobNet < Rukawa::JobNet
|
119
|
-
class << self
|
120
|
-
def dependencies
|
121
|
-
{
|
122
|
-
Job1 => [],
|
123
|
-
Job2 => [Job1], Job3 => [Job1],
|
124
|
-
Job4 => [Job2, Job3],
|
125
|
-
InnerJobNet => [Job3],
|
126
|
-
Job8 => [InnerJobNet],
|
127
|
-
Job5 => [Job3],
|
128
|
-
Job6 => [Job4, Job5],
|
129
|
-
Job7 => [Job6],
|
130
|
-
InnerJobNet2 => [Job4],
|
131
|
-
}
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
```
|
136
35
|
|
36
|
+
See [sample/job_nets/sample_job_net.rb](https://github.com/joker1007/rukawa/blob/master/sample/job_nets/sample_job_net.rb).
|
37
|
+
|
38
|
+
### JobGraph
|
137
39
|

|
138
40
|
|
139
41
|
### Execution
|
@@ -142,7 +44,7 @@ end
|
|
142
44
|
% cd rukawa/sample
|
143
45
|
|
144
46
|
# load ./jobs/**/*.rb, ./job_net/**/*.rb automatically
|
145
|
-
% bundle exec rukawa run SampleJobNet -r
|
47
|
+
% bundle exec rukawa run SampleJobNet -r 1 -d result.dot
|
146
48
|
+--------------+---------+
|
147
49
|
| Job | Status |
|
148
50
|
+--------------+---------+
|
data/lib/rukawa/cli.rb
CHANGED
@@ -20,7 +20,7 @@ module Rukawa
|
|
20
20
|
load_job_definitions
|
21
21
|
|
22
22
|
job_net_class = Object.const_get(job_net_name)
|
23
|
-
job_net = job_net_class.new(options[:variables])
|
23
|
+
job_net = job_net_class.new(nil, options[:variables])
|
24
24
|
result = Runner.run(job_net, options[:batch], options[:refresh_interval])
|
25
25
|
|
26
26
|
if options[:dot]
|
@@ -37,7 +37,7 @@ module Rukawa
|
|
37
37
|
load_job_definitions
|
38
38
|
|
39
39
|
job_net_class = Object.const_get(job_net_name)
|
40
|
-
job_net = job_net_class.new(options[:variables])
|
40
|
+
job_net = job_net_class.new(nil, options[:variables])
|
41
41
|
job_net.output_dot(options[:output])
|
42
42
|
end
|
43
43
|
|
data/lib/rukawa/dag.rb
CHANGED
@@ -18,13 +18,11 @@ module Rukawa
|
|
18
18
|
dependencies[job_class].each do |depend_job_class|
|
19
19
|
depend_job = @jobs.find { |j| j.instance_of?(depend_job_class) }
|
20
20
|
|
21
|
-
depend_job.nodes_as_from.each do |from|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
to.in_comings << edge
|
27
|
-
end
|
21
|
+
depend_job.nodes_as_from.product(job.nodes_as_to).each do |from, to|
|
22
|
+
edge = Edge.new(from, to, job_net)
|
23
|
+
@edges << edge
|
24
|
+
from.out_goings << edge
|
25
|
+
to.in_comings << edge
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
data/lib/rukawa/job.rb
CHANGED
@@ -6,7 +6,7 @@ module Rukawa
|
|
6
6
|
attr_accessor :in_comings, :out_goings
|
7
7
|
attr_reader :state
|
8
8
|
|
9
|
-
def initialize(job_net)
|
9
|
+
def initialize(job_net, variables = {})
|
10
10
|
@job_net = job_net
|
11
11
|
@in_comings = Set.new
|
12
12
|
@out_goings = Set.new
|
@@ -14,11 +14,11 @@ module Rukawa
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def root?
|
17
|
-
in_comings.empty?
|
17
|
+
in_comings.select { |edge| edge.cluster == @job_net }.empty?
|
18
18
|
end
|
19
19
|
|
20
20
|
def leaf?
|
21
|
-
out_goings.empty?
|
21
|
+
out_goings.select { |edge| edge.cluster == @job_net }.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
def dataflow
|
@@ -58,9 +58,9 @@ module Rukawa
|
|
58
58
|
|
59
59
|
def to_dot_def
|
60
60
|
if state == Rukawa::State::Waiting
|
61
|
-
""
|
61
|
+
"#{name};\n"
|
62
62
|
else
|
63
|
-
"#{name} [color = #{state.color}];\n"
|
63
|
+
"#{name} [color = #{state.color}];\n"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/lib/rukawa/job_net.rb
CHANGED
data/lib/rukawa/version.rb
CHANGED
@@ -15,13 +15,38 @@ class InnerJobNet2 < Rukawa::JobNet
|
|
15
15
|
def dependencies
|
16
16
|
{
|
17
17
|
InnerJob4 => [],
|
18
|
-
InnerJob5 => [],
|
18
|
+
InnerJob5 => [InnerJob4],
|
19
19
|
InnerJob6 => [InnerJob4, InnerJob5],
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
class InnerJobNet3 < Rukawa::JobNet
|
26
|
+
class << self
|
27
|
+
def dependencies
|
28
|
+
{
|
29
|
+
InnerJob7 => [],
|
30
|
+
InnerJob8 => [],
|
31
|
+
InnerJob9 => [InnerJob7, InnerJob8],
|
32
|
+
InnerJob10 => [InnerJob7, InnerJob8],
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class InnerJobNet4 < Rukawa::JobNet
|
39
|
+
class << self
|
40
|
+
def dependencies
|
41
|
+
{
|
42
|
+
InnerJob11 => [],
|
43
|
+
InnerJob12 => [],
|
44
|
+
InnerJob13 => [],
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
25
50
|
class SampleJobNet < Rukawa::JobNet
|
26
51
|
class << self
|
27
52
|
def dependencies
|
@@ -35,6 +60,8 @@ class SampleJobNet < Rukawa::JobNet
|
|
35
60
|
Job6 => [Job4, Job5],
|
36
61
|
Job7 => [Job6],
|
37
62
|
InnerJobNet2 => [Job4],
|
63
|
+
InnerJobNet3 => [Job8, Job7],
|
64
|
+
InnerJobNet4 => [InnerJobNet3],
|
38
65
|
}
|
39
66
|
end
|
40
67
|
end
|
data/sample/jobnet.png
CHANGED
Binary file
|
data/sample/jobs/sample_job.rb
CHANGED
@@ -52,3 +52,24 @@ end
|
|
52
52
|
|
53
53
|
class InnerJob6 < SampleJob
|
54
54
|
end
|
55
|
+
|
56
|
+
class InnerJob7 < SampleJob
|
57
|
+
end
|
58
|
+
|
59
|
+
class InnerJob8 < SampleJob
|
60
|
+
end
|
61
|
+
|
62
|
+
class InnerJob9 < SampleJob
|
63
|
+
end
|
64
|
+
|
65
|
+
class InnerJob10 < SampleJob
|
66
|
+
end
|
67
|
+
|
68
|
+
class InnerJob11 < SampleJob
|
69
|
+
end
|
70
|
+
|
71
|
+
class InnerJob12 < SampleJob
|
72
|
+
end
|
73
|
+
|
74
|
+
class InnerJob13 < SampleJob
|
75
|
+
end
|
data/sample/result.png
CHANGED
Binary file
|