cnvrg 0.0.140 → 0.0.141
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cnvrg/Images.rb +0 -1
- data/lib/cnvrg/cli.rb +201 -100
- data/lib/cnvrg/files.rb +4 -2
- data/lib/cnvrg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926f82dfe1bfcf71e51c1218b90c197dcd9ee717
|
4
|
+
data.tar.gz: 87668443ad37a85c376c92c38599a23b2475e036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7996005a060813f1b2405a60b020bcc6ea56cc97ea8f165e903958a588a2de4178f7588ac64bbc4a5a2dbde43deeccd49fe959b065905e85171cef8a2d0cd51
|
7
|
+
data.tar.gz: c9ce755b4f9e3ed0a2d400c3d7bbe3a14f318a1b8fed87b9fd31d8facda64cca78e28d75de923d7d23cb97b465afb620b95463570a98354aa0f03887ee137d25
|
data/lib/cnvrg/Images.rb
CHANGED
data/lib/cnvrg/cli.rb
CHANGED
@@ -29,7 +29,6 @@ require 'fileutils'
|
|
29
29
|
require 'zip'
|
30
30
|
require 'active_support/all'
|
31
31
|
require 'thor'
|
32
|
-
require 'pry'
|
33
32
|
|
34
33
|
# DEV VERSION
|
35
34
|
#
|
@@ -246,15 +245,30 @@ module Cnvrg
|
|
246
245
|
owners << choose_owner
|
247
246
|
chosen = false
|
248
247
|
while !chosen
|
249
|
-
|
248
|
+
owners_id = owners.each_with_index.map{|x,i| "#{i+1}. #{x}"}
|
249
|
+
choose_owner = ask("Choose default owner:\n"+owners_id.join("\n")+"\n")
|
250
|
+
|
251
|
+
if choose_owner =~ /[[:digit:]]/
|
252
|
+
ow_index = choose_owner.to_i-1
|
253
|
+
if ow_index<0 or ow_index >= owners.size
|
254
|
+
say "No such owner, please choose again", Thor::Shell::Color::BLUE
|
255
|
+
chosen = false
|
256
|
+
next
|
257
|
+
end
|
258
|
+
choose_owner = owners[choose_owner.to_i-1]
|
259
|
+
chosen = true
|
250
260
|
|
251
|
-
owners_lower = owners.map { |o| o.downcase }
|
252
|
-
ow_index = owners_lower.index(choose_owner.downcase)
|
253
|
-
if ow_index.nil?
|
254
|
-
say "Could not find owner named #{choose_owner}", Thor::Shell::Color::RED
|
255
261
|
else
|
256
|
-
|
262
|
+
|
263
|
+
owners_lower = owners.map { |o| o.downcase }
|
264
|
+
ow_index = owners_lower.index(choose_owner.downcase)
|
265
|
+
if ow_index.nil?
|
266
|
+
say "Could not find owner named #{choose_owner}", Thor::Shell::Color::RED
|
267
|
+
else
|
268
|
+
chosen = true
|
269
|
+
end
|
257
270
|
end
|
271
|
+
|
258
272
|
end
|
259
273
|
|
260
274
|
|
@@ -274,6 +288,11 @@ module Cnvrg
|
|
274
288
|
|
275
289
|
exit(1)
|
276
290
|
end
|
291
|
+
rescue
|
292
|
+
|
293
|
+
say "Error Occurred, aborting", Thor::Shell::Color::RED
|
294
|
+
logout()
|
295
|
+
exit(1)
|
277
296
|
rescue SignalException
|
278
297
|
|
279
298
|
say "\nAborting"
|
@@ -393,8 +412,8 @@ module Cnvrg
|
|
393
412
|
say "created project successfully", Thor::Shell::Color::GREEN
|
394
413
|
say "Linked directory to\t#{@project.url}", Thor::Shell::Color::GREEN
|
395
414
|
rescue => e
|
396
|
-
|
397
|
-
|
415
|
+
log_end(-1,e.message)
|
416
|
+
say "Error occurred, aborting", Thor::Shell::Color::RED
|
398
417
|
if Dir.exist? working_dir
|
399
418
|
|
400
419
|
@project.revert(working_dir)
|
@@ -821,7 +840,7 @@ module Cnvrg
|
|
821
840
|
say "User aborted, Rolling Back all changes.", Thor::Shell::Color::RED
|
822
841
|
exit(0)
|
823
842
|
rescue => e
|
824
|
-
log_end(1, e.message)
|
843
|
+
log_end(-1, e.message)
|
825
844
|
@files.rollback_commit(commit_sha1)
|
826
845
|
say "Exception while trying to upload, Rolling back", Thor::Shell::Color::RED
|
827
846
|
exit(0)
|
@@ -835,7 +854,7 @@ module Cnvrg
|
|
835
854
|
|
836
855
|
@project.update_idx_with_commit!(commit_sha1)
|
837
856
|
rescue => e
|
838
|
-
log_end(1, e.message)
|
857
|
+
log_end(-1, e.message)
|
839
858
|
@files.rollback_commit(commit_sha1)
|
840
859
|
say "Couldn't commit updates, Rolling Back all changes.", Thor::Shell::Color::RED
|
841
860
|
exit(1)
|
@@ -1026,6 +1045,7 @@ module Cnvrg
|
|
1026
1045
|
if !response["result"]["tree"].nil?
|
1027
1046
|
idx = {commit: response["result"]["commit"], tree: response["result"]["tree"]}
|
1028
1047
|
File.open(project_home + "/.cnvrg/idx.yml", "w+") { |f| f.write idx.to_yaml }
|
1048
|
+
current_tree = Dir.entries(".").reject { |file| file.start_with? '.' or file.eql? "__init__.py" or file.eql? "uwsgi.ini" }
|
1029
1049
|
|
1030
1050
|
response["result"]["tree"].each do |f|
|
1031
1051
|
relative_path = f[0].gsub(/^#{@project.local_path}/, "")
|
@@ -1077,21 +1097,21 @@ module Cnvrg
|
|
1077
1097
|
|
1078
1098
|
|
1079
1099
|
desc 'run cmd', 'Runs an experiment'
|
1080
|
-
method_option :local, :type => :boolean, :aliases => ["
|
1081
|
-
method_option :small, :type => :boolean, :aliases => ["
|
1082
|
-
method_option :medium, :type => :boolean, :aliases => ["--
|
1083
|
-
method_option :large, :type => :boolean, :aliases => ["
|
1100
|
+
method_option :local, :type => :boolean, :aliases => ["-l"], :default => false
|
1101
|
+
method_option :small, :type => :boolean, :aliases => ["-sm", "--small"], :default => false
|
1102
|
+
method_option :medium, :type => :boolean, :aliases => ["-md","--medium"], :default => false
|
1103
|
+
method_option :large, :type => :boolean, :aliases => ["-lg","--large"], :default => false
|
1084
1104
|
method_option :gpu, :type => :boolean, :aliases => ["--gpu"], :default => false
|
1085
|
-
method_option :gpuxl, :type => :boolean, :aliases => ["--
|
1086
|
-
method_option :sync_before, :type => :boolean, :aliases => ["
|
1087
|
-
method_option :sync_after, :type => :boolean, :aliases => ["
|
1088
|
-
method_option :title, :type => :string, :aliases => ["
|
1105
|
+
method_option :gpuxl, :type => :boolean, :aliases => ["--gpuxl"], :default => false
|
1106
|
+
method_option :sync_before, :type => :boolean, :aliases => ["-sb"], :default => true
|
1107
|
+
method_option :sync_after, :type => :boolean, :aliases => ["-sa"], :default => true
|
1108
|
+
method_option :title, :type => :string, :aliases => ["-t"], :default => ""
|
1089
1109
|
method_option :log, :type => :boolean, :aliases => ["--log"], :default => false
|
1090
|
-
method_option :email_notification, :type => :boolean, :aliases => ["
|
1091
|
-
method_option :upload_output, :type => :string, :aliases => ["
|
1092
|
-
method_option :commit, :type => :string, :aliases => ["
|
1093
|
-
method_option :schedule, :type => :string, :aliases => ["
|
1094
|
-
method_option :image, :type => :string, :aliases => ["
|
1110
|
+
method_option :email_notification, :type => :boolean, :aliases => ["-en"], :default => false
|
1111
|
+
method_option :upload_output, :type => :string, :aliases => ["-uo"], :default => ""
|
1112
|
+
method_option :commit, :type => :string, :aliases => ["-c"], :default => ""
|
1113
|
+
method_option :schedule, :type => :string, :aliases => ["-s"], :default => ""
|
1114
|
+
method_option :image, :type => :string, :aliases => ["-i"], :default => ""
|
1095
1115
|
|
1096
1116
|
def run(*cmd)
|
1097
1117
|
sync_before = options["sync_before"]
|
@@ -1119,14 +1139,14 @@ module Cnvrg
|
|
1119
1139
|
|
1120
1140
|
|
1121
1141
|
desc '', ''
|
1122
|
-
method_option :sync_before, :type => :boolean, :aliases => ["-sb"
|
1123
|
-
method_option :sync_after, :type => :boolean, :aliases => ["-sa"
|
1124
|
-
method_option :title, :type => :string, :aliases => ["-t"
|
1125
|
-
method_option :log, :type => :boolean, :aliases => ["-l", "--
|
1126
|
-
method_option :email_notification, :type => :boolean, :aliases => ["-en"
|
1127
|
-
method_option :upload_output, :type => :string, :aliases => [
|
1128
|
-
method_option :commit, :type => :string, :aliases => ["
|
1129
|
-
method_option :image, :type => :string, :aliases => ["
|
1142
|
+
method_option :sync_before, :type => :boolean, :aliases => ["-sb"], :default => true
|
1143
|
+
method_option :sync_after, :type => :boolean, :aliases => ["-sa"], :default => true
|
1144
|
+
method_option :title, :type => :string, :aliases => ["-t"], :default => ""
|
1145
|
+
method_option :log, :type => :boolean, :aliases => ["-l", "--log"], :default => false
|
1146
|
+
method_option :email_notification, :type => :boolean, :aliases => ["-en"], :default => false
|
1147
|
+
method_option :upload_output, :type => :string, :aliases => [ "-uo"], :default => ""
|
1148
|
+
method_option :commit, :type => :string, :aliases => ["-c"], :default => ""
|
1149
|
+
method_option :image, :type => :string, :aliases => ["-i"], :default => ""
|
1130
1150
|
method_option :indocker, :type => :boolean, :default => false
|
1131
1151
|
|
1132
1152
|
def exec(*cmd)
|
@@ -1258,7 +1278,6 @@ module Cnvrg
|
|
1258
1278
|
end
|
1259
1279
|
|
1260
1280
|
rescue Errno::EIO => e
|
1261
|
-
puts e
|
1262
1281
|
# break
|
1263
1282
|
rescue Errno::ENOENT
|
1264
1283
|
log_end(1, "command #{cmd} isn't valid")
|
@@ -1271,8 +1290,9 @@ module Cnvrg
|
|
1271
1290
|
exp_success = false
|
1272
1291
|
say "The process exited!", Thor::Shell::Color::RED
|
1273
1292
|
rescue => e
|
1274
|
-
|
1275
|
-
|
1293
|
+
log_end(-1, e.message)
|
1294
|
+
say "Error occurred,aborting", Thor::Shell::Color::RED
|
1295
|
+
exit(0)
|
1276
1296
|
end
|
1277
1297
|
::Process.wait pid
|
1278
1298
|
cpu_average = cpu_total.inject(0) { |sum, el| sum + el }.to_f / cpu_total.size
|
@@ -1310,7 +1330,7 @@ module Cnvrg
|
|
1310
1330
|
invoke :sync, [], :new_branch => true
|
1311
1331
|
|
1312
1332
|
else
|
1313
|
-
invoke :sync, [], :new_branch =>
|
1333
|
+
invoke :sync, [], :new_branch => false
|
1314
1334
|
end
|
1315
1335
|
end
|
1316
1336
|
end_commit = @project.last_local_commit
|
@@ -1321,8 +1341,7 @@ module Cnvrg
|
|
1321
1341
|
log_end(0)
|
1322
1342
|
end
|
1323
1343
|
rescue => e
|
1324
|
-
|
1325
|
-
log_end(1, e.message)
|
1344
|
+
log_end(-1, e.message)
|
1326
1345
|
if container
|
1327
1346
|
container.stop()
|
1328
1347
|
end
|
@@ -1458,7 +1477,9 @@ module Cnvrg
|
|
1458
1477
|
exp_success = false
|
1459
1478
|
say "The process exited!", Thor::Shell::Color::RED
|
1460
1479
|
rescue => e
|
1461
|
-
log_end(1, e.message)
|
1480
|
+
log_end(-1, e.message)
|
1481
|
+
say "Error occurred, aborting", Thor::Shell::Color::RED
|
1482
|
+
exit(0)
|
1462
1483
|
end
|
1463
1484
|
::Process.wait pid
|
1464
1485
|
cpu_average = cpu_total.inject(0) { |sum, el| sum + el }.to_f / cpu_total.size
|
@@ -1508,7 +1529,7 @@ module Cnvrg
|
|
1508
1529
|
log_end(0)
|
1509
1530
|
end
|
1510
1531
|
rescue => e
|
1511
|
-
log_end(1, e.message)
|
1532
|
+
log_end(-1, e.message)
|
1512
1533
|
say "Couldn't run #{cmd}, check your input parameters", Thor::Shell::Color::RED
|
1513
1534
|
exit(1)
|
1514
1535
|
end
|
@@ -1533,16 +1554,16 @@ module Cnvrg
|
|
1533
1554
|
end
|
1534
1555
|
|
1535
1556
|
desc '', ''
|
1536
|
-
method_option :sync_before, :type => :boolean, :aliases => ["-sb"
|
1537
|
-
method_option :sync_after, :type => :boolean, :aliases => ["-sa"
|
1538
|
-
method_option :title, :type => :string, :aliases => ["-t"
|
1539
|
-
method_option :log, :type => :boolean, :aliases => ["-l", "--
|
1540
|
-
method_option :email_notification, :type => :boolean, :aliases => ["-en"
|
1541
|
-
method_option :upload_output, :type => :string, :aliases => ["
|
1542
|
-
method_option :machine_type, :type => :string, :
|
1543
|
-
method_option :schedule, :type => :string, :aliases => [
|
1544
|
-
method_option :commit, :type => :string, :aliases => [
|
1545
|
-
method_option :image, :type => :string, :aliases => ["
|
1557
|
+
method_option :sync_before, :type => :boolean, :aliases => ["-sb"], :default => true
|
1558
|
+
method_option :sync_after, :type => :boolean, :aliases => ["-sa"], :default => true
|
1559
|
+
method_option :title, :type => :string, :aliases => ["-t"], :default => ""
|
1560
|
+
method_option :log, :type => :boolean, :aliases => ["-l", "--log"], :default => false
|
1561
|
+
method_option :email_notification, :type => :boolean, :aliases => ["-en"], :default => false
|
1562
|
+
method_option :upload_output, :type => :string, :aliases => ["-uo"], :default => ""
|
1563
|
+
method_option :machine_type, :type => :string, :default => ""
|
1564
|
+
method_option :schedule, :type => :string, :aliases => [ "-s"], :default => ""
|
1565
|
+
method_option :commit, :type => :string, :aliases => [ "-c"], :default => nil
|
1566
|
+
method_option :image, :type => :string, :aliases => ["-i"], :default => ""
|
1546
1567
|
|
1547
1568
|
def exec_remote(*cmd)
|
1548
1569
|
verify_logged_in(true)
|
@@ -1570,10 +1591,17 @@ module Cnvrg
|
|
1570
1591
|
new_time = new_time[0, new_time.size-6] #remove timezone
|
1571
1592
|
schedule = "at #{new_time}"
|
1572
1593
|
end
|
1594
|
+
upload_output = options["upload_output"]
|
1595
|
+
time_to_upload = calc_output_time(upload_output)
|
1596
|
+
if time_to_upload==0 or time_to_upload==-1
|
1597
|
+
upload_output_option = "--upload_output=1m"
|
1598
|
+
else
|
1599
|
+
upload_output_option = "--upload_output=#{upload_output}"
|
1600
|
+
end
|
1573
1601
|
options_hash = Hash[options]
|
1574
|
-
options_hash.except!("schedule", "machine_type", "image")
|
1602
|
+
options_hash.except!("schedule", "machine_type", "image", "upload_output")
|
1575
1603
|
exec_options = options_hash.map { |x| "--#{x[0]}=#{x[1]}" }.flatten.join(" ")
|
1576
|
-
command = "#{exec_options}
|
1604
|
+
command = "#{exec_options} #{upload_output_option} #{cmd.flatten.join(" ")}"
|
1577
1605
|
commit_to_run = options["commit"] || nil
|
1578
1606
|
if !schedule.nil? and !schedule.empty?
|
1579
1607
|
|
@@ -1589,14 +1617,15 @@ module Cnvrg
|
|
1589
1617
|
image = is_project_with_docker(working_dir)
|
1590
1618
|
if !image or !image.is_docker
|
1591
1619
|
# say "Couldn't find image related to project", Thor::Shell::Color::RED
|
1592
|
-
|
1620
|
+
|
1621
|
+
image_slug = "cnvrg"
|
1593
1622
|
if instance_type.eql? "gpu" or instance_type.eql? "gpuxl"
|
1594
|
-
|
1623
|
+
image_slug = "cnvrg_gpu"
|
1595
1624
|
end
|
1596
1625
|
# default = yes? "use #{default_image_name} default image?", Thor::Shell::Color::YELLOW
|
1597
1626
|
# if default
|
1598
|
-
|
1599
|
-
|
1627
|
+
# image = Images.new(working_dir, default_image_name)
|
1628
|
+
# image_slug = image.image_slug
|
1600
1629
|
# else
|
1601
1630
|
# exit(0)
|
1602
1631
|
# end
|
@@ -1763,27 +1792,30 @@ module Cnvrg
|
|
1763
1792
|
|
1764
1793
|
method_option :kernel, :type => :string, :aliases => ["--k", "-k"], :default => ""
|
1765
1794
|
method_option :notebook_dir, :type => :string, :aliases => ["-n", "--n"], :default => "", :desc => "relative path to notebook dir from current directory"
|
1766
|
-
method_option :local, :type => :boolean, :aliases => ["
|
1767
|
-
method_option :small, :type => :boolean, :aliases => ["
|
1768
|
-
method_option :medium, :type => :boolean, :aliases => ["--
|
1769
|
-
method_option :large, :type => :boolean, :aliases => ["
|
1795
|
+
method_option :local, :type => :boolean, :aliases => ["-l"], :default => false
|
1796
|
+
method_option :small, :type => :boolean, :aliases => ["-sm","--small"], :default => false
|
1797
|
+
method_option :medium, :type => :boolean, :aliases => ["-md","--medium"], :default => false
|
1798
|
+
method_option :large, :type => :boolean, :aliases => ["-lg","--large"], :default => false
|
1770
1799
|
method_option :gpu, :type => :boolean, :aliases => ["--gpu"], :default => false
|
1771
|
-
method_option :gpuxl, :type => :boolean, :aliases => ["--
|
1800
|
+
method_option :gpuxl, :type => :boolean, :aliases => ["--gpuxl"], :default => false
|
1801
|
+
method_option :image, :type => :string, :aliases => ["--i"], :default => ""
|
1802
|
+
|
1772
1803
|
desc 'starts a notebook session', 'starts a notebook session remotely or locally'
|
1773
1804
|
|
1774
1805
|
def notebook()
|
1775
1806
|
local = options["local"]
|
1776
1807
|
notebook_dir = options["notebook_dir"]
|
1777
1808
|
kernel = options["kernel"]
|
1809
|
+
image = options["image"]
|
1778
1810
|
|
1779
1811
|
if local
|
1780
|
-
invoke :run_notebook, [], :notebook_dir => notebook_dir, :remote => false, :kernel => kernel
|
1812
|
+
invoke :run_notebook, [], :notebook_dir => notebook_dir, :remote => false, :kernel => kernel,:image =>image
|
1781
1813
|
return
|
1782
1814
|
else
|
1783
1815
|
instances = {"small" => options["small"], "medium" => options["medium"], "large" => options["large"], "gpu" => options["gpu"], "gpuxl" => options["gpuxl"]}
|
1784
1816
|
instance_type = get_instance_type(instances)
|
1785
1817
|
|
1786
|
-
invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type
|
1818
|
+
invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type, :image =>image
|
1787
1819
|
return
|
1788
1820
|
|
1789
1821
|
end
|
@@ -1792,10 +1824,10 @@ module Cnvrg
|
|
1792
1824
|
end
|
1793
1825
|
|
1794
1826
|
desc 'remote_notebook', 'run notebook server on remote server'
|
1795
|
-
method_option :notebook_dir, :type => :string, :aliases => ["-n"
|
1796
|
-
method_option :machine_type, :type => :string,
|
1797
|
-
method_option :kernel, :type => :string, :aliases => ["--
|
1798
|
-
method_option :image, :type => :string, :aliases => ["
|
1827
|
+
method_option :notebook_dir, :type => :string, :aliases => ["-n"], :default => "", :desc => "relative path to notebook dir from current directory"
|
1828
|
+
method_option :machine_type, :type => :string, :default => ""
|
1829
|
+
method_option :kernel, :type => :string, :aliases => ["--kernel", "-k"], :default => ""
|
1830
|
+
method_option :image, :type => :string, :aliases => ["-i"], :default => ""
|
1799
1831
|
|
1800
1832
|
|
1801
1833
|
def remote_notebook()
|
@@ -1941,9 +1973,8 @@ module Cnvrg
|
|
1941
1973
|
|
1942
1974
|
end
|
1943
1975
|
rescue => e
|
1944
|
-
|
1945
|
-
|
1946
|
-
say "Error occurd, Aborting"
|
1976
|
+
log_end(-1, e.message)
|
1977
|
+
say "Error occurred, aborting",Thor::Shell::Color::RED
|
1947
1978
|
if container
|
1948
1979
|
container.stop()
|
1949
1980
|
end
|
@@ -2004,9 +2035,8 @@ module Cnvrg
|
|
2004
2035
|
end
|
2005
2036
|
end
|
2006
2037
|
rescue => e
|
2007
|
-
|
2008
|
-
|
2009
|
-
say "Error occurd, Aborting"
|
2038
|
+
log_end(-1, e.message)
|
2039
|
+
say "Error occurred, aborting"
|
2010
2040
|
if container
|
2011
2041
|
container.stop()
|
2012
2042
|
end
|
@@ -2023,6 +2053,7 @@ module Cnvrg
|
|
2023
2053
|
method_option :remote, :type => :boolean, :aliases => ["-r", "--r"], :default => false, :desc => "run on remote machine"
|
2024
2054
|
method_option :kernel, :type => :string, :aliases => ["-k", "--k"], :default => "", :desc => "default kernel"
|
2025
2055
|
method_option :verbose, :type => :boolean, :aliases => ["--v"], :default => false
|
2056
|
+
method_option :image, :type => :string, :aliases => ["-i"], :default => ""
|
2026
2057
|
|
2027
2058
|
def run_notebook
|
2028
2059
|
|
@@ -2045,6 +2076,11 @@ module Cnvrg
|
|
2045
2076
|
notebook_dir = project_dir+ notebook_dir
|
2046
2077
|
end
|
2047
2078
|
say "Linking notebook directory to: #{File.basename notebook_dir}", Thor::Shell::Color::BLUE
|
2079
|
+
choose_image = options["image"]
|
2080
|
+
|
2081
|
+
if !choose_image.nil? and !choose_image.empty?
|
2082
|
+
invoke :set_image,[choose_image]
|
2083
|
+
end
|
2048
2084
|
image = is_project_with_docker(Dir.pwd)
|
2049
2085
|
if image and image.is_docker and !remote
|
2050
2086
|
container= image.get_container
|
@@ -2132,8 +2168,7 @@ module Cnvrg
|
|
2132
2168
|
# exit(1)
|
2133
2169
|
# end
|
2134
2170
|
rescue => e
|
2135
|
-
log_end(-1)
|
2136
|
-
puts e
|
2171
|
+
log_end(-1,e.message)
|
2137
2172
|
say "Error occurd, aborting", Thor::Shell::Color::RED
|
2138
2173
|
if container
|
2139
2174
|
container.stop()
|
@@ -2210,8 +2245,7 @@ module Cnvrg
|
|
2210
2245
|
exit(0)
|
2211
2246
|
end
|
2212
2247
|
rescue => e
|
2213
|
-
|
2214
|
-
log_end(-1)
|
2248
|
+
log_end(-1,e.message)
|
2215
2249
|
say "Error occurd, aborting"
|
2216
2250
|
if container
|
2217
2251
|
container.stop()
|
@@ -2261,8 +2295,7 @@ module Cnvrg
|
|
2261
2295
|
|
2262
2296
|
log_end(0)
|
2263
2297
|
rescue => e
|
2264
|
-
log_end(-1)
|
2265
|
-
puts e
|
2298
|
+
log_end(-1,e.message)
|
2266
2299
|
say "Error occurd, aborting"
|
2267
2300
|
if container
|
2268
2301
|
container.stop()
|
@@ -2325,8 +2358,7 @@ module Cnvrg
|
|
2325
2358
|
|
2326
2359
|
log_end(0)
|
2327
2360
|
rescue => e
|
2328
|
-
log_end(-1)
|
2329
|
-
puts e
|
2361
|
+
log_end(-1,e.message)
|
2330
2362
|
say "Error occurd, aborting"
|
2331
2363
|
if container
|
2332
2364
|
container.stop()
|
@@ -2402,8 +2434,7 @@ module Cnvrg
|
|
2402
2434
|
|
2403
2435
|
log_end(0)
|
2404
2436
|
rescue => e
|
2405
|
-
log_end(-1)
|
2406
|
-
puts e
|
2437
|
+
log_end(-1,e.message)
|
2407
2438
|
say "Error occurd, aborting", Thor::Shell::Color::RED
|
2408
2439
|
if container
|
2409
2440
|
container.stop()
|
@@ -2452,8 +2483,9 @@ module Cnvrg
|
|
2452
2483
|
log_end(0)
|
2453
2484
|
return new_image.id
|
2454
2485
|
rescue => e
|
2455
|
-
|
2456
|
-
|
2486
|
+
log_end(-1,e.message)
|
2487
|
+
say "\nError occurred,aborting"
|
2488
|
+
exit(1)
|
2457
2489
|
rescue SignalException
|
2458
2490
|
log_end(-1)
|
2459
2491
|
say "\nAborting"
|
@@ -2529,7 +2561,9 @@ module Cnvrg
|
|
2529
2561
|
say "Image was updated successfully", Thor::Shell::Color::GREEN
|
2530
2562
|
end
|
2531
2563
|
rescue => e
|
2532
|
-
|
2564
|
+
log_end(-1,e.message)
|
2565
|
+
say "error occurred, aborting"
|
2566
|
+
|
2533
2567
|
end
|
2534
2568
|
end
|
2535
2569
|
|
@@ -2591,8 +2625,8 @@ module Cnvrg
|
|
2591
2625
|
exit(1)
|
2592
2626
|
end
|
2593
2627
|
rescue => e
|
2594
|
-
|
2595
|
-
|
2628
|
+
log_end(-1,e.message)
|
2629
|
+
say "Couldn't upload image file for: #{image_name}", Thor::Shell::Color::RED
|
2596
2630
|
rescue SignalException
|
2597
2631
|
log_end(-1)
|
2598
2632
|
|
@@ -2646,7 +2680,7 @@ module Cnvrg
|
|
2646
2680
|
method_option :cmd, :type => :string, :aliases => ["-c", "--c"], :default => "/usr/local/cnvrg/run_ipython.sh"
|
2647
2681
|
|
2648
2682
|
|
2649
|
-
def config_remote(image_name, port=7654)
|
2683
|
+
def config_remote(image_name, port=7654,tensport=6006)
|
2650
2684
|
local_images = Docker::Image.all
|
2651
2685
|
|
2652
2686
|
docker_image_local = local_images.map { |x| x.info["RepoTags"] }.flatten.select { |y| y.eql? "#{image_name}:latest" }.flatten
|
@@ -2673,6 +2707,9 @@ module Cnvrg
|
|
2673
2707
|
'8888/tcp' => [
|
2674
2708
|
{'HostPort' => "#{port}", 'HostIp' => 'localhost'}
|
2675
2709
|
],
|
2710
|
+
'6006/tcp' => [
|
2711
|
+
{'HostPort' => "#{tensport}", 'HostIp' => 'localhost'}
|
2712
|
+
],
|
2676
2713
|
},
|
2677
2714
|
},
|
2678
2715
|
}
|
@@ -2688,13 +2725,79 @@ module Cnvrg
|
|
2688
2725
|
container.exec(command, tty: true)
|
2689
2726
|
command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
|
2690
2727
|
container.exec(command, tty: true)
|
2691
|
-
say "#{container.id}:#{port}"
|
2728
|
+
say "#{container.id}:#{port}##{tensport}"
|
2692
2729
|
rescue => e
|
2693
2730
|
if e.message.include? "is not running"
|
2694
|
-
return config_remote(image_name, port-1)
|
2731
|
+
return config_remote(image_name, port-1,tensport-1)
|
2695
2732
|
end
|
2696
|
-
|
2697
|
-
|
2733
|
+
|
2734
|
+
if container
|
2735
|
+
container.kill()
|
2736
|
+
end
|
2737
|
+
return false
|
2738
|
+
end
|
2739
|
+
end
|
2740
|
+
desc '', ''
|
2741
|
+
method_option :login, :type => :string, :aliases => ["-l", "--l"], :default => ""
|
2742
|
+
method_option :app_dir, :type => :string, :aliases => ["-d", "--d"], :default => "/home/ds/notebooks"
|
2743
|
+
method_option :cmd, :type => :string, :aliases => ["-c", "--c"], :default => "/usr/local/cnvrg/run_ipython.sh"
|
2744
|
+
|
2745
|
+
|
2746
|
+
def config_remote_gpu(image_name, port=7654,tensport=6006)
|
2747
|
+
local_images = Docker::Image.all
|
2748
|
+
|
2749
|
+
docker_image_local = local_images.map { |x| x.info["RepoTags"] }.flatten.select { |y| y.eql? "#{image_name}:latest" }.flatten
|
2750
|
+
if docker_image_local.empty?
|
2751
|
+
say "no image"
|
2752
|
+
exit(1)
|
2753
|
+
end
|
2754
|
+
|
2755
|
+
begin
|
2756
|
+
login_content = options["login"]
|
2757
|
+
app_dir = options["app_dir"]
|
2758
|
+
cmd= options["cmd"]
|
2759
|
+
|
2760
|
+
# image_settings = {
|
2761
|
+
# 'Image' => "#{image_name}:latest",
|
2762
|
+
# 'User' => 'ds',
|
2763
|
+
# 'Cmd' => cmd,
|
2764
|
+
# 'WorkingDir' => app_dir,
|
2765
|
+
# 'ExposedPorts' => {
|
2766
|
+
# '8888/tcp' => {},
|
2767
|
+
# },
|
2768
|
+
# 'HostConfig' => {
|
2769
|
+
# 'PortBindings' => {
|
2770
|
+
# '8888/tcp' => [
|
2771
|
+
# {'HostPort' => "#{port}", 'HostIp' => 'localhost'}
|
2772
|
+
# ],
|
2773
|
+
# '6006/tcp' => [
|
2774
|
+
# {'HostPort' => "6006", 'HostIp' => 'localhost'}
|
2775
|
+
# ],
|
2776
|
+
# },
|
2777
|
+
# },
|
2778
|
+
# }
|
2779
|
+
|
2780
|
+
container_id = `nvidia-docker run -itd -p #{port}:8888 -p #{tensport}:6006 -w #{app_dir} #{image_name}:latest #{cmd} `
|
2781
|
+
container_id = container_id.gsub("\n","")
|
2782
|
+
container = Docker::Container.get(container_id)
|
2783
|
+
# container.start()
|
2784
|
+
command = ["/bin/bash", "-lc", "sudo echo -e \"#{login_content}\" >/home/ds/.netrc"]
|
2785
|
+
container.exec(command, tty: true)
|
2786
|
+
command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg"]
|
2787
|
+
container.exec(command, tty: true)
|
2788
|
+
command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg/tmp"]
|
2789
|
+
container.exec(command, tty: true)
|
2790
|
+
command = ["/bin/bash", "-lc", "sudo chown -R ds /home/ds/.cnvrg /home/ds/.netrc"]
|
2791
|
+
container.exec(command, tty: true)
|
2792
|
+
command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
|
2793
|
+
container.exec(command, tty: true)
|
2794
|
+
say "#{container.id}:#{port}##{tensport}"
|
2795
|
+
rescue => e
|
2796
|
+
if e.message.include? "is not running"
|
2797
|
+
puts "running asgain with: #{port-1} #{tensport-1}"
|
2798
|
+
return config_remote_gpu(image_name, port-1,tensport-1)
|
2799
|
+
end
|
2800
|
+
|
2698
2801
|
if container
|
2699
2802
|
container.kill()
|
2700
2803
|
end
|
@@ -2750,7 +2853,6 @@ module Cnvrg
|
|
2750
2853
|
return "port is taken"
|
2751
2854
|
end
|
2752
2855
|
puts "error"
|
2753
|
-
puts e
|
2754
2856
|
if container
|
2755
2857
|
container.kill()
|
2756
2858
|
end
|
@@ -2768,12 +2870,12 @@ module Cnvrg
|
|
2768
2870
|
|
2769
2871
|
path = File.expand_path('~')+"/.cnvrg/tmp/#{image_name}.zip"
|
2770
2872
|
@files = Cnvrg::Files.new("", "")
|
2771
|
-
python_arr = Cnvrg::Images.get_installed_packages("python")
|
2772
|
-
py = python_arr.join(",") unless python_arr.nil? or python_arr.empty?
|
2773
|
-
system_arr = Cnvrg::Images.get_installed_packages("system")
|
2774
|
-
sys = system_arr.join(",") unless system_arr.nil? or system_arr.empty?
|
2873
|
+
# python_arr = Cnvrg::Images.get_installed_packages("python")
|
2874
|
+
# py = python_arr.join(",") unless python_arr.nil? or python_arr.empty?
|
2875
|
+
# system_arr = Cnvrg::Images.get_installed_packages("system")
|
2876
|
+
# sys = system_arr.join(",") unless system_arr.nil? or system_arr.empty?
|
2775
2877
|
# bash_history = Cnvrg::Images.get_bash_history
|
2776
|
-
res = @files.upload_image(path, image_name, owner, true, true,
|
2878
|
+
res = @files.upload_image(path, image_name, owner, true, true, "", "", "", "Image made by cnvrg.io team", "")
|
2777
2879
|
|
2778
2880
|
end
|
2779
2881
|
|
@@ -3290,7 +3392,6 @@ module Cnvrg
|
|
3290
3392
|
end
|
3291
3393
|
$LOG = LogStashLogger.new(type: :file, path: logfile, sync: true)
|
3292
3394
|
rescue => e
|
3293
|
-
# puts e
|
3294
3395
|
end
|
3295
3396
|
end
|
3296
3397
|
|
data/lib/cnvrg/files.rb
CHANGED
@@ -99,7 +99,7 @@ module Cnvrg
|
|
99
99
|
content_type = "application/gzip"
|
100
100
|
end
|
101
101
|
begin
|
102
|
-
upload_resp = Cnvrg::API.request("users/#{owner}/images/" + "
|
102
|
+
upload_resp = Cnvrg::API.request("users/#{owner}/images/" + "upload_cnvrg", 'POST_FILE', {relative_path: absolute_path,
|
103
103
|
file_name: file_name,
|
104
104
|
image_name: image_name,
|
105
105
|
file_size: file_size,
|
@@ -108,7 +108,9 @@ module Cnvrg
|
|
108
108
|
project_slug: @project_slug,
|
109
109
|
commit_id:commit_id ,
|
110
110
|
dpkg: dpkg,
|
111
|
-
|
111
|
+
py2: libraries,
|
112
|
+
py3: libraries,
|
113
|
+
|
112
114
|
bash_history: bash,
|
113
115
|
commit_message:message,
|
114
116
|
is_base: is_base})
|
data/lib/cnvrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.141
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-03-
|
12
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|