cnvrg 0.0.1420 → 0.0.1421

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 +93 -78
  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: f94403f39c98e7d4c89c32d9c066f6cc82bf9833
4
- data.tar.gz: 2aa4bbda3018ee9d4615f343db4bbc4e420bfdd0
3
+ metadata.gz: 1c6baee53317d2534fda3e2bbe815b9f8ebfe782
4
+ data.tar.gz: a91b53562b3e431399d3bf20ed6cb0a1f4bda1ad
5
5
  SHA512:
6
- metadata.gz: deab7e2a08f9e01744970c10641039cda7f56bd080d9cd6d0da49b1e2cd1c95e983c4b519a652f3ccf4d6aaf01c4cd074dba96140bce9a3adf06a2fb5bca7c3e
7
- data.tar.gz: c8632b9c983025873f92ec07b64498c2625467c9a2e9593420cc9edf4d0c0f09278332d7a5dde58440b34c9e7e669f070804747fd6b4801787540af869b1b8be
6
+ metadata.gz: cbaf58967b1170824772cdbc8472394ca430d6e6272256c868005b70a492a40196ee8af7dc4fd37b03ebfc6f757ba29ba54854c33c1e73f185a0a005a9a8ef94
7
+ data.tar.gz: 3817f79efeca681e9eca2d17b9a38c87807f1d1b71c28550327417ac8307d399f647d839177d5dd9791d582383ea99220107f0ae31815d374ef1e174b490d4d6
@@ -66,7 +66,7 @@ class Thor
66
66
  real_options = []
67
67
 
68
68
  real_args = [].replace(array_options)
69
- if local_options.is_a? (Array) and !local_options.empty?
69
+ if local_options.is_a? (Array) and !local_options.empty? and args.empty?
70
70
  array_options.each_with_index do |p, i|
71
71
  opt = p
72
72
  if p.include? "="
@@ -91,6 +91,12 @@ class Thor
91
91
 
92
92
  args = real_args
93
93
  else
94
+ if !args.empty? and local_options.is_a? Array and !local_options.empty?
95
+ args = args + local_options
96
+ else
97
+ args = args.flatten()
98
+ end
99
+
94
100
  end
95
101
 
96
102
 
@@ -115,9 +121,12 @@ class Thor
115
121
 
116
122
  def is_option (options, p)
117
123
  options.each do |o|
118
- if (!o.aliases.nil? and (o.aliases[0].split(",").include? p or o.aliases.include? p)) or o.switch_name.eql? p
119
- return o
124
+ if !o.aliases.nil?
125
+ if (o.aliases.is_a? Array and o.aliases.include? p) or (!o.aliases.is_a? Array and o.aliases[0].split(",").include? p) or o.switch_name.eql? p
126
+ return o
127
+ end
120
128
  end
129
+
121
130
  end
122
131
  return false
123
132
  end
@@ -1321,6 +1330,21 @@ module Cnvrg
1321
1330
 
1322
1331
  end
1323
1332
 
1333
+ # desc 'data commits', 'List all commits for a specific dataset'
1334
+ #
1335
+ # def list_commits()
1336
+ # verify_logged_in(true)
1337
+ # log_start(__method__, args, options)
1338
+ #
1339
+ # dataset_dir = is_cnvrg_dir(Dir.pwd)
1340
+ # @dataset = Dataset.new(dataset_dir)
1341
+ # result = @dataset.list_commits()
1342
+ # list = result["result"]["list"]
1343
+ #
1344
+ # print_table(list)
1345
+ #
1346
+ # end
1347
+
1324
1348
 
1325
1349
  desc 'unlink', 'Unlink a project from current directory'
1326
1350
 
@@ -2080,9 +2104,9 @@ module Cnvrg
2080
2104
  end
2081
2105
  if local
2082
2106
  invoke :exec, cmd, :sync_before => sync_before, :sync_after => sync_after, :title => title,
2083
- :log => log, :email_notification => email_notification, :upload_output => upload_output,
2084
- :commit => commit, :image => image, :data => data, :data_commit => data_commit, :ignore => ignore
2085
- return
2107
+ :log => log, :email_notification => email_notification, :upload_output => upload_output,
2108
+ :commit => commit, :image => image, :data => data, :data_commit => data_commit, :ignore => ignore
2109
+ return
2086
2110
  else
2087
2111
  real_options.delete(["local", false])
2088
2112
  instances = {"small" => options["small"], "medium" => options["medium"], "large" => options["large"],
@@ -2091,10 +2115,9 @@ module Cnvrg
2091
2115
  if !instance_type.nil? and !instance_type.empty?
2092
2116
  real_options << ["machine_type", instance_type]
2093
2117
  end
2094
- # exec_options = real_options.map { |x| "--#{x[0]}=#{x[1]}" }.flatten.join(" ")
2095
- # cmd_to_exec = "#{exec_options} #{cmd.join(" ")}"
2096
- # return exec_remote(cmd_to_exec)
2097
- invoke :exec_remote, cmd, :sync_before => sync_before, :sync_after => sync_after, :title => title, :machine_type => instance_type,
2118
+ exec_options = real_options.map { |x| "--#{x[0]}=#{x[1]}" }.flatten.join(" ")
2119
+ cmd_to_exec = "#{exec_options} #{cmd.join(" ")}"
2120
+ invoke :exec_remote, [cmd] , :sync_before => sync_before, :sync_after => sync_after, :title => title, :machine_type => instance_type,
2098
2121
  :schedule => schedule, :log => log, :email_notification => email_notification, :upload_output => upload_output, :commit => commit,
2099
2122
  :image => image, :grid => grid, :data => data, :data_commit => data_commit, :ignore => ignore
2100
2123
  return
@@ -2196,8 +2219,6 @@ module Cnvrg
2196
2219
  start_commit = @project.last_local_commit
2197
2220
  cmd = cmd.join("\s")
2198
2221
 
2199
-
2200
-
2201
2222
  @exp = Experiment.new(@project.owner, @project.slug)
2202
2223
 
2203
2224
  platform = RUBY_PLATFORM
@@ -2556,7 +2577,6 @@ module Cnvrg
2556
2577
  method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
2557
2578
  method_option :ignore, :type => :string, :aliases => ["-i"], :desc => "ignore following files", :default => ""
2558
2579
 
2559
-
2560
2580
  def exec_remote(*cmd)
2561
2581
  verify_logged_in(true)
2562
2582
  log_start(__method__, args, options)
@@ -2729,14 +2749,10 @@ module Cnvrg
2729
2749
  workers = options["workers"] || nil
2730
2750
  begin
2731
2751
  num_workers = workers.to_i
2732
-
2733
- puts workers
2734
2752
  rescue
2735
2753
  say "Number of workers should be a number between 1 to 10", Thor::Shell::Color::RED
2736
2754
  exit(1)
2737
2755
  end
2738
-
2739
- exit(0)
2740
2756
  file_as_input = options["file_as_input"] || false
2741
2757
 
2742
2758
 
@@ -2757,7 +2773,7 @@ module Cnvrg
2757
2773
 
2758
2774
  invoke :sync, [false], []
2759
2775
 
2760
- res = project.deploy(file_to_run, function, nil, commit_to_run, instance_type, image_slug, schedule, local_timestamp,num_workers,file_as_input)
2776
+ res = project.deploy(file_to_run, function, nil, commit_to_run, instance_type, image_slug, schedule, local_timestamp, num_workers, file_as_input)
2761
2777
 
2762
2778
  if Cnvrg::CLI.is_response_success(res)
2763
2779
 
@@ -2820,7 +2836,7 @@ module Cnvrg
2820
2836
  method_option :gpu, :type => :boolean, :aliases => ["--gpu"], :default => false
2821
2837
  method_option :gpuxl, :type => :boolean, :aliases => ["--gpuxl"], :default => false
2822
2838
  method_option :gpuxxl, :type => :boolean, :aliases => ["--gpuxxl"], :default => false
2823
- method_option :image, :type => :string, :aliases => ["-i","--image"], :default => ""
2839
+ method_option :image, :type => :string, :aliases => ["-i", "--image"], :default => ""
2824
2840
  method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
2825
2841
  method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
2826
2842
 
@@ -2843,7 +2859,7 @@ module Cnvrg
2843
2859
  instance_type = get_instance_type(instances)
2844
2860
 
2845
2861
  invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type, :image => image,
2846
- :data=> data, :data_commit => data_commit
2862
+ :data => data, :data_commit => data_commit
2847
2863
  return
2848
2864
 
2849
2865
  end
@@ -2860,7 +2876,6 @@ module Cnvrg
2860
2876
  method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
2861
2877
 
2862
2878
 
2863
-
2864
2879
  def remote_notebook()
2865
2880
  verify_logged_in(true)
2866
2881
  log_start(__method__, args, options)
@@ -2898,7 +2913,7 @@ module Cnvrg
2898
2913
  invoke :sync, [false], []
2899
2914
 
2900
2915
 
2901
- res = @image.remote_notebook(notebook_dir, instance_type, kernel,data,data_commit)
2916
+ res = @image.remote_notebook(notebook_dir, instance_type, kernel, data, data_commit)
2902
2917
  if Cnvrg::CLI.is_response_success(res)
2903
2918
  if res["result"]["machine"] == -1
2904
2919
  say "There are no available machines", Thor::Shell::Color::BLUE
@@ -3129,7 +3144,7 @@ module Cnvrg
3129
3144
  stdout.each do |line|
3130
3145
  puts line
3131
3146
 
3132
- end
3147
+ end
3133
3148
 
3134
3149
  rescue Errno::EIO => e
3135
3150
  # break
@@ -3161,43 +3176,43 @@ module Cnvrg
3161
3176
 
3162
3177
  end
3163
3178
 
3164
- if options["verbose"]
3165
- say "Syncing project before running", Thor::Shell::Color::BLUE
3166
- say 'Checking for new updates from remote version', Thor::Shell::Color::BLUE
3167
- end
3168
- @project = Project.new(project_dir)
3169
-
3170
- start_commit = @project.last_local_commit
3171
-
3172
- if (note_slug=image.note_slug)
3173
- say "There is a running notebook session in: https://cnvrg.io/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/show/#{note_slug}", Thor::Shell::Color::BLUE
3174
- new = yes? "Create a new session?", Thor::Shell::Color::YELLOW
3175
- if !new
3176
- exit(0)
3179
+ if options["verbose"]
3180
+ say "Syncing project before running", Thor::Shell::Color::BLUE
3181
+ say 'Checking for new updates from remote version', Thor::Shell::Color::BLUE
3177
3182
  end
3183
+ @project = Project.new(project_dir)
3178
3184
 
3179
- end
3180
- invoke :sync, [false], :verbose => options["verbose"]
3181
- say "Done Syncing", Thor::Shell::Color::BLUE if options["verbose"]
3182
- #replace url
3183
- base_url = get_base_url()
3185
+ start_commit = @project.last_local_commit
3184
3186
 
3185
- local_url = "/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/view/local"
3186
- command = ["/bin/bash", "-lc", "sed -i 's#c.NotebookApp.base_url = .*#c.NotebookApp.base_url = \"#{local_url}\"#' /home/ds/.jupyter/jupyter_notebook_config.py"]
3187
- container.exec(command, tty: true)
3188
- container.stop()
3189
- container.start()
3190
- sleep(7)
3191
- @note = Experiment.new(@project.owner, @project.slug)
3192
- port = image.container_port()
3187
+ if (note_slug=image.note_slug)
3188
+ say "There is a running notebook session in: https://cnvrg.io/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/show/#{note_slug}", Thor::Shell::Color::BLUE
3189
+ new = yes? "Create a new session?", Thor::Shell::Color::YELLOW
3190
+ if !new
3191
+ exit(0)
3192
+ end
3193
3193
 
3194
- command = ["/bin/bash", "-lc", "jupyter notebook list"]
3195
- list = container.exec(command, tty: true)[0]
3196
- if list.empty? or list.nil?
3197
- say "Couldn't start notebook server", Thor::Shell::Color::RED
3198
- log_end(1, "can't start notebook server")
3199
- exit(1)
3200
- end
3194
+ end
3195
+ invoke :sync, [false], :verbose => options["verbose"]
3196
+ say "Done Syncing", Thor::Shell::Color::BLUE if options["verbose"]
3197
+ #replace url
3198
+ base_url = get_base_url()
3199
+
3200
+ local_url = "/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/view/local"
3201
+ command = ["/bin/bash", "-lc", "sed -i 's#c.NotebookApp.base_url = .*#c.NotebookApp.base_url = \"#{local_url}\"#' /home/ds/.jupyter/jupyter_notebook_config.py"]
3202
+ container.exec(command, tty: true)
3203
+ container.stop()
3204
+ container.start()
3205
+ sleep(7)
3206
+ @note = Experiment.new(@project.owner, @project.slug)
3207
+ port = image.container_port()
3208
+
3209
+ command = ["/bin/bash", "-lc", "jupyter notebook list"]
3210
+ list = container.exec(command, tty: true)[0]
3211
+ if list.empty? or list.nil?
3212
+ say "Couldn't start notebook server", Thor::Shell::Color::RED
3213
+ log_end(1, "can't start notebook server")
3214
+ exit(1)
3215
+ end
3201
3216
 
3202
3217
  result = ""
3203
3218
  list.each do |r|
@@ -3207,24 +3222,24 @@ module Cnvrg
3207
3222
  end
3208
3223
  token = result.to_s.split("::")[0].to_s.match(/(token=)(.+)\s/)[2]
3209
3224
 
3210
- # machine_activity = @note.get_machine_activity(project_dir)
3225
+ # machine_activity = @note.get_machine_activity(project_dir)
3211
3226
 
3212
3227
 
3213
- slug = @note.start_notebook_session(kernel, start_commit, token, port, false, notebook_dir)
3214
- image.set_note_url(slug)
3215
- note_url = "http://localhost:#{port}/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/view/local/?token=#{token}"
3228
+ slug = @note.start_notebook_session(kernel, start_commit, token, port, false, notebook_dir)
3229
+ image.set_note_url(slug)
3230
+ note_url = "http://localhost:#{port}/#{@project.owner}/projects/#{@project.slug}/notebook_sessions/view/local/?token=#{token}"
3216
3231
 
3217
3232
 
3218
- if !note_url.empty?
3219
- check = Helpers.checkmark()
3233
+ if !note_url.empty?
3234
+ check = Helpers.checkmark()
3220
3235
 
3221
- say "#{check} Notebook server started successfully", Thor::Shell::Color::GREEN
3222
- Launchy.open(note_url)
3223
- else
3224
- say "Couldn't start notebook server", Thor::Shell::Color::RED
3225
- log_end(1, "can't start notebook server")
3226
- exit(1)
3227
- end
3236
+ say "#{check} Notebook server started successfully", Thor::Shell::Color::GREEN
3237
+ Launchy.open(note_url)
3238
+ else
3239
+ say "Couldn't start notebook server", Thor::Shell::Color::RED
3240
+ log_end(1, "can't start notebook server")
3241
+ exit(1)
3242
+ end
3228
3243
  end
3229
3244
 
3230
3245
 
@@ -3236,7 +3251,7 @@ module Cnvrg
3236
3251
  end
3237
3252
  rescue SignalException
3238
3253
  if !notebooks_pid.nil?
3239
- ::Process.kill(0,notebooks_pid)
3254
+ ::Process.kill(0, notebooks_pid)
3240
3255
  say "#{check} Notebook has stopped successfully", Thor::Shell::Color::GREEN
3241
3256
 
3242
3257
 
@@ -3821,14 +3836,14 @@ module Cnvrg
3821
3836
 
3822
3837
  login_content = options["login"]
3823
3838
 
3824
- container = Docker::Container.get(container)
3825
- command = ["/bin/bash", "-lc", "sudo echo -e \"#{login_content}\" >/home/ds/.netrc"]
3826
- container.exec(command, tty: true)
3827
- command = ["/bin/bash", "-lc", "sudo chown -R ds:ds /home/ds/.netrc"]
3828
- container.exec(command, tty: true)
3829
- command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
3830
- container.exec(command, tty: true)
3831
- say "OK"
3839
+ container = Docker::Container.get(container)
3840
+ command = ["/bin/bash", "-lc", "sudo echo -e \"#{login_content}\" >/home/ds/.netrc"]
3841
+ container.exec(command, tty: true)
3842
+ command = ["/bin/bash", "-lc", "sudo chown -R ds:ds /home/ds/.netrc"]
3843
+ container.exec(command, tty: true)
3844
+ command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
3845
+ container.exec(command, tty: true)
3846
+ say "OK"
3832
3847
 
3833
3848
  end
3834
3849
 
@@ -1,4 +1,4 @@
1
1
  module Cnvrg
2
- VERSION = '0.0.1420'
2
+ VERSION = '0.0.1421'
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.0.1420
4
+ version: 0.0.1421
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-06-14 00:00:00.000000000 Z
12
+ date: 2017-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler