cnvrg 0.3.8 → 0.3.9

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cnvrg/cli.rb +36 -18
  3. data/lib/cnvrg/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14812c074d9b241c639f215c82da967e632a5b4c
4
- data.tar.gz: 68845b081b102ec1d06499a09e3e576a00a89e65
3
+ metadata.gz: e7730f2e06b22172c2321f5a96469aa47b4d5896
4
+ data.tar.gz: fbfb6ed5621d075252fe01e4844c16fa995fc263
5
5
  SHA512:
6
- metadata.gz: ce3a5373033f6a01bab5e0eb9d839e3a6a3b7d1b15576a996e1c00e5d6ef091e9ac6ac50a320379aa9f7ac691b16f8caacc3116b5bd79c4f3c464fbf17878c23
7
- data.tar.gz: 2d1ece161322402bd3922b52f0e0371577eeade4c650d037c7956d13c04a3ce701647ff45f45c4c5415006b6e0a6c33f12bda2ddbbb9103c0a0802a49b3438d6
6
+ metadata.gz: b2be5b074fccb4a67ce8966fe88d42a2cb083538025a0ea5532d8bad267ac259e329b20486f0fb615f1e6a9352dcacf78edcee42ea69f84f795aaa2a2b156cc7
7
+ data.tar.gz: 251fdf65e5f29230edea5b295d061fb8fc1d51fefdf537a27df7773d1c76dd613f63a55a9947a6923439e00a8c1d1f0ba10c4f35b89e6101f1196317cf21d4ba
@@ -36,7 +36,6 @@ require 'pathname'
36
36
  require 'enumerator'
37
37
  require 'ruby-progressbar'
38
38
  require 'open3'
39
-
40
39
  class Thor
41
40
  module Base
42
41
  def initialize(args = [], local_options = {}, config = {})
@@ -2151,6 +2150,7 @@ module Cnvrg
2151
2150
  method_option :force, :type => :boolean, :aliases => ["-f", "--force"], :default => false
2152
2151
  method_option :message, :type => :string, :aliases => ["-m", "--message"], :default => ""
2153
2152
  method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
2153
+ method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
2154
2154
 
2155
2155
  def upload(link = false, sync = false, direct = false, ignore_list = "")
2156
2156
 
@@ -2163,7 +2163,7 @@ module Cnvrg
2163
2163
  if commit_msg.nil? or commit_msg.empty?
2164
2164
  commit_msg = ""
2165
2165
  end
2166
-
2166
+ return_id = options["return_id"]
2167
2167
  @files = Cnvrg::Files.new(@project.owner, @project.slug)
2168
2168
  ignore = options[:ignore] || ""
2169
2169
  force = options[:force] || false
@@ -2399,6 +2399,14 @@ module Cnvrg
2399
2399
  end
2400
2400
  log_message("Total of #{update_count} / #{update_total} files.", Thor::Shell::Color::GREEN)
2401
2401
  else
2402
+ if return_id
2403
+ print_res = {
2404
+ 'success' => "true",
2405
+ 'commit_sha1' => res["result"]["commit_id"]
2406
+ }
2407
+ puts JSON[print_res]
2408
+ exit(0)
2409
+ end
2402
2410
  if (options["sync"] or sync) and direct
2403
2411
  log_message("#{check} Syncing project completed successfully", Thor::Shell::Color::GREEN)
2404
2412
 
@@ -2411,11 +2419,30 @@ module Cnvrg
2411
2419
 
2412
2420
  else
2413
2421
  @files.rollback_commit(commit_sha1)
2414
- log_message("Error: couldn't commit changes, Rolling Back all changes.", Thor::Shell::Color::RED)
2422
+ if return_id
2423
+ print_res = {
2424
+ 'success' => "false",
2425
+ 'message' => 'couldn\'t commit changes, Rolling Back all changes.'
2426
+ }
2427
+ puts JSON[print_res]
2428
+ else
2429
+ log_message("Error: couldn't commit changes, Rolling Back all changes.", Thor::Shell::Color::RED)
2430
+
2431
+ end
2415
2432
  end
2416
2433
  else
2417
2434
  @files.rollback_commit(commit_sha1)
2435
+ if return_id
2436
+ print_res = {
2437
+ 'success' => "false",
2438
+ 'message' => "uploaded only: #{update_count} / #{update_total}, \n Rolling back"
2439
+
2440
+ }
2441
+ puts JSON[print_res]
2442
+ else
2418
2443
  log_message("Error: uploaded only: #{update_count} / #{update_total}, \n Rolling back", Thor::Shell::Color::RED)
2444
+ end
2445
+
2419
2446
 
2420
2447
  end
2421
2448
  rescue => e
@@ -3050,8 +3077,8 @@ module Cnvrg
3050
3077
  method_option :ignore, :type => :string, :aliases => ["-i", "--ignore"], :default => ""
3051
3078
  method_option :force, :type => :boolean, :aliases => ["-f", "--force"], :default => false
3052
3079
  method_option :message, :type => :string, :aliases => ["-m", "--message"], :default => ""
3080
+ method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
3053
3081
  method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
3054
-
3055
3082
  def sync(direct = true)
3056
3083
  verify_logged_in(true) if direct
3057
3084
  log_start(__method__, args, options)
@@ -3060,10 +3087,8 @@ module Cnvrg
3060
3087
  if !options[:force]
3061
3088
  invoke :download, [], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true
3062
3089
  end
3063
-
3064
-
3065
3090
  invoke :upload, [link = false, sync = true, direct = direct], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true,
3066
- :ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"]
3091
+ :ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"], :return_id => options["return_id"]
3067
3092
 
3068
3093
 
3069
3094
  end
@@ -3291,7 +3316,6 @@ module Cnvrg
3291
3316
  begin
3292
3317
  loop do
3293
3318
  restart = @exp.restart_spot_instance()
3294
- puts "spot status: #{restart}"
3295
3319
  if restart
3296
3320
  log_message('Spot instance is going to be terminated', Thor::Shell::Color::YELLOW)
3297
3321
  # sync
@@ -3385,8 +3409,6 @@ module Cnvrg
3385
3409
  puts cur_log
3386
3410
  end
3387
3411
  log << cur_log
3388
-
3389
-
3390
3412
  end
3391
3413
 
3392
3414
 
@@ -3420,7 +3442,6 @@ module Cnvrg
3420
3442
  end
3421
3443
  ::Process.wait pid
3422
3444
  end
3423
-
3424
3445
  cpu_average = cpu_total.inject(0) {|sum, el| sum + el}.to_f / cpu_total.size
3425
3446
  memory_average = memory_total.inject(0) {|sum, el| sum + el}.to_f / memory_total.size
3426
3447
  exit_status = $?.exitstatus
@@ -3440,7 +3461,6 @@ module Cnvrg
3440
3461
  exit(0)
3441
3462
  end
3442
3463
  else
3443
-
3444
3464
  end_commit = @project.last_local_commit
3445
3465
  res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
3446
3466
  log_message("Experiment has failed, look at the log for more details or run cnvrg exec --log", Thor::Shell::Color::RED)
@@ -3450,13 +3470,12 @@ module Cnvrg
3450
3470
  end
3451
3471
  if sync_after
3452
3472
  # Sync after run
3453
-
3454
-
3455
3473
  download(sync = true, ignore_list = ignore)
3456
3474
  upload(link = false, sync = true, direct = false, ignore_list = ignore)
3457
3475
 
3458
3476
  end
3459
- end_commit = @project.last_local_commit
3477
+ end_commit = @project.last_local_commit
3478
+ sleep(7) # end cycle
3460
3479
 
3461
3480
  res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
3462
3481
  check = Helpers.checkmark()
@@ -3610,7 +3629,6 @@ module Cnvrg
3610
3629
  else
3611
3630
  image_slug = image.image_slug
3612
3631
  end
3613
-
3614
3632
  invoke :sync, [false], :force => force if sync_before
3615
3633
 
3616
3634
 
@@ -5622,10 +5640,10 @@ module Cnvrg
5622
5640
  def calc_output_log_time(log_count)
5623
5641
  if log_count <= 20
5624
5642
  return 5
5625
- elsif log_count <= 40
5643
+ elsif log_count <= 100
5626
5644
  return 10
5627
5645
  else
5628
- return 30
5646
+ return 15
5629
5647
  end
5630
5648
 
5631
5649
  end
@@ -1,4 +1,4 @@
1
1
  module Cnvrg
2
- VERSION = '0.3.8'
2
+ VERSION = '0.3.9'
3
3
  end
4
4
 
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.3.8
4
+ version: 0.3.9
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-03-19 00:00:00.000000000 Z
12
+ date: 2018-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler