rukawa 0.1.0 → 0.1.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: e06e9e3a6f053f844f030ddbdd6d41b740ae4565
4
- data.tar.gz: a6cefb0f982de9eb9b26407d364394e87183204b
3
+ metadata.gz: a389842b98a975ff2ed0ee853e8ffff2bd4e4a70
4
+ data.tar.gz: c9771aba374409856f6970c9facc5a6c2fcc168e
5
5
  SHA512:
6
- metadata.gz: 876ed17a6dcc459f8b97ceda257d79c33e99fade9d16edf7c7ef8e11cf715c1f7f3619e3b1cac0045616a6109fe1edf1b89fce6f2d221b1d957458e84be6db40
7
- data.tar.gz: f1b491287e0541225161fe018115c0c8a1cf148c72f58e35e92eb6c32308c8fb6cef6e119a2814360d4f22112e55e10334fc3e17ef66acd4ecdbdbee05f53349
6
+ metadata.gz: 7121c4dab817fcdd3c08e669a03336eb34ba6bd6f1550a7c1a3c37f91133b5af6143a513cec690ef0149f2aea871ab7157c56dbe7de551a5a2c55c90ce8b2a30
7
+ data.tar.gz: b011617ab7508d79e5db4bb62fe65691301434b33894f4b5fb8fcc8ae105853b24ac20ac793ce774f8a377948545362cac7b81adfd16880d7b688cf71482c54f
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Rukawa
2
+ [![Gem Version](https://badge.fury.io/rb/rukawa.svg)](https://badge.fury.io/rb/rukawa)
2
3
  [![Build Status](https://travis-ci.org/joker1007/rukawa.svg?branch=master)](https://travis-ci.org/joker1007/rukawa)
3
4
  [![Code Climate](https://codeclimate.com/github/joker1007/rukawa/badges/gpa.svg)](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
- ```rb
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
  ![jobnet.png](https://raw.githubusercontent.com/joker1007/rukawa/master/sample/jobnet.png)
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 5 -d result.dot
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
- job.nodes_as_to.each do |to|
23
- edge = Edge.new(from, to)
24
- @edges << edge
25
- from.out_goings << edge
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" unless state == Rukawa::State::Waiting
63
+ "#{name} [color = #{state.color}];\n"
64
64
  end
65
65
  end
66
66
 
@@ -11,7 +11,7 @@ module Rukawa
11
11
  end
12
12
  end
13
13
 
14
- def initialize(variables = {})
14
+ def initialize(_job_net, variables = {})
15
15
  @variables = variables
16
16
  @dag = Dag.new(self, self.class.dependencies)
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Rukawa
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rukawa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007