cnvrg 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cnvrg.gemspec +2 -0
- data/lib/cnvrg/api.rb +34 -4
- data/lib/cnvrg/cli.rb +85 -77
- data/lib/cnvrg/datafiles.rb +36 -11
- data/lib/cnvrg/files.rb +41 -14
- data/lib/cnvrg/project.rb +7 -4
- data/lib/cnvrg/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1d1df0dbab52f8c30f1a3e149f04ce2736b7f1c
|
4
|
+
data.tar.gz: 6ee10285e341bffd5436c79bdd3d6036fc355b02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2416fe3163e8160c1c5c8d9c93e77ccbd4ba388f9bc5ffceb4876c54fb509a5dac7acbb99b81c528717759aa2216d301aaf5eca1fca7a00989538a6428d8d22a
|
7
|
+
data.tar.gz: 100b34a24b210d0ad3de434c79108d02d8aa954b9102d9c33f137674c7906bd23d011929a16d4c46e6d6abadc2ef2b308cd9a390f2beee1f01003aa28f460c8d
|
data/cnvrg.gemspec
CHANGED
data/lib/cnvrg/api.rb
CHANGED
@@ -3,6 +3,8 @@ require 'faraday'
|
|
3
3
|
require 'json'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'cnvrg/helpers'
|
6
|
+
require 'faraday_middleware-request-retry'
|
7
|
+
require 'logger'
|
6
8
|
|
7
9
|
module Cnvrg
|
8
10
|
class API
|
@@ -52,9 +54,24 @@ module Cnvrg
|
|
52
54
|
end
|
53
55
|
conn.headers['Auth-Token'] = @pass
|
54
56
|
conn.headers['User-Agent'] = "#{Cnvrg::API::USER_AGENT}"
|
57
|
+
conn.options.timeout = 420
|
58
|
+
conn.options.open_timeout =420
|
55
59
|
case method
|
56
|
-
|
60
|
+
when 'GET'
|
61
|
+
retries = 0
|
62
|
+
success = false
|
63
|
+
while !success and retries < 20
|
64
|
+
begin
|
57
65
|
response = conn.get "#{resource}", data
|
66
|
+
success = true
|
67
|
+
rescue => e
|
68
|
+
sleep(5)
|
69
|
+
retries +=1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
if !success
|
73
|
+
return false
|
74
|
+
end
|
58
75
|
if response.to_hash[:status] == 404
|
59
76
|
return false
|
60
77
|
end
|
@@ -66,8 +83,21 @@ module Cnvrg
|
|
66
83
|
when 'POST'
|
67
84
|
conn.options.timeout = 420
|
68
85
|
conn.options.open_timeout =420
|
69
|
-
|
70
|
-
|
86
|
+
retries = 0
|
87
|
+
success = false
|
88
|
+
while !success and retries < 20
|
89
|
+
begin
|
90
|
+
response = conn.post "#{resource}", data
|
91
|
+
success = true
|
92
|
+
|
93
|
+
rescue => e
|
94
|
+
sleep(5)
|
95
|
+
retries +=1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
if !success
|
99
|
+
return false
|
100
|
+
end
|
71
101
|
if response.to_hash[:status] == 404
|
72
102
|
return false
|
73
103
|
end
|
@@ -136,7 +166,7 @@ module Cnvrg
|
|
136
166
|
else
|
137
167
|
end
|
138
168
|
rescue => e
|
139
|
-
|
169
|
+
puts e
|
140
170
|
return nil
|
141
171
|
rescue SignalException
|
142
172
|
return false
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -36,6 +36,8 @@ require 'pathname'
|
|
36
36
|
require 'enumerator'
|
37
37
|
require 'ruby-progressbar'
|
38
38
|
require 'open3'
|
39
|
+
|
40
|
+
|
39
41
|
class Thor
|
40
42
|
module Base
|
41
43
|
def initialize(args = [], local_options = {}, config = {})
|
@@ -1515,7 +1517,6 @@ module Cnvrg
|
|
1515
1517
|
@project = Project.new(project_dir)
|
1516
1518
|
result = @project.list_commits()
|
1517
1519
|
list = result["result"]["list"]
|
1518
|
-
|
1519
1520
|
print_table(list)
|
1520
1521
|
|
1521
1522
|
end
|
@@ -1557,6 +1558,8 @@ module Cnvrg
|
|
1557
1558
|
project_home = Dir.pwd
|
1558
1559
|
else
|
1559
1560
|
if (Dir.exists? project_name)
|
1561
|
+
# project_name = "#{project_name}_#{rand(1 .. 5000000000)}"
|
1562
|
+
# puts project_name
|
1560
1563
|
log_message("Error: Conflict with dir #{project_name}", Thor::Shell::Color::RED)
|
1561
1564
|
if no? "Sync to repository anyway? (current data might lost)", Thor::Shell::Color::YELLOW
|
1562
1565
|
log_message("Remove dir in order to clone #{project_name}", Thor::Shell::Color::RED)
|
@@ -1620,7 +1623,6 @@ module Cnvrg
|
|
1620
1623
|
:autofinish => true
|
1621
1624
|
},
|
1622
1625
|
in_processes: ParallelProcesses,
|
1623
|
-
in_thread: ParallelThreads
|
1624
1626
|
}
|
1625
1627
|
begin
|
1626
1628
|
is_success = true
|
@@ -2152,7 +2154,7 @@ module Cnvrg
|
|
2152
2154
|
method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
|
2153
2155
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
2154
2156
|
|
2155
|
-
def upload(link = false, sync = false, direct = false, ignore_list = "")
|
2157
|
+
def upload(link = false, sync = false, direct = false, ignore_list = "", in_exp = false)
|
2156
2158
|
|
2157
2159
|
begin
|
2158
2160
|
verify_logged_in(true)
|
@@ -2184,20 +2186,12 @@ module Cnvrg
|
|
2184
2186
|
end
|
2185
2187
|
new_branch = options["new_branch"] || false
|
2186
2188
|
|
2187
|
-
|
2188
|
-
new_branch_exp = @project.get_new_branch
|
2189
|
-
if new_branch_exp
|
2190
|
-
new_branch = new_branch_exp
|
2191
|
-
end
|
2192
|
-
end
|
2193
|
-
|
2194
|
-
result = @project.compare_idx(new_branch, force: force, deploy: options["deploy"])
|
2189
|
+
result = @project.compare_idx(new_branch, force: force, deploy: options["deploy"],in_exp:in_exp)
|
2195
2190
|
commit = result["result"]["commit"]
|
2196
2191
|
if !link
|
2197
|
-
if ((commit != @project.last_local_commit and !@project.last_local_commit.nil? and !result["result"]["tree"]["updated_on_server"].empty?) and !force)
|
2198
|
-
|
2192
|
+
if (result["result"]["new_version_exist"] and !force) or ((commit != @project.last_local_commit and !@project.last_local_commit.nil? and !result["result"]["tree"]["updated_on_server"].empty?) and !force)
|
2199
2193
|
log_message("Remote server has an updated version, please run `cnvrg download` first, or alternatively: `cnvrg sync`", Thor::Shell::Color::BLUE)
|
2200
|
-
|
2194
|
+
return false
|
2201
2195
|
end
|
2202
2196
|
|
2203
2197
|
log_message("Comparing local changes with remote version:", Thor::Shell::Color::BLUE, (options["verbose"]))
|
@@ -2236,7 +2230,12 @@ module Cnvrg
|
|
2236
2230
|
|
2237
2231
|
end
|
2238
2232
|
# Start commit
|
2239
|
-
|
2233
|
+
if in_exp
|
2234
|
+
exp_start_commit = @project.last_local_commit
|
2235
|
+
else
|
2236
|
+
exp_start_commit = nil
|
2237
|
+
end
|
2238
|
+
commit_sha1 = @files.start_commit(new_branch, force: force, exp_start_commit:exp_start_commit)["result"]["commit_sha1"]
|
2240
2239
|
|
2241
2240
|
# upload / update
|
2242
2241
|
begin
|
@@ -2296,7 +2295,7 @@ module Cnvrg
|
|
2296
2295
|
log_message("Couldn't upload, Rolling Back all changes.", Thor::Shell::Color::RED)
|
2297
2296
|
@files.rollback_commit(commit_sha1)
|
2298
2297
|
|
2299
|
-
|
2298
|
+
return false
|
2300
2299
|
end
|
2301
2300
|
end
|
2302
2301
|
|
@@ -2336,7 +2335,7 @@ module Cnvrg
|
|
2336
2335
|
log_message("Couldn't upload, Rolling Back all changes.", Thor::Shell::Color::RED)
|
2337
2336
|
@files.rollback_commit(commit_sha1)
|
2338
2337
|
|
2339
|
-
|
2338
|
+
return false
|
2340
2339
|
|
2341
2340
|
end
|
2342
2341
|
|
@@ -2351,12 +2350,12 @@ module Cnvrg
|
|
2351
2350
|
rescue SignalException
|
2352
2351
|
@files.rollback_commit(commit_sha1)
|
2353
2352
|
say "User aborted, Rolling Back all changes.", Thor::Shell::Color::RED
|
2354
|
-
|
2353
|
+
return false
|
2355
2354
|
rescue => e
|
2356
2355
|
@files.rollback_commit(commit_sha1)
|
2357
2356
|
log_message("Exception while trying to upload, Rolling back", Thor::Shell::Color::RED)
|
2358
2357
|
log_error(e)
|
2359
|
-
|
2358
|
+
return false
|
2360
2359
|
end
|
2361
2360
|
if !result["deleted"].nil? and !result["deleted"].empty?
|
2362
2361
|
update_count += result["deleted"].size
|
@@ -2374,7 +2373,7 @@ module Cnvrg
|
|
2374
2373
|
@files.rollback_commit(commit_sha1)
|
2375
2374
|
log_message("Couldn't commit updates, Rolling Back all changes.", Thor::Shell::Color::RED)
|
2376
2375
|
log_error(e)
|
2377
|
-
|
2376
|
+
return false
|
2378
2377
|
|
2379
2378
|
end
|
2380
2379
|
image = is_project_with_docker(Dir.pwd)
|
@@ -2405,13 +2404,15 @@ module Cnvrg
|
|
2405
2404
|
'commit_sha1' => res["result"]["commit_id"]
|
2406
2405
|
}
|
2407
2406
|
puts JSON[print_res]
|
2408
|
-
|
2407
|
+
return JSON[print_res]
|
2409
2408
|
end
|
2410
2409
|
if (options["sync"] or sync) and direct
|
2411
2410
|
log_message("#{check} Syncing project completed successfully", Thor::Shell::Color::GREEN)
|
2411
|
+
return true
|
2412
2412
|
|
2413
2413
|
else
|
2414
2414
|
log_message("#{check} Changes were updated successfully", Thor::Shell::Color::GREEN)
|
2415
|
+
return true
|
2415
2416
|
|
2416
2417
|
end
|
2417
2418
|
|
@@ -2429,6 +2430,7 @@ module Cnvrg
|
|
2429
2430
|
log_message("Error: couldn't commit changes, Rolling Back all changes.", Thor::Shell::Color::RED)
|
2430
2431
|
|
2431
2432
|
end
|
2433
|
+
return false
|
2432
2434
|
end
|
2433
2435
|
else
|
2434
2436
|
@files.rollback_commit(commit_sha1)
|
@@ -2442,7 +2444,7 @@ module Cnvrg
|
|
2442
2444
|
else
|
2443
2445
|
log_message("Error: uploaded only: #{update_count} / #{update_total}, \n Rolling back", Thor::Shell::Color::RED)
|
2444
2446
|
end
|
2445
|
-
|
2447
|
+
return false
|
2446
2448
|
|
2447
2449
|
end
|
2448
2450
|
rescue => e
|
@@ -2451,14 +2453,14 @@ module Cnvrg
|
|
2451
2453
|
log_error(e)
|
2452
2454
|
@files.rollback_commit(commit_sha1) unless commit_sha1.nil?
|
2453
2455
|
puts e.message
|
2456
|
+
return false
|
2454
2457
|
|
2455
|
-
exit(1)
|
2456
2458
|
rescue SignalException
|
2457
2459
|
|
2458
2460
|
say "\nAborting", Thor::Shell::Color::BLUE
|
2459
2461
|
say "\nRolling back all changes", Thor::Shell::Color::BLUE
|
2460
2462
|
@files.rollback_commit(commit_sha1) unless commit_sha1.nil?
|
2461
|
-
|
2463
|
+
return false
|
2462
2464
|
end
|
2463
2465
|
|
2464
2466
|
end
|
@@ -2700,7 +2702,7 @@ module Cnvrg
|
|
2700
2702
|
method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
|
2701
2703
|
method_option :ignore, :type => :string, :aliases => ["-i"], :desc => "ignore following files", :default => ""
|
2702
2704
|
|
2703
|
-
def download(sync = false, ignore_list = "")
|
2705
|
+
def download(sync = false, ignore_list = "", in_exp=false)
|
2704
2706
|
begin
|
2705
2707
|
verify_logged_in(true)
|
2706
2708
|
log_start(__method__, args, options)
|
@@ -2723,12 +2725,14 @@ module Cnvrg
|
|
2723
2725
|
log_message("Couldn't append new ignore files to .cnvrgignore", Thor::Shell::Color::YELLOW)
|
2724
2726
|
end
|
2725
2727
|
new_branch = options["new_branch"] || false
|
2726
|
-
res = @project.compare_idx(new_branch)["result"]
|
2727
|
-
|
2728
|
+
res = @project.compare_idx(new_branch, commit: nil, in_exp: in_exp)["result"]
|
2728
2729
|
result = res["tree"]
|
2729
2730
|
|
2730
2731
|
commit = res["commit"]
|
2731
2732
|
if result["updated_on_server"].empty? and result["conflicts"].empty? and result["deleted"].empty?
|
2733
|
+
if !@project.last_local_commit.eql? commit
|
2734
|
+
@project.update_idx_with_commit!(commit)
|
2735
|
+
end
|
2732
2736
|
log_message("Project is up to date", Thor::Shell::Color::GREEN, ((options["sync"] or sync) ? false : true))
|
2733
2737
|
return true
|
2734
2738
|
end
|
@@ -3079,15 +3083,17 @@ module Cnvrg
|
|
3079
3083
|
method_option :message, :type => :string, :aliases => ["-m", "--message"], :default => ""
|
3080
3084
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
3081
3085
|
method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
|
3086
|
+
method_option :in_exp, :type => :boolean, :aliases => ["-e", "--in_exp"], :default => false
|
3087
|
+
|
3082
3088
|
def sync(direct = true)
|
3083
3089
|
verify_logged_in(true) if direct
|
3084
3090
|
log_start(__method__, args, options)
|
3085
3091
|
log_message('Checking for new updates from remote version', Thor::Shell::Color::BLUE, options["verbose"])
|
3086
3092
|
log_message('Syncing project', Thor::Shell::Color::BLUE, !options["verbose"])
|
3087
3093
|
if !options[:force]
|
3088
|
-
invoke :download, [], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true
|
3094
|
+
invoke :download, [true, "", options["in_exp"] ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true
|
3089
3095
|
end
|
3090
|
-
invoke :upload, [
|
3096
|
+
invoke :upload, [false, true, direct, "",options["in_exp"] ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true,
|
3091
3097
|
:ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"], :return_id => options["return_id"]
|
3092
3098
|
|
3093
3099
|
|
@@ -3121,7 +3127,6 @@ module Cnvrg
|
|
3121
3127
|
method_option :max_time, :type => :string, :aliases => [ "--max_time"], :default => nil
|
3122
3128
|
method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
|
3123
3129
|
|
3124
|
-
|
3125
3130
|
def run(*cmd)
|
3126
3131
|
verify_logged_in(true)
|
3127
3132
|
log_start(__method__, args, options)
|
@@ -3185,16 +3190,6 @@ module Cnvrg
|
|
3185
3190
|
return
|
3186
3191
|
end
|
3187
3192
|
|
3188
|
-
# if local
|
3189
|
-
#
|
3190
|
-
# else
|
3191
|
-
|
3192
|
-
|
3193
|
-
# invoke :exec_remote, [cmd_to_exec.split(" ")], :sync_before => sync_before, :sync_after => sync_after, :title => title, :machine_type => instance_type,
|
3194
|
-
# :schedule => schedule, :log => log, :email_notification => email_notification, :upload_output => upload_output, :commit => commit,
|
3195
|
-
# :image => image, :grid => grid, :data => data, :data_commit => data_commit, :ignore => ignore
|
3196
|
-
# return
|
3197
|
-
# end
|
3198
3193
|
end
|
3199
3194
|
|
3200
3195
|
desc '', '', :hide => true
|
@@ -3224,7 +3219,6 @@ module Cnvrg
|
|
3224
3219
|
working_dir = is_cnvrg_dir
|
3225
3220
|
script_path = get_cmd_path_in_dir(working_dir, Dir.pwd)
|
3226
3221
|
|
3227
|
-
|
3228
3222
|
sync_before = options["sync_before"]
|
3229
3223
|
sync_after = options["sync_after"]
|
3230
3224
|
print_log = options["log"]
|
@@ -3434,6 +3428,8 @@ module Cnvrg
|
|
3434
3428
|
exp_success = false
|
3435
3429
|
log_message("The process exited!", Thor::Shell::Color::RED)
|
3436
3430
|
rescue => e
|
3431
|
+
sleep(20) # end cycle
|
3432
|
+
|
3437
3433
|
res = @exp.end(log, 1, start_commit, cpu_average, memory_average)
|
3438
3434
|
|
3439
3435
|
log_message("Error occurred,aborting", Thor::Shell::Color::RED)
|
@@ -3448,38 +3444,34 @@ module Cnvrg
|
|
3448
3444
|
if $?.exitstatus != 0
|
3449
3445
|
exp_success = false
|
3450
3446
|
end
|
3451
|
-
if !exp_success
|
3452
|
-
if !Cnvrg::Helpers.internet_connection?
|
3453
|
-
wait_offline = agree "Seems like you're offline, wait until you're back online?", Thor::Shell::Color::YELLOW
|
3454
|
-
if wait_offline
|
3455
|
-
log_message("Waiting until your'e online..", Thor::Shell::Color::BLUE)
|
3456
|
-
while !Cnvrg::Helpers.internet_connection?
|
3457
|
-
end
|
3458
|
-
exit_status = 0
|
3459
|
-
else
|
3460
|
-
log_message("Experiment has failed, your'e computer is offline", Thor::Shell::Color::RED)
|
3461
|
-
exit(0)
|
3462
|
-
end
|
3463
|
-
else
|
3464
|
-
end_commit = @project.last_local_commit
|
3465
|
-
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3466
|
-
log_message("Experiment has failed, look at the log for more details or run cnvrg exec --log", Thor::Shell::Color::RED)
|
3467
|
-
exit(0)
|
3468
|
-
end
|
3469
3447
|
|
3470
|
-
|
3471
|
-
if sync_after
|
3448
|
+
if sync_after
|
3472
3449
|
# Sync after run
|
3473
|
-
|
3474
|
-
|
3450
|
+
upload_res_count = 0
|
3451
|
+
upload_res = false
|
3452
|
+
while !upload_res and upload_res_count <5
|
3475
3453
|
|
3476
|
-
|
3454
|
+
upload_res = upload(false, true, false, ignore, true)
|
3455
|
+
upload_res_count +=1
|
3456
|
+
end
|
3457
|
+
# download(sync = true, ignore_list = ignore)
|
3458
|
+
# upload(link = false, sync = true, direct = false, ignore_list = ignore)
|
3459
|
+
|
3460
|
+
end
|
3477
3461
|
end_commit = @project.last_local_commit
|
3478
|
-
sleep(7) # end cycle
|
3479
3462
|
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3463
|
+
sleep(30) # end cycle
|
3464
|
+
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3465
|
+
|
3466
|
+
|
3467
|
+
if !exp_success
|
3468
|
+
|
3469
|
+
log_message("Experiment has failed, look at the log for more details or run cnvrg exec --log", Thor::Shell::Color::RED)
|
3470
|
+
else
|
3471
|
+
check = Helpers.checkmark()
|
3472
|
+
log_message("#{check} Done. Experiment's results were updated!", Thor::Shell::Color::GREEN)
|
3473
|
+
end
|
3474
|
+
|
3483
3475
|
rescue => e
|
3484
3476
|
if container
|
3485
3477
|
container.stop()
|
@@ -3495,6 +3487,8 @@ module Cnvrg
|
|
3495
3487
|
|
3496
3488
|
}
|
3497
3489
|
log << cur_log
|
3490
|
+
sleep(20) # end cycle
|
3491
|
+
|
3498
3492
|
res = @exp.end(log, "-1", end_commit, cpu_average, memory_average)
|
3499
3493
|
|
3500
3494
|
end
|
@@ -3510,6 +3504,7 @@ module Cnvrg
|
|
3510
3504
|
rescue SignalException
|
3511
3505
|
exit_status = -1
|
3512
3506
|
end_commit = @project.last_local_commit
|
3507
|
+
sleep(20) # end cycle
|
3513
3508
|
|
3514
3509
|
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3515
3510
|
if container
|
@@ -3629,7 +3624,22 @@ module Cnvrg
|
|
3629
3624
|
else
|
3630
3625
|
image_slug = image.image_slug
|
3631
3626
|
end
|
3632
|
-
|
3627
|
+
forced_commit = nil
|
3628
|
+
if sync_before
|
3629
|
+
if force
|
3630
|
+
sync_result = invoke :sync, [false], :force => force, :return_id=> true
|
3631
|
+
begin
|
3632
|
+
forced_commit = JSON(sync_result)["commit_sha1"]
|
3633
|
+
rescue
|
3634
|
+
forced_commit = nil
|
3635
|
+
end
|
3636
|
+
else
|
3637
|
+
sync_result = invoke :sync, [false], :force => false
|
3638
|
+
end
|
3639
|
+
|
3640
|
+
|
3641
|
+
|
3642
|
+
end
|
3633
3643
|
|
3634
3644
|
|
3635
3645
|
if command.include? "'"
|
@@ -3648,6 +3658,9 @@ module Cnvrg
|
|
3648
3658
|
end
|
3649
3659
|
log_message("Running remote experiment", Thor::Shell::Color::BLUE)
|
3650
3660
|
exp = Experiment.new(project.owner, project.slug)
|
3661
|
+
if forced_commit and (commit_to_run.nil? or commit_to_run.empty?)
|
3662
|
+
commit_to_run = forced_commit
|
3663
|
+
end
|
3651
3664
|
res = exp.exec_remote(command, commit_to_run, instance_type, image_slug, schedule, local_timestamp, grid, path_to_cmd, data, data_commit,
|
3652
3665
|
periodic_sync, sync_before_terminate, max_time, ds_sync_options)
|
3653
3666
|
if Cnvrg::CLI.is_response_success(res)
|
@@ -3701,6 +3714,7 @@ module Cnvrg
|
|
3701
3714
|
rescue SignalException
|
3702
3715
|
exit_status = -1
|
3703
3716
|
end_commit = project.last_local_commit
|
3717
|
+
sleep(20) # end cycle
|
3704
3718
|
|
3705
3719
|
res = @exp.end(log, exit_status, end_commit, "", "")
|
3706
3720
|
say "\nAborting"
|
@@ -3816,6 +3830,7 @@ module Cnvrg
|
|
3816
3830
|
rescue SignalException
|
3817
3831
|
exit_status = -1
|
3818
3832
|
end_commit = project.last_local_commit
|
3833
|
+
sleep(20) # end cycle
|
3819
3834
|
|
3820
3835
|
res = @exp.end(log, exit_status, end_commit, "", "")
|
3821
3836
|
say "\nAborting"
|
@@ -5638,14 +5653,7 @@ module Cnvrg
|
|
5638
5653
|
end
|
5639
5654
|
|
5640
5655
|
def calc_output_log_time(log_count)
|
5641
|
-
|
5642
|
-
return 5
|
5643
|
-
elsif log_count <= 100
|
5644
|
-
return 10
|
5645
|
-
else
|
5646
|
-
return 15
|
5647
|
-
end
|
5648
|
-
|
5656
|
+
return 10
|
5649
5657
|
end
|
5650
5658
|
|
5651
5659
|
def log_start(command, args = "", options = {})
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -167,7 +167,6 @@ module Cnvrg
|
|
167
167
|
dpkg: dpkg,
|
168
168
|
py2: libraries,
|
169
169
|
py3: libraries,
|
170
|
-
|
171
170
|
bash_history: bash,
|
172
171
|
commit_message: message,
|
173
172
|
is_base: is_base})
|
@@ -242,13 +241,25 @@ module Cnvrg
|
|
242
241
|
begin
|
243
242
|
sts_path = upload_resp["result"]["path_sts"]
|
244
243
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
244
|
+
retries = 0
|
245
|
+
success= false
|
246
|
+
while !success and retries < 20
|
247
|
+
begin
|
248
|
+
if !Helpers.is_verify_ssl
|
249
|
+
body = open(sts_path, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read
|
250
|
+
else
|
251
|
+
body = open(sts_path).read
|
252
|
+
end
|
253
|
+
success = true
|
254
|
+
rescue => e
|
255
|
+
retries +=1
|
256
|
+
sleep(5)
|
251
257
|
|
258
|
+
end
|
259
|
+
end
|
260
|
+
if !success
|
261
|
+
return false
|
262
|
+
end
|
252
263
|
split = body.split("\n")
|
253
264
|
key = split[0]
|
254
265
|
iv = split[1]
|
@@ -380,10 +391,24 @@ module Cnvrg
|
|
380
391
|
|
381
392
|
absolute_path += ".conflict" if conflict
|
382
393
|
sts_path = download_resp["result"]["path_sts"]
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
394
|
+
retries = 0
|
395
|
+
success= false
|
396
|
+
while !success and retries < 20
|
397
|
+
begin
|
398
|
+
if !Helpers.is_verify_ssl
|
399
|
+
body = open(sts_path, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read
|
400
|
+
else
|
401
|
+
body = open(sts_path).read
|
402
|
+
end
|
403
|
+
success = true
|
404
|
+
rescue => e
|
405
|
+
retries +=1
|
406
|
+
sleep(5)
|
407
|
+
|
408
|
+
end
|
409
|
+
end
|
410
|
+
if !success
|
411
|
+
return false
|
387
412
|
end
|
388
413
|
split = body.split("\n")
|
389
414
|
key = split[0]
|
data/lib/cnvrg/files.rb
CHANGED
@@ -256,12 +256,25 @@ module Cnvrg
|
|
256
256
|
begin
|
257
257
|
sts_path = upload_resp["result"]["path_sts"]
|
258
258
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
259
|
+
retries = 0
|
260
|
+
success= false
|
261
|
+
while !success and retries < 20
|
262
|
+
begin
|
263
|
+
if !Helpers.is_verify_ssl
|
264
|
+
body = open(sts_path, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read
|
265
|
+
else
|
266
|
+
body = open(sts_path).read
|
267
|
+
end
|
268
|
+
success = true
|
269
|
+
rescue => e
|
270
|
+
retries +=1
|
271
|
+
sleep(5)
|
264
272
|
|
273
|
+
end
|
274
|
+
end
|
275
|
+
if !success
|
276
|
+
return false
|
277
|
+
end
|
265
278
|
split = body.split("\n")
|
266
279
|
key = split[0]
|
267
280
|
iv = split[1]
|
@@ -303,7 +316,6 @@ module Cnvrg
|
|
303
316
|
|
304
317
|
rescue => e
|
305
318
|
puts e
|
306
|
-
puts e.backtrace
|
307
319
|
return false
|
308
320
|
rescue SignalException
|
309
321
|
return false
|
@@ -373,11 +385,26 @@ module Cnvrg
|
|
373
385
|
|
374
386
|
absolute_path += ".conflict" if conflict
|
375
387
|
sts_path = download_resp["result"]["path_sts"]
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
388
|
+
retries = 0
|
389
|
+
success= false
|
390
|
+
while !success and retries < 20
|
391
|
+
begin
|
392
|
+
if !Helpers.is_verify_ssl
|
393
|
+
body = open(sts_path, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read
|
394
|
+
else
|
395
|
+
body = open(sts_path).read
|
396
|
+
end
|
397
|
+
success = true
|
398
|
+
rescue => e
|
399
|
+
retries +=1
|
400
|
+
sleep(5)
|
401
|
+
|
402
|
+
end
|
403
|
+
end
|
404
|
+
if !success
|
405
|
+
return false
|
380
406
|
end
|
407
|
+
|
381
408
|
split = body.split("\n")
|
382
409
|
key = split[0]
|
383
410
|
iv = split[1]
|
@@ -418,8 +445,8 @@ module Cnvrg
|
|
418
445
|
end
|
419
446
|
|
420
447
|
rescue => e
|
421
|
-
|
422
|
-
|
448
|
+
puts e.message
|
449
|
+
return false
|
423
450
|
|
424
451
|
end
|
425
452
|
end
|
@@ -544,10 +571,10 @@ module Cnvrg
|
|
544
571
|
return true
|
545
572
|
|
546
573
|
end
|
547
|
-
def start_commit(new_branch,force:false)
|
574
|
+
def start_commit(new_branch,force:false, exp_start_commit:nil)
|
548
575
|
|
549
576
|
response = Cnvrg::API.request("#{base_resource}/commit/start", 'POST', {project_slug: @project_slug, new_branch: new_branch,force:force,
|
550
|
-
username: @owner})
|
577
|
+
username: @owner, exp_start_commit:exp_start_commit})
|
551
578
|
Cnvrg::CLI.is_response_success(response,false)
|
552
579
|
return response
|
553
580
|
end
|
data/lib/cnvrg/project.rb
CHANGED
@@ -356,8 +356,12 @@ module Cnvrg
|
|
356
356
|
return response
|
357
357
|
end
|
358
358
|
|
359
|
-
def compare_idx(new_branch, commit:last_local_commit,force:false, deploy: false)
|
360
|
-
|
359
|
+
def compare_idx(new_branch, commit:last_local_commit,force:false, deploy: false, in_exp:false)
|
360
|
+
if commit.nil?
|
361
|
+
local_idx = YAML.load_file("#{self.local_path}/.cnvrg/idx.yml")
|
362
|
+
else
|
363
|
+
local_idx = self.generate_idx(deploy: deploy)
|
364
|
+
end
|
361
365
|
ignore_list = self.send_ignore_list()
|
362
366
|
if force
|
363
367
|
added = []
|
@@ -365,7 +369,6 @@ module Cnvrg
|
|
365
369
|
added << local_idx[:tree].keys
|
366
370
|
added.flatten!
|
367
371
|
end
|
368
|
-
|
369
372
|
response ={"result"=> {"commit"=>nil,"tree"=> {"added"=> added,
|
370
373
|
"updated_on_server"=> [],
|
371
374
|
"updated_on_local"=> [],
|
@@ -375,7 +378,7 @@ module Cnvrg
|
|
375
378
|
|
376
379
|
end
|
377
380
|
response = Cnvrg::API.request("users/#{self.owner}/projects/#{self.slug}/status", 'POST', {idx: local_idx, new_branch: new_branch,
|
378
|
-
current_commit: commit,ignore:ignore_list, force:force})
|
381
|
+
current_commit: commit,ignore:ignore_list, force:force,in_exp:in_exp})
|
379
382
|
CLI.is_response_success(response,false)
|
380
383
|
return response
|
381
384
|
end
|
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.
|
4
|
+
version: 0.4.0
|
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: 2018-
|
12
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -385,6 +385,20 @@ dependencies:
|
|
385
385
|
- - ">="
|
386
386
|
- !ruby/object:Gem::Version
|
387
387
|
version: '0'
|
388
|
+
- !ruby/object:Gem::Dependency
|
389
|
+
name: faraday_middleware-request-retry
|
390
|
+
requirement: !ruby/object:Gem::Requirement
|
391
|
+
requirements:
|
392
|
+
- - ">="
|
393
|
+
- !ruby/object:Gem::Version
|
394
|
+
version: '0'
|
395
|
+
type: :runtime
|
396
|
+
prerelease: false
|
397
|
+
version_requirements: !ruby/object:Gem::Requirement
|
398
|
+
requirements:
|
399
|
+
- - ">="
|
400
|
+
- !ruby/object:Gem::Version
|
401
|
+
version: '0'
|
388
402
|
description: A CLI tool for interacting with cnvrg.io.
|
389
403
|
email:
|
390
404
|
- info@cnvrg.io
|