ev_job_gen 0.1.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +5 -5
- data/README.md +14 -14
- data/ev_job_gen.gemspec +1 -1
- data/kubernetes/tmpl/cron_job_template.yml.erb +3 -0
- data/kubernetes/tmpl/oneshot_job_template.yml.erb +1 -0
- data/kubernetes/tmpl/spec_template.yml.erb +9 -11
- data/lib/ev_job_gen.rb +1 -1
- data/lib/ev_job_gen/job.rb +11 -1
- data/lib/ev_job_gen/manifest_gen.rb +1 -1
- data/lib/ev_job_gen/renderer.rb +38 -0
- data/lib/ev_job_gen/renderer/manifest_renderer.rb +18 -0
- data/lib/ev_job_gen/renderer/spec_renderer.rb +27 -0
- data/lib/ev_job_gen/version.rb +1 -1
- metadata +11 -10
- data/lib/ev_job_gen/yml_renderer.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d76575d155e4b7b154b3a6c99935b9d95e6dcbc4808850300c66970060c7ac0
|
4
|
+
data.tar.gz: 8052e28d5ed38ca4dc74cf947743c5e0b50cb9a19235d68f97352291b3c0ba91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcdb61bac8e410866278924228bffee720bfbbb1aad4d6cad6f1417f28f662cf232122deed5ddd3d48034a20dfd4129cf05a78ae1a2e2ace7edf0e8d9b91df15
|
7
|
+
data.tar.gz: b631dadb3640383d4e0c574200d1a7c11e2a333e7458fa5b2de3ab55bfdd803b86f53b2346e7fd75cf51ff4be534321bb5898da9f0ba101c62dcc7b206986583
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ev_job_gen (0.
|
4
|
+
ev_job_gen (0.5.0)
|
5
5
|
dotenv (~> 2.5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
pry-doc (0.13.4)
|
18
18
|
pry (~> 0.11)
|
19
19
|
yard (~> 0.9.11)
|
20
|
-
rake (
|
20
|
+
rake (13.0.1)
|
21
21
|
rspec (3.7.0)
|
22
22
|
rspec-core (~> 3.7.0)
|
23
23
|
rspec-expectations (~> 3.7.0)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
32
|
rspec-support (~> 3.7.0)
|
33
33
|
rspec-support (3.7.1)
|
34
|
-
yard (0.9.
|
34
|
+
yard (0.9.20)
|
35
35
|
|
36
36
|
PLATFORMS
|
37
37
|
ruby
|
@@ -41,8 +41,8 @@ DEPENDENCIES
|
|
41
41
|
ev_job_gen!
|
42
42
|
pry
|
43
43
|
pry-doc
|
44
|
-
rake (~>
|
44
|
+
rake (~> 13.0)
|
45
45
|
rspec (~> 3.7)
|
46
46
|
|
47
47
|
BUNDLED WITH
|
48
|
-
1.
|
48
|
+
1.17.2
|
data/README.md
CHANGED
@@ -25,11 +25,12 @@ Place a yml file in jobs directory
|
|
25
25
|
# Ex. ml-project-1.yml
|
26
26
|
namespace: ml-project-1
|
27
27
|
image: some-docker-registory/ml-project-1:latest
|
28
|
-
command:
|
29
|
-
|
28
|
+
command:
|
29
|
+
- script/evaluate | tee /tmp/out.txt
|
30
30
|
out: /tmp/out.txt
|
31
31
|
metrics: /tmp/metrics.json
|
32
32
|
commithash: ${COMMITHASH}
|
33
|
+
setup_wget: apt install -y wget
|
33
34
|
```
|
34
35
|
|
35
36
|
Then execute `ev-job-gen` command.
|
@@ -74,30 +75,29 @@ spec:
|
|
74
75
|
app: ev-job
|
75
76
|
role: job
|
76
77
|
spec:
|
78
|
+
|
77
79
|
restartPolicy: Never
|
78
80
|
containers:
|
79
81
|
- name: ev-job
|
80
|
-
image: some-docker-registory/
|
82
|
+
image: some-docker-registory/ml-project-1:latest
|
81
83
|
imagePullPolicy: Always
|
82
84
|
command:
|
83
85
|
- "/bin/bash"
|
84
86
|
- "-c"
|
85
87
|
- >
|
86
|
-
script/evaluate | tee /tmp/out.txt
|
87
|
-
|
88
|
-
export
|
89
|
-
export
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
cp linux-amd64/ev ev;
|
95
|
-
|
88
|
+
script/evaluate | tee /tmp/out.txt &&
|
89
|
+
export AWS_ACCESS_KEY_ID=xxx &&
|
90
|
+
export AWS_SECRET_ACCESS_KEY=xxx &&
|
91
|
+
export AWS_REGION=xxx &&
|
92
|
+
apt install -y wget &&
|
93
|
+
wget https://github.com/wantedly/ev-cli/releases/download/v1.2.3/ev-v1.2.3-linux-amd64.tar.gz &&
|
94
|
+
tar xvzf ev-v1.2.3-linux-amd64.tar.gz &&
|
95
|
+
cp linux-amd64/ev ev &&
|
96
96
|
./ev upload --branch master \
|
97
97
|
--commit ${COMMITHASH} \
|
98
98
|
--out /tmp/out.txt \
|
99
99
|
--metrics /tmp/metrics.json \
|
100
|
-
--namespace ml-project-1
|
100
|
+
--namespace ml-project-1
|
101
101
|
```
|
102
102
|
|
103
103
|
## Development
|
data/ev_job_gen.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_dependency "dotenv", "~> 2.5.0"
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.16"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.7"
|
30
30
|
spec.add_development_dependency "pry"
|
31
31
|
spec.add_development_dependency "pry-doc"
|
@@ -14,6 +14,7 @@ spec:
|
|
14
14
|
suspend: false
|
15
15
|
successfulJobsHistoryLimit: 10
|
16
16
|
failedJobsHistoryLimit: 3
|
17
|
+
startingDeadlineSeconds: 300
|
17
18
|
jobTemplate:
|
18
19
|
metadata:
|
19
20
|
name: ev-job
|
@@ -30,4 +31,6 @@ spec:
|
|
30
31
|
name: ev-job
|
31
32
|
app: ev-job
|
32
33
|
role: job
|
34
|
+
annotations:
|
35
|
+
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
|
33
36
|
spec: <%= spec %>
|
@@ -8,19 +8,17 @@ containers:
|
|
8
8
|
- "/bin/bash"
|
9
9
|
- "-c"
|
10
10
|
- >
|
11
|
-
<%= job.command.
|
12
|
-
|
13
|
-
export
|
14
|
-
export
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
cp linux-amd64/ev ev;
|
20
|
-
|
11
|
+
<%= job.command.join(" && ") %> &&
|
12
|
+
export AWS_ACCESS_KEY_ID=<%= ENV['AWS_ACCESS_KEY_ID'] %> &&
|
13
|
+
export AWS_SECRET_ACCESS_KEY=<%= ENV['AWS_SECRET_ACCESS_KEY'] %> &&
|
14
|
+
export AWS_REGION=<%= ENV['AWS_REGION'] %> &&
|
15
|
+
<%= job.setup_wget %> &&
|
16
|
+
wget https://github.com/wantedly/ev-cli/releases/download/v1.2.3/ev-v1.2.3-linux-amd64.tar.gz &&
|
17
|
+
tar xvzf ev-v1.2.3-linux-amd64.tar.gz &&
|
18
|
+
cp linux-amd64/ev ev &&
|
21
19
|
./ev upload --branch master \
|
22
20
|
--commit <%= job.commithash %> \
|
23
21
|
--out <%= job.out %> \
|
24
22
|
--metrics <%= job.metrics %> \
|
25
|
-
--namespace <%= job.namespace
|
23
|
+
--namespace <%= job.namespace %>
|
26
24
|
<%= config.containers_envFrom(offset: 2) %>
|
data/lib/ev_job_gen.rb
CHANGED
data/lib/ev_job_gen/job.rb
CHANGED
@@ -13,12 +13,22 @@ module EvJobGen
|
|
13
13
|
@out = h["out"]
|
14
14
|
@metrics = h["metrics"]
|
15
15
|
@commithash = h["commithash"]
|
16
|
+
@setup_wget = h["setup_wget"] # NOTE: this is optional
|
16
17
|
|
17
18
|
# NOTE: suffix is used only for oneshot job
|
18
19
|
@suffix = 5.times.map { CHARS.sample }.join
|
19
20
|
end
|
20
21
|
|
21
|
-
attr_reader
|
22
|
+
attr_reader(
|
23
|
+
:namespace,
|
24
|
+
:image,
|
25
|
+
:command,
|
26
|
+
:out,
|
27
|
+
:metrics,
|
28
|
+
:commithash,
|
29
|
+
:setup_wget,
|
30
|
+
:suffix,
|
31
|
+
)
|
22
32
|
|
23
33
|
private
|
24
34
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'ev_job_gen/renderer/manifest_renderer'
|
2
|
+
require 'ev_job_gen/renderer/spec_renderer'
|
3
|
+
|
4
|
+
module EvJobGen
|
5
|
+
class Renderer
|
6
|
+
def initialize(template:, specoffset:, jobfile:, configfile:)
|
7
|
+
@template = template
|
8
|
+
@specoffset = specoffset
|
9
|
+
@job = EvJobGen::Job.new(jobfile)
|
10
|
+
@config = EvJobGen::Config.new(configfile)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
spec = SpecRenderer.new(
|
15
|
+
job: @job,
|
16
|
+
config: @config,
|
17
|
+
).render
|
18
|
+
|
19
|
+
r = ManifestRenderer.new(
|
20
|
+
template: @template,
|
21
|
+
job: @job,
|
22
|
+
spec: offset(spec, off: @specoffset + 2)
|
23
|
+
).render
|
24
|
+
|
25
|
+
normalize(r)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def normalize(text)
|
31
|
+
text.split("\n").map { |l| l.rstrip }.map { |l| "#{l}\n" }.join
|
32
|
+
end
|
33
|
+
|
34
|
+
def offset(text, off:)
|
35
|
+
"\n" + text.split("\n").map { |l| "#{' ' * off}#{l}\n" }.join
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module EvJobGen
|
4
|
+
class Renderer
|
5
|
+
class ManifestRenderer
|
6
|
+
def initialize(template:, job:, spec:)
|
7
|
+
@renderer = ERB.new(File.read(template))
|
8
|
+
@job = job
|
9
|
+
@spec = spec
|
10
|
+
end
|
11
|
+
attr_reader :job, :spec
|
12
|
+
|
13
|
+
def render
|
14
|
+
@renderer.result(binding) # Only use `job` and `spec`
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module EvJobGen
|
4
|
+
class Renderer
|
5
|
+
class SpecRenderer
|
6
|
+
class << self
|
7
|
+
def spec_template_path
|
8
|
+
File.expand_path(
|
9
|
+
File.join('kubernetes', 'tmpl', 'spec_template.yml.erb'),
|
10
|
+
EvJobGen.root,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(job:, config:)
|
16
|
+
@job = job
|
17
|
+
@config = config
|
18
|
+
@renderer = ERB.new(File.read(SpecRenderer.spec_template_path))
|
19
|
+
end
|
20
|
+
attr_reader :job, :config
|
21
|
+
|
22
|
+
def render
|
23
|
+
@renderer.result(binding) # Only use `job` and `config`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ev_job_gen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ev_job_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,13 +125,15 @@ files:
|
|
125
125
|
- lib/ev_job_gen/config.rb
|
126
126
|
- lib/ev_job_gen/job.rb
|
127
127
|
- lib/ev_job_gen/manifest_gen.rb
|
128
|
+
- lib/ev_job_gen/renderer.rb
|
129
|
+
- lib/ev_job_gen/renderer/manifest_renderer.rb
|
130
|
+
- lib/ev_job_gen/renderer/spec_renderer.rb
|
128
131
|
- lib/ev_job_gen/version.rb
|
129
|
-
- lib/ev_job_gen/yml_renderer.rb
|
130
132
|
homepage: https://github.com/wantedly/ev-job-gen
|
131
133
|
licenses:
|
132
134
|
- MIT
|
133
135
|
metadata: {}
|
134
|
-
post_install_message:
|
136
|
+
post_install_message:
|
135
137
|
rdoc_options: []
|
136
138
|
require_paths:
|
137
139
|
- lib
|
@@ -146,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
148
|
- !ruby/object:Gem::Version
|
147
149
|
version: '0'
|
148
150
|
requirements: []
|
149
|
-
|
150
|
-
|
151
|
-
signing_key:
|
151
|
+
rubygems_version: 3.0.3
|
152
|
+
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: Generator of kubernetes manifest file for evaluation job.
|
154
155
|
test_files: []
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module EvJobGen
|
5
|
-
class YmlRenderer
|
6
|
-
class << self
|
7
|
-
def spec_template_path
|
8
|
-
File.expand_path(
|
9
|
-
File.join('kubernetes', 'tmpl', 'spec_template.yml.erb'),
|
10
|
-
EvJobGen.root,
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(template:, specoffset:, jobfile:, configfile:)
|
16
|
-
@spec_renderer = ERB.new(File.read(YmlRenderer.spec_template_path))
|
17
|
-
@specoffset = specoffset
|
18
|
-
@renderer = ERB.new(File.read(template))
|
19
|
-
@job = EvJobGen::Job.new(jobfile)
|
20
|
-
@config = EvJobGen::Config.new(configfile)
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :job, :config
|
24
|
-
|
25
|
-
def render
|
26
|
-
spec = render_spec
|
27
|
-
@renderer.result(binding)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def render_spec
|
33
|
-
r = @spec_renderer.result(binding)
|
34
|
-
offset = @specoffset + 2
|
35
|
-
"\n" + r.split("\n").map { |l| "#{' ' * offset}#{l}\n" }.join
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|