rukawa 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rukawa/cli.rb +18 -1
- data/lib/rukawa/configuration.rb +33 -0
- data/lib/rukawa/job.rb +1 -1
- data/lib/rukawa/job_net.rb +2 -0
- data/lib/rukawa/version.rb +1 -1
- data/sample/jobnet.png +0 -0
- data/sample/result.png +0 -0
- data/sample/rukawa.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0345bf03c443cf5a22b3cde1e5397ccb86aa16ee
|
4
|
+
data.tar.gz: 317a36ce8f9664ef86fee7b8928e05f3cc101664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a0bda03e6575c683811947f1427390408125c0e397bd33c13325c0678a317219686e5d45110f24df666da96db3efca48737c66e6835f217b55c9e9af2857444
|
7
|
+
data.tar.gz: f68ec7053149239557a6f3dea6e4c3d0f72f75620a79a3f7d77dbe69c1ea9d83bba9c4490dd477db0ebc4cfdcc4325f20dd00b5ab03be73d905f961b5484288e
|
data/lib/rukawa/cli.rb
CHANGED
@@ -7,14 +7,17 @@ module Rukawa
|
|
7
7
|
map "run" => "_run"
|
8
8
|
method_option :concurrency, aliases: "-c", type: :numeric, default: nil, desc: "Default: cpu count"
|
9
9
|
method_option :variables, type: :hash, default: {}
|
10
|
+
method_option :config, type: :string, default: nil, desc: "If this options is not set, try to load ./rukawa.rb"
|
10
11
|
method_option :job_dirs, type: :array, default: [], desc: "Load job directories"
|
11
12
|
method_option :batch, aliases: "-b", type: :boolean, default: false, desc: "If batch mode, not display running status"
|
12
13
|
method_option :log, aliases: "-l", type: :string, default: "./rukawa.log"
|
14
|
+
method_option :stdout, type: :boolean, default: false, desc: "Output log to stdout"
|
13
15
|
method_option :dot, aliases: "-d", type: :string, default: nil, desc: "Output job status by dot format"
|
14
16
|
method_option :refresh_interval, aliases: "-r", type: :numeric, default: 3, desc: "Refresh interval for running status information"
|
15
17
|
def _run(job_net_name)
|
18
|
+
load_config
|
16
19
|
Rukawa.configure do |c|
|
17
|
-
c.log_file = options[:log]
|
20
|
+
c.log_file = options[:stdout] ? $stdout : options[:log]
|
18
21
|
c.concurrency = options[:concurrency] if options[:concurrency]
|
19
22
|
end
|
20
23
|
load_job_definitions
|
@@ -31,9 +34,11 @@ module Rukawa
|
|
31
34
|
end
|
32
35
|
|
33
36
|
desc "graph JOB_NET_NAME", "Output jobnet graph"
|
37
|
+
method_option :config, type: :string, default: nil, desc: "If this options is not set, try to load ./rukawa.rb"
|
34
38
|
method_option :job_dirs, type: :array, default: []
|
35
39
|
method_option :output, aliases: "-o", type: :string, required: true
|
36
40
|
def graph(job_net_name)
|
41
|
+
load_config
|
37
42
|
load_job_definitions
|
38
43
|
|
39
44
|
job_net_class = Object.const_get(job_net_name)
|
@@ -43,6 +48,18 @@ module Rukawa
|
|
43
48
|
|
44
49
|
private
|
45
50
|
|
51
|
+
def load_config
|
52
|
+
if options[:config]
|
53
|
+
load File.expand_path(options[:config], Dir.pwd)
|
54
|
+
else
|
55
|
+
load default_config_file if File.exists?(default_config_file)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def default_config_file
|
60
|
+
"./rukawa.rb"
|
61
|
+
end
|
62
|
+
|
46
63
|
def default_job_dirs
|
47
64
|
[File.join(Dir.pwd, "job_nets"), File.join(Dir.pwd, "jobs")]
|
48
65
|
end
|
data/lib/rukawa/configuration.rb
CHANGED
@@ -9,10 +9,43 @@ module Rukawa
|
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@config = OpenStruct.new(log_file: "./rukawa.log", concurrency: Concurrent.processor_count)
|
12
|
+
@config.graph = GraphConfig.new.tap { |c| c.rankdir = "LR" }
|
12
13
|
end
|
13
14
|
|
14
15
|
def __getobj__
|
15
16
|
@config
|
16
17
|
end
|
18
|
+
|
19
|
+
def graph_attrs
|
20
|
+
if @config.graph.rankdir || @config.graph.size || @config.graph
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
GraphConfig = Struct.new(:rankdir, :size, :rotate, :ranksep, :nodesep, :concentrate, :node) do
|
26
|
+
def initialize(*args)
|
27
|
+
super
|
28
|
+
self.node = GraphNodeConfig.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def attrs
|
32
|
+
if rankdir || size || rotate || ranksep || nodesep || concentrate
|
33
|
+
values = to_h.map { |k, v| "#{k} = #{v}" if k != :node && v }.compact
|
34
|
+
"graph [#{values.join(",")}];\n"
|
35
|
+
else
|
36
|
+
""
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
GraphNodeConfig = Struct.new(:shape, :style) do
|
42
|
+
def attrs
|
43
|
+
if shape || style
|
44
|
+
values = to_h.map { |k, v| "#{k} = #{v}" if v }.compact
|
45
|
+
"node [#{values.join(",")}];\n"
|
46
|
+
else
|
47
|
+
""
|
48
|
+
end
|
49
|
+
end
|
17
50
|
end
|
18
51
|
end
|
data/lib/rukawa/job.rb
CHANGED
data/lib/rukawa/job_net.rb
CHANGED
@@ -48,6 +48,8 @@ module Rukawa
|
|
48
48
|
graphdef = subgraph ? "subgraph" : "digraph"
|
49
49
|
buf = %Q|#{graphdef} "#{subgraph ? "cluster_" : ""}#{name}" {\n|
|
50
50
|
buf += %Q{label = "#{name}";\n}
|
51
|
+
buf += Rukawa.config.graph.attrs
|
52
|
+
buf += Rukawa.config.graph.node.attrs
|
51
53
|
buf += "color = blue;\n" if subgraph
|
52
54
|
dag.each do |j|
|
53
55
|
buf += j.to_dot_def
|
data/lib/rukawa/version.rb
CHANGED
data/sample/jobnet.png
CHANGED
Binary file
|
data/sample/result.png
CHANGED
Binary file
|
data/sample/rukawa.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rukawa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- sample/jobnet.png
|
142
142
|
- sample/jobs/sample_job.rb
|
143
143
|
- sample/result.png
|
144
|
+
- sample/rukawa.rb
|
144
145
|
homepage: https://github.com/joker1007/rukawa
|
145
146
|
licenses: []
|
146
147
|
metadata: {}
|