cnvrg 0.0.1414 → 0.0.1418

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3a999e3ce7616d42f0a81033156a8d5819b68fd
4
- data.tar.gz: 5dfc8054f9ee3f38cefaef9a06b113f72e3d12ba
3
+ metadata.gz: 6e5e43e32a2a764d0177be682b7957bdaa6c184b
4
+ data.tar.gz: a1bd77092a713f3f6edb16f0f2bbb998d3a795d2
5
5
  SHA512:
6
- metadata.gz: cd4af46476dcb927770dd1c88c782ab9d2125e94cc496441f8b465b8edbcd22a2dd02d9d5dbb299c2aa1ac9fa183b2ece4c802f2041b243949a1bf385c317877
7
- data.tar.gz: 2ec0f4e18e2571ce46dd77fa20bf7b6d5b5e667c4d76816502d5e86799c47417a0faec100c46d97566278fa4d68ce4779ead5e4e320ce767a6da711b3fc2d721
6
+ metadata.gz: f60c19507e5eed03dd015ec4d8d03694cf518692057ba969b64cc62a2208d50e02007ace23c0d82740ffe263f685271610ba58f87d22a6866c0bd2d4021ab54a
7
+ data.tar.gz: 8049f800636d14a9de359dd580bece4a28cf6422304e65d17862e5aa85b83604aa9bf798c70b322c2bbcbafc6a40e3bf1659dbb6823d2050f044cd6b58468fef
data/lib/cnvrg/Images.rb CHANGED
@@ -172,9 +172,10 @@ module Cnvrg
172
172
  def create_container(port=7654, is_remote=false)
173
173
  begin
174
174
  image_settings = {
175
- 'Image' => "#{@image_name}:#{@image_tag}",
175
+ 'Image' => "#{@image_name}:latest",
176
176
  'User' => 'ds',
177
- 'Cmd' => '/home/ds/run_ipython.sh',
177
+ 'Cmd' => '/usr/local/cnvrg/run_ipython.sh',
178
+ 'WorkingDir' => '/home/ds/notebooks',
178
179
  'ExposedPorts' => {
179
180
  '8888/tcp' => {},
180
181
  },
@@ -187,9 +188,6 @@ module Cnvrg
187
188
  },
188
189
  },
189
190
  }
190
- # if !is_remote
191
- # image_settings['HostConfig'].merge!({ 'Binds' => ["#{@working_dir}:/home/ds/notebooks"]})
192
- # end
193
191
  container = Docker::Container.create(image_settings)
194
192
  container.start()
195
193
  netrc = File.open(File.expand_path('~')+"/.netrc", "rb")
@@ -199,10 +197,6 @@ module Cnvrg
199
197
  p = container.exec(command, tty: true)
200
198
  command = ["/bin/bash", "-lc", "sudo chown -R ds /home/ds/.netrc"]
201
199
  p = container.exec(command, tty: true)
202
- command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg"]
203
- container.exec(command, tty: true)
204
- command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg/tmp"]
205
- container.exec(command, tty: true)
206
200
  config = File.open(File.expand_path('~')+"/.cnvrg/config.yml", "rb")
207
201
  config_content = config.read
208
202
  container.store_file("/home/ds/.cnvrg/config.yml", config_content)
@@ -249,11 +243,13 @@ module Cnvrg
249
243
 
250
244
  end
251
245
 
252
- def remote_notebook(notebook_path, instance_type, kernel)
246
+ def remote_notebook(notebook_path, instance_type, kernel,data,data_commit)
253
247
  response = Cnvrg::API.request("users/#{@owner}/images/#{@image_slug}/remote_notebook", 'POST', {dir: notebook_path,
254
248
  project_slug: @project_slug,
255
249
  instance_type: instance_type,
256
- kernel: kernel})
250
+ kernel: kernel,
251
+ dataset_slug:data,
252
+ dataset_commit: data_commit})
257
253
  return response
258
254
  end
259
255
 
data/lib/cnvrg/cli.rb CHANGED
@@ -759,7 +759,7 @@ module Cnvrg
759
759
  end
760
760
 
761
761
  desc 'init_data_container', 'Init dataset directory', :hide => true
762
- method_option :login_content, :type => :string, :aliases => ["--l"], :default => ""
762
+ method_option :login_content, :type => :string, :aliases => ["-l"], :default => ""
763
763
 
764
764
  def init_data_container(container)
765
765
  begin
@@ -2794,7 +2794,10 @@ module Cnvrg
2794
2794
  method_option :gpu, :type => :boolean, :aliases => ["--gpu"], :default => false
2795
2795
  method_option :gpuxl, :type => :boolean, :aliases => ["--gpuxl"], :default => false
2796
2796
  method_option :gpuxxl, :type => :boolean, :aliases => ["--gpuxxl"], :default => false
2797
- method_option :image, :type => :string, :aliases => ["--i"], :default => ""
2797
+ method_option :image, :type => :string, :aliases => ["-i","--image"], :default => ""
2798
+ method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
2799
+ method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
2800
+
2798
2801
 
2799
2802
  desc 'notebook', 'starts a notebook session remotely or locally'
2800
2803
 
@@ -2803,7 +2806,8 @@ module Cnvrg
2803
2806
  notebook_dir = options["notebook_dir"]
2804
2807
  kernel = options["kernel"]
2805
2808
  image = options["image"]
2806
-
2809
+ data = options["data"]
2810
+ data_commit = options["data_commit"]
2807
2811
  if local
2808
2812
  invoke :run_notebook, [], :notebook_dir => notebook_dir, :remote => false, :kernel => kernel, :image => image
2809
2813
  return
@@ -2812,7 +2816,8 @@ module Cnvrg
2812
2816
  "gpu" => options["gpu"], "gpuxl" => options["gpuxl"], "gpuxxl" => options["gpuxxl"]}
2813
2817
  instance_type = get_instance_type(instances)
2814
2818
 
2815
- invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type, :image => image
2819
+ invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type, :image => image,
2820
+ :data=> data, :data_commit => data_commit
2816
2821
  return
2817
2822
 
2818
2823
  end
@@ -2825,6 +2830,9 @@ module Cnvrg
2825
2830
  method_option :machine_type, :type => :string, :default => ""
2826
2831
  method_option :kernel, :type => :string, :aliases => ["--kernel", "-k"], :default => ""
2827
2832
  method_option :image, :type => :string, :aliases => ["-i"], :default => ""
2833
+ method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
2834
+ method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
2835
+
2828
2836
 
2829
2837
 
2830
2838
  def remote_notebook()
@@ -2836,6 +2844,8 @@ module Cnvrg
2836
2844
  notebook_dir = options["notebook_dir"]
2837
2845
  instance_type = options["machine_type"] || nil
2838
2846
  kernel = options["kernel"] || nil
2847
+ data = options["data"]
2848
+ data_commit = options["data_commit"]
2839
2849
 
2840
2850
 
2841
2851
  begin
@@ -2862,7 +2872,7 @@ module Cnvrg
2862
2872
  invoke :sync, [false], []
2863
2873
 
2864
2874
 
2865
- res = @image.remote_notebook(notebook_dir, instance_type, kernel)
2875
+ res = @image.remote_notebook(notebook_dir, instance_type, kernel,data,data_commit)
2866
2876
  if Cnvrg::CLI.is_response_success(res)
2867
2877
  if res["result"]["machine"] == -1
2868
2878
  say "There are no available machines", Thor::Shell::Color::BLUE
@@ -3063,7 +3073,7 @@ module Cnvrg
3063
3073
  notebook_dir = options["notebook_dir"]
3064
3074
  remote = options["remote"] || false
3065
3075
  kernel = options["kernel"] || ""
3066
-
3076
+ notebooks_pid = nil
3067
3077
 
3068
3078
  if notebook_dir.empty?
3069
3079
  notebook_dir = project_dir
@@ -3071,25 +3081,60 @@ module Cnvrg
3071
3081
 
3072
3082
  notebook_dir = project_dir+ notebook_dir
3073
3083
  end
3074
- say "Linking notebook directory to: #{File.basename notebook_dir}", Thor::Shell::Color::BLUE
3075
3084
  choose_image = options["image"]
3076
3085
 
3077
3086
  if !choose_image.nil? and !choose_image.empty?
3078
3087
  invoke :set_image, [choose_image]
3079
3088
  end
3089
+
3080
3090
  image = is_project_with_docker(Dir.pwd)
3091
+ if !image
3092
+ jupyter_installed = `which jupyter`
3093
+ if !$?.success?
3094
+ say "Could not find jupyter, Is it installed?", Thor::Shell::Color::RED
3095
+ exit(1)
3096
+ end
3097
+
3098
+
3099
+ cmd = "jupyter-notebook --port=8888"
3100
+ PTY.spawn(cmd) do |stdout, stdin, pid, stderr|
3101
+ begin
3102
+ notebooks_pid = pid
3103
+ stdout.each do |line|
3104
+ puts line
3105
+
3106
+ end
3107
+
3108
+ rescue Errno::EIO => e
3109
+ # break
3110
+ rescue Errno::ENOENT
3111
+ log_end(1, "command #{cmd} isn't valid")
3112
+
3113
+
3114
+ say "command \"#{cmd}\" couldn't be executed, verify command is valid", Thor::Shell::Color::RED
3115
+ rescue PTY::ChildExited
3116
+ log_end(1, "proccess exited")
3117
+ say "The process exited!", Thor::Shell::Color::RED
3118
+ rescue => e
3119
+ log_end(-1, e.message)
3120
+ say "Error occurred,aborting", Thor::Shell::Color::RED
3121
+ exit(0)
3122
+
3123
+ end
3124
+
3125
+
3126
+ end
3127
+
3128
+ end
3129
+
3081
3130
  if image and image.is_docker and !remote
3082
3131
  container= image.get_container
3083
3132
  if !container
3084
-
3085
- say "Couldn't create container with image #{image.image_name}:#{image.image_tag}", Thor::Shell::Color::RED
3133
+ say "Couldn't start docker container", Thor::Shell::Color::RED
3086
3134
  exit(1)
3135
+
3087
3136
  end
3088
- else
3089
- say "Project is not configured with any image", Thor::Shell::Color::RED
3090
- exit(1)
3091
3137
 
3092
- end
3093
3138
  if options["verbose"]
3094
3139
  say "Syncing project before running", Thor::Shell::Color::BLUE
3095
3140
  say 'Checking for new updates from remote version', Thor::Shell::Color::BLUE
@@ -3116,7 +3161,7 @@ module Cnvrg
3116
3161
  container.exec(command, tty: true)
3117
3162
  container.stop()
3118
3163
  container.start()
3119
-
3164
+ sleep(7)
3120
3165
  @note = Experiment.new(@project.owner, @project.slug)
3121
3166
  port = image.container_port()
3122
3167
 
@@ -3128,8 +3173,13 @@ module Cnvrg
3128
3173
  exit(1)
3129
3174
  end
3130
3175
 
3131
- url = list[list.size-1].split(" ::")
3132
- token = url[0][(url[0].index("=")+1)..-1]
3176
+ result = ""
3177
+ list.each do |r|
3178
+ if r.include? "http"
3179
+ result = r
3180
+ end
3181
+ end
3182
+ token = result.to_s.split("::")[0].to_s.match(/(token=)(.+)\s/)[2]
3133
3183
 
3134
3184
  # machine_activity = @note.get_machine_activity(project_dir)
3135
3185
 
@@ -3149,20 +3199,9 @@ module Cnvrg
3149
3199
  log_end(1, "can't start notebook server")
3150
3200
  exit(1)
3151
3201
  end
3202
+ end
3203
+
3152
3204
 
3153
- # jup =verify_software_installed("jupyter-notebook")
3154
- # logs = `#{jup} --no-browser --ip=0.0.0.0 --notebook-dir=#{notebook_dir}`
3155
- # url = URI.extract(logs).reject { |x| x if !x.include? "http" }.uniq![0]
3156
- # if !url.empty?
3157
- # check = Helpers.checkmark()
3158
- #
3159
- # say "#{check} Notebook server started successfully, view notebook in url: #{url}", Thor::Shell::Color::GREEN
3160
- # log_end(0)
3161
- # else
3162
- # say "Couldn't start notebook server", Thor::Shell::Color::RED
3163
- # log_end(1, "can't start notebook server")
3164
- # exit(1)
3165
- # end
3166
3205
  rescue => e
3167
3206
  log_end(-1, e.message)
3168
3207
  say "Error occurd, aborting", Thor::Shell::Color::RED
@@ -3170,12 +3209,20 @@ module Cnvrg
3170
3209
  container.stop()
3171
3210
  end
3172
3211
  rescue SignalException
3173
- log_end(-1)
3174
- if container
3175
- container.stop()
3212
+ if !notebooks_pid.nil?
3213
+ ::Process.kill(0,notebooks_pid)
3214
+ say "#{check} Notebook has stopped successfully", Thor::Shell::Color::GREEN
3215
+
3216
+
3217
+ invoke :sync, [false], []
3218
+ else
3219
+ log_end(-1)
3220
+
3221
+ if container
3222
+ container.stop()
3223
+ end
3176
3224
  end
3177
- say "Aborting"
3178
- exit(1)
3225
+
3179
3226
  end
3180
3227
 
3181
3228
 
@@ -3676,9 +3723,9 @@ module Cnvrg
3676
3723
  end
3677
3724
 
3678
3725
  desc '', '', :hide => true
3679
- method_option :login, :type => :string, :aliases => ["-l", "--l"], :default => ""
3680
- method_option :app_dir, :type => :string, :aliases => ["-d", "--d"], :default => "/home/ds/notebooks"
3681
- method_option :cmd, :type => :string, :aliases => ["-c", "--c"], :default => "/usr/local/cnvrg/run_ipython.sh"
3726
+ method_option :login, :type => :string, :aliases => ["-l"], :default => ""
3727
+ method_option :app_dir, :type => :string, :aliases => ["-d"], :default => "/home/ds/notebooks"
3728
+ method_option :cmd, :type => :string, :aliases => ["-c"], :default => "/usr/local/cnvrg/run_ipython.sh"
3682
3729
 
3683
3730
 
3684
3731
  def config_remote(image_name, port=7654, tensport=6006)
@@ -3719,11 +3766,11 @@ module Cnvrg
3719
3766
  container.start()
3720
3767
  command = ["/bin/bash", "-lc", "sudo echo -e \"#{login_content}\" >/home/ds/.netrc"]
3721
3768
  container.exec(command, tty: true)
3722
- command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg"]
3723
- container.exec(command, tty: true)
3724
- command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg/tmp"]
3725
- container.exec(command, tty: true)
3726
- command = ["/bin/bash", "-lc", "sudo chown -R ds /home/ds/.cnvrg /home/ds/.netrc"]
3769
+ # command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg"]
3770
+ # container.exec(command, tty: true)
3771
+ # command = ["/bin/bash", "-lc", "mkdir /home/ds/.cnvrg/tmp"]
3772
+ # container.exec(command, tty: true)
3773
+ command = ["/bin/bash", "-lc", "sudo chown -R ds:ds /home/ds/.netrc"]
3727
3774
  container.exec(command, tty: true)
3728
3775
  command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
3729
3776
  container.exec(command, tty: true)
@@ -3740,6 +3787,25 @@ module Cnvrg
3740
3787
  end
3741
3788
  end
3742
3789
 
3790
+
3791
+ desc '', '', :hide => true
3792
+ method_option :login, :type => :string, :aliases => ["-l"], :default => ""
3793
+
3794
+ def config_netrc(container)
3795
+
3796
+ login_content = options["login"]
3797
+
3798
+ container = Docker::Container.get(container)
3799
+ command = ["/bin/bash", "-lc", "sudo echo -e \"#{login_content}\" >/home/ds/.netrc"]
3800
+ container.exec(command, tty: true)
3801
+ command = ["/bin/bash", "-lc", "sudo chown -R ds:ds /home/ds/.netrc"]
3802
+ container.exec(command, tty: true)
3803
+ command = ["/bin/bash", "-lc", "sudo chmod 0600 /home/ds/.netrc"]
3804
+ container.exec(command, tty: true)
3805
+ say "OK"
3806
+
3807
+ end
3808
+
3743
3809
  desc '', '', :hide => true
3744
3810
  method_option :login, :type => :string, :aliases => ["-l", "--l"], :default => ""
3745
3811
  method_option :app_dir, :type => :string, :aliases => ["-d", "--d"], :default => "/home/ds/notebooks"
@@ -3950,7 +4016,6 @@ module Cnvrg
3950
4016
  end
3951
4017
  end
3952
4018
 
3953
-
3954
4019
  return dir_path
3955
4020
 
3956
4021
  else
@@ -4072,7 +4137,7 @@ module Cnvrg
4072
4137
 
4073
4138
  desc 'pull_image', 'downloads and loads an image'
4074
4139
 
4075
- def pull(image_name)
4140
+ def pull_image(image_name)
4076
4141
  begin
4077
4142
  verify_logged_in(false)
4078
4143
  log_start(__method__, args, options)
@@ -4085,8 +4150,18 @@ module Cnvrg
4085
4150
  path = download_image(image_name, image["slug"])
4086
4151
  if path
4087
4152
  say "Building image", Thor::Shell::Color::BLUE
4088
- Docker.options[:read_timeout]=1200
4089
- image = Docker::Image.build_from_dir(path, {'dockerfile' => 'Dockerfile', 't' => "#{image_name}:lastest"})
4153
+ Docker.options[:read_timeout]=216000
4154
+ image = Docker::Image.build_from_dir(path, {'dockerfile' => 'Dockerfile.cpu', 't' => "#{image_name}:latest"}) do |v|
4155
+ begin
4156
+ if (log = JSON.parse(v)) && log.has_key?("stream")
4157
+ next if log["stream"].starts_with? "Step"
4158
+ $stdout.puts log["stream"]
4159
+ end
4160
+ rescue
4161
+ end
4162
+
4163
+ end
4164
+
4090
4165
  if not image.nil?
4091
4166
  FileUtils.rm_rf(path)
4092
4167
  checks = Helpers.checkmark()
@@ -4095,11 +4170,13 @@ module Cnvrg
4095
4170
  return image
4096
4171
  log_end(0)
4097
4172
  else
4173
+
4098
4174
  say "Could not build image", Thor::Shell::Color::RED
4099
4175
  log_end(1, "Could build image")
4100
4176
  return false
4101
4177
  end
4102
4178
  else
4179
+
4103
4180
  say "Could not download image", Thor::Shell::Color::RED
4104
4181
  log_end(1, "Could build image")
4105
4182
  return false
@@ -4127,7 +4204,9 @@ module Cnvrg
4127
4204
  #
4128
4205
  # end
4129
4206
  # end
4130
- rescue
4207
+ rescue => e
4208
+
4209
+
4131
4210
  say "Couldn't build image", Thor::Shell::Color::RED
4132
4211
 
4133
4212
  rescue SignalException
@@ -254,7 +254,7 @@ module Cnvrg
254
254
 
255
255
  end
256
256
 
257
- if !s4cmd_suc or !s4cmd_install_suc
257
+ if !s4cmd_suc or !s4cmd_suc or !s4cmd_install_suc
258
258
  s3 = Aws::S3::Resource.new(
259
259
  :access_key_id => URLcrypt.decrypt(upload_resp["result"]["sts_a"]),
260
260
  :secret_access_key => URLcrypt.decrypt(upload_resp["result"]["sts_s"]),
data/lib/cnvrg/files.rb CHANGED
@@ -229,11 +229,11 @@ module Cnvrg
229
229
 
230
230
  s4cmd=`pip freeze |grep s4cmd > /dev/null 2>&1` ; s4cmd_suc=$?.success?
231
231
  if !s4cmd_suc
232
- `pip install s4cmd > /dev/null 2>&1`
232
+ `pip install s4cmd > /dev/null 2>&1` ; s4cmd_install_suc=$?.success?
233
233
  end
234
234
 
235
235
  end
236
- if !is_python
236
+ if !s4cmd_suc or !s4cmd_suc or !s4cmd_install_suc
237
237
  s3 = Aws::S3::Resource.new(
238
238
  :access_key_id => URLcrypt.decrypt(upload_resp["result"]["sts_a"]),
239
239
  :secret_access_key => URLcrypt.decrypt(upload_resp["result"]["sts_s"]),
@@ -251,7 +251,7 @@ module Cnvrg
251
251
  s4cmd_body = ""
252
252
  s4cmd_http_object.start do |http|
253
253
  response = http.request s4cmd_request
254
- s4cmd_body = response.read_body
254
+ s4cmd_body = response.read_bodyo
255
255
  end
256
256
  s4cmd_new_body = s4cmd_body.gsub(" self.client = self.boto3.client('s3',
257
257
  aws_access_key_id=aws_access_key_id,
data/lib/cnvrg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Cnvrg
2
- VERSION = '0.0.1414'
2
+ VERSION = '0.0.1418'
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.1414
4
+ version: 0.0.1418
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-05-30 00:00:00.000000000 Z
12
+ date: 2017-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  requirements: []
361
361
  rubyforge_project:
362
- rubygems_version: 2.6.3
362
+ rubygems_version: 2.6.12
363
363
  signing_key:
364
364
  specification_version: 4
365
365
  summary: A CLI tool for interacting with cnvrg.io.