cnvrg 0.0.15 → 0.0.140
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cnvrg.gemspec +5 -9
- data/lib/cnvrg/Images.rb +15 -76
- data/lib/cnvrg/api.rb +4 -7
- data/lib/cnvrg/cli.rb +527 -2149
- data/lib/cnvrg/experiment.rb +10 -19
- data/lib/cnvrg/files.rb +208 -302
- data/lib/cnvrg/helpers.rb +1 -42
- data/lib/cnvrg/job.rb +1 -0
- data/lib/cnvrg/project.rb +15 -55
- data/lib/cnvrg/version.rb +1 -2
- data/lib/cnvrg.rb +1 -0
- metadata +17 -48
- data/lib/cnvrg/data.rb +0 -72
- data/lib/cnvrg/datafiles.rb +0 -509
- data/lib/cnvrg/dataset.rb +0 -296
- data/lib/cnvrg/ssh.rb +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd32719858cd65bd5cc1a284f04ebcc727e2a83
|
4
|
+
data.tar.gz: ab592b0e08289acf21377a50aa53ce3feb8a83f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45bbf580911bc4c8dc14a88023e39019801a6d079093991d5a5960957f7a57d7241d340f3c8b74e949e35283e1423bf219599c7389b26eead581c79ea036c91d
|
7
|
+
data.tar.gz: 98369829234aeba876bcbebe69dec5993a7a4b4be6d04d5c7b479f42ab9dd050fb5a022e62f5c6dc2f2d8e22d8af50a183a935e411d8d3c581ad56b83a9b33d6
|
data/cnvrg.gemspec
CHANGED
@@ -34,15 +34,11 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency 'aws-sdk'
|
35
35
|
spec.add_runtime_dependency 'sucker_punch', '~> 2.0'
|
36
36
|
spec.add_runtime_dependency 'urlcrypt', '~> 0.1.1'
|
37
|
-
spec.add_runtime_dependency 'logstash-logger'
|
38
|
-
spec.add_runtime_dependency 'launchy'
|
39
|
-
spec.add_runtime_dependency 'docker-api'
|
40
|
-
spec.add_runtime_dependency 'rubyzip'
|
41
|
-
spec.add_runtime_dependency 'activesupport'
|
42
|
-
spec.add_runtime_dependency 'ruby-progressbar'
|
43
|
-
spec.add_runtime_dependency 'net-ssh'
|
44
|
-
|
45
|
-
|
37
|
+
spec.add_runtime_dependency 'logstash-logger'
|
38
|
+
spec.add_runtime_dependency 'launchy'
|
39
|
+
spec.add_runtime_dependency 'docker-api'
|
40
|
+
spec.add_runtime_dependency 'rubyzip'
|
41
|
+
spec.add_runtime_dependency 'activesupport'
|
46
42
|
|
47
43
|
|
48
44
|
end
|
data/lib/cnvrg/Images.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'cnvrg/files'
|
3
3
|
require 'docker'
|
4
|
-
require '
|
5
|
-
|
4
|
+
require 'pry'
|
6
5
|
|
7
6
|
module Cnvrg
|
8
7
|
class Images
|
@@ -48,6 +47,7 @@ module Cnvrg
|
|
48
47
|
end
|
49
48
|
|
50
49
|
rescue => e
|
50
|
+
puts e
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -95,73 +95,6 @@ module Cnvrg
|
|
95
95
|
|
96
96
|
|
97
97
|
end
|
98
|
-
def self.create_new_custom_image(type,owner,image_name,is_public,is_base,image_extend,python3)
|
99
|
-
response = Cnvrg::API.request("users/#{owner}/images/custom", 'POST', {instance_type:type,image_name:image_name,is_public:is_public,
|
100
|
-
is_base:is_base,image_extend:image_extend,
|
101
|
-
python3:python3})
|
102
|
-
return response
|
103
|
-
end
|
104
|
-
def self.revoke_custom_new_image(owner,slug)
|
105
|
-
response = Cnvrg::API.request("users/#{owner}/images/#{slug}/revoke_image", 'GET')
|
106
|
-
return response
|
107
|
-
end
|
108
|
-
def self.commit_custom_image(owner,slug)
|
109
|
-
response = Cnvrg::API.request("users/#{owner}/images/#{slug}/commit_custom_image", 'GET')
|
110
|
-
return response
|
111
|
-
end
|
112
|
-
def self.ssh_to_machine(resp)
|
113
|
-
|
114
|
-
sts_path = resp["result"]["sts_path"]
|
115
|
-
|
116
|
-
uri = URI.parse(sts_path)
|
117
|
-
|
118
|
-
http_object = Net::HTTP.new(uri.host, uri.port)
|
119
|
-
http_object.use_ssl = true if uri.scheme == 'https'
|
120
|
-
request = Net::HTTP::Get.new(sts_path)
|
121
|
-
|
122
|
-
body = ""
|
123
|
-
http_object.start do |http|
|
124
|
-
response = http.request request
|
125
|
-
body = response.read_body
|
126
|
-
end
|
127
|
-
|
128
|
-
URLcrypt::key = [body].pack('H*')
|
129
|
-
|
130
|
-
ip = URLcrypt.decrypt(resp["result"]["machine_i"])
|
131
|
-
|
132
|
-
user = URLcrypt.decrypt(resp["result"]["machine_u"])
|
133
|
-
key = URLcrypt.decrypt(resp["result"]["machine_k"])
|
134
|
-
tempssh = Tempfile.new "sshkey"
|
135
|
-
tempssh.write open(key).read
|
136
|
-
tempssh.rewind
|
137
|
-
key_path = tempssh.path
|
138
|
-
count = 0
|
139
|
-
while count < 5
|
140
|
-
|
141
|
-
begin
|
142
|
-
ssh = Net::SSH.start(ip, user=user, :keys => key_path, :timeout => 10)
|
143
|
-
if !ssh.nil?
|
144
|
-
return ssh
|
145
|
-
else
|
146
|
-
count+=1
|
147
|
-
sleep(2)
|
148
|
-
|
149
|
-
end
|
150
|
-
rescue
|
151
|
-
count+=1
|
152
|
-
sleep(2)
|
153
|
-
|
154
|
-
|
155
|
-
end
|
156
|
-
end
|
157
|
-
if tempssh
|
158
|
-
tempssh.close
|
159
|
-
tempssh.unlink
|
160
|
-
end
|
161
|
-
return false
|
162
|
-
end
|
163
|
-
|
164
|
-
|
165
98
|
|
166
99
|
def create_custom_image(new_image_name,working_dir,stored_commands)
|
167
100
|
|
@@ -241,10 +174,9 @@ module Cnvrg
|
|
241
174
|
def create_container(port=7654, is_remote=false)
|
242
175
|
begin
|
243
176
|
image_settings = {
|
244
|
-
'Image' => "#{@image_name}
|
177
|
+
'Image' => "#{@image_name}:#{@image_tag}",
|
245
178
|
'User' => 'ds',
|
246
|
-
'Cmd' => '/
|
247
|
-
'WorkingDir' => '/home/ds/notebooks',
|
179
|
+
'Cmd' => '/home/ds/run_ipython.sh',
|
248
180
|
'ExposedPorts' => {
|
249
181
|
'8888/tcp' => {},
|
250
182
|
},
|
@@ -257,6 +189,9 @@ module Cnvrg
|
|
257
189
|
},
|
258
190
|
},
|
259
191
|
}
|
192
|
+
# if !is_remote
|
193
|
+
# image_settings['HostConfig'].merge!({ 'Binds' => ["#{@working_dir}:/home/ds/notebooks"]})
|
194
|
+
# end
|
260
195
|
container = Docker::Container.create(image_settings)
|
261
196
|
container.start()
|
262
197
|
netrc = File.open(File.expand_path('~')+"/.netrc", "rb")
|
@@ -266,6 +201,10 @@ module Cnvrg
|
|
266
201
|
p = container.exec(command, tty: true)
|
267
202
|
command = ["/bin/bash", "-lc", "sudo chown -R ds /home/ds/.netrc"]
|
268
203
|
p = container.exec(command, tty: true)
|
204
|
+
command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg"]
|
205
|
+
container.exec(command, tty: true)
|
206
|
+
command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg/tmp"]
|
207
|
+
container.exec(command, tty: true)
|
269
208
|
config = File.open(File.expand_path('~')+"/.cnvrg/config.yml", "rb")
|
270
209
|
config_content = config.read
|
271
210
|
container.store_file("/home/ds/.cnvrg/config.yml", config_content)
|
@@ -288,6 +227,7 @@ module Cnvrg
|
|
288
227
|
if e.message.include? "is not running"
|
289
228
|
return create_container(port-1)
|
290
229
|
end
|
230
|
+
puts e
|
291
231
|
return false
|
292
232
|
rescue SignalException
|
293
233
|
|
@@ -307,18 +247,17 @@ module Cnvrg
|
|
307
247
|
File.open(@working_dir+"/.cnvrg/pip_base.txt", "w+") { |f| f.write pip }
|
308
248
|
File.open(@working_dir+"/.cnvrg/dpkg_base.txt", "w+") { |f| f.write dpkg }
|
309
249
|
rescue => e
|
250
|
+
puts e
|
310
251
|
end
|
311
252
|
|
312
253
|
|
313
254
|
end
|
314
255
|
|
315
|
-
def remote_notebook(notebook_path, instance_type, kernel
|
256
|
+
def remote_notebook(notebook_path, instance_type, kernel)
|
316
257
|
response = Cnvrg::API.request("users/#{@owner}/images/#{@image_slug}/remote_notebook", 'POST', {dir: notebook_path,
|
317
258
|
project_slug: @project_slug,
|
318
259
|
instance_type: instance_type,
|
319
|
-
kernel: kernel
|
320
|
-
dataset_slug:data,
|
321
|
-
dataset_commit: data_commit})
|
260
|
+
kernel: kernel})
|
322
261
|
return response
|
323
262
|
end
|
324
263
|
|
data/lib/cnvrg/api.rb
CHANGED
@@ -57,10 +57,7 @@ module Cnvrg
|
|
57
57
|
else
|
58
58
|
response
|
59
59
|
end
|
60
|
-
|
61
|
-
conn.options.timeout = 420
|
62
|
-
conn.options.open_timeout =420
|
63
|
-
|
60
|
+
when 'POST'
|
64
61
|
response = conn.post "#{endpoint_uri}/#{resource}", data
|
65
62
|
|
66
63
|
if parse_request == true
|
@@ -73,12 +70,12 @@ module Cnvrg
|
|
73
70
|
fr.headers['Auth-Token'] = @pass
|
74
71
|
fr.headers['User-Agent'] = "#{Cnvrg::API::USER_AGENT}"
|
75
72
|
fr.headers["Content-Type"] = "multipart/form-data"
|
76
|
-
|
73
|
+
|
77
74
|
fr.request :multipart
|
78
75
|
fr.request :url_encoded
|
79
76
|
fr.adapter :net_http
|
80
77
|
end
|
81
|
-
|
78
|
+
|
82
79
|
|
83
80
|
# what if windows?
|
84
81
|
# data[:file] = Faraday::UploadIO.new(data[:absolute_path], content_type)
|
@@ -107,7 +104,7 @@ module Cnvrg
|
|
107
104
|
else
|
108
105
|
end
|
109
106
|
rescue => e
|
110
|
-
|
107
|
+
puts e
|
111
108
|
return nil
|
112
109
|
end
|
113
110
|
|