cnvrg 1.11.28 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +42 -0
- data/cnvrg.gemspec +8 -6
- data/lib/cnvrg/api.rb +4 -4
- data/lib/cnvrg/cli.rb +172 -81
- data/lib/cnvrg/connect_job_ssh.rb +4 -4
- data/lib/cnvrg/experiment.rb +18 -11
- data/lib/cnvrg/files.rb +6 -2
- data/lib/cnvrg/helpers/agent.rb +58 -18
- data/lib/cnvrg/helpers/executer.rb +179 -37
- data/lib/cnvrg/job_ssh.rb +9 -4
- data/lib/cnvrg/project.rb +26 -9
- data/lib/cnvrg/version.rb +2 -2
- metadata +43 -8
data/lib/cnvrg/job_ssh.rb
CHANGED
@@ -5,14 +5,18 @@ module Cnvrg
|
|
5
5
|
method_option :port, :type => :numeric, :aliases => ["-p", "--port"], :desc => "Port to bind into", :default => 2222
|
6
6
|
method_option :username, :type => :string, :aliases => ["-u", "--username"], :desc => "Job container user name", :default => nil
|
7
7
|
method_option :password, :type => :string, :aliases => ["--password"], :desc =>"Job Conatainer user name, will be set by cnvrg", :default => nil
|
8
|
+
method_option :no_auth, :type => :boolean, :aliases => ["--no-auth"], :default => false
|
9
|
+
method_option :internal_port, :type => :numeric, :aliases => ["--internal-port"], :desc =>"Internal port in the pod for the ssh", :default => 22
|
8
10
|
method_option :kubeconfig, :type => :string, :aliases => ["--kubeconfig"], :desc => "Path to kubeconfig, if blank default config will be used", :default => nil
|
9
11
|
def start(job_id)
|
12
|
+
no_auth = options["no_auth"]
|
10
13
|
Cnvrg::CLI.new.log_start(__method__, args, options)
|
11
14
|
@job_ssh = ConnectJobSsh.new(job_id)
|
12
|
-
@job_ssh.start(options['username'], options['password'])
|
15
|
+
@job_ssh.start(options['username'], options['password'], no_auth, port: options['internal_port'])
|
13
16
|
pod_name = nil
|
14
17
|
namespace = "cnvrg"
|
15
18
|
ssh_ready = false
|
19
|
+
internal_port = options['internal_port']
|
16
20
|
while not ssh_ready
|
17
21
|
resp = @job_ssh.status()
|
18
22
|
status = resp["ssh_status"]
|
@@ -26,13 +30,14 @@ module Cnvrg
|
|
26
30
|
username = resp["username"]
|
27
31
|
pod_name = resp["pod_name"]
|
28
32
|
namespace = resp["namespace"]
|
33
|
+
internal_port = resp["port"] || internal_port
|
29
34
|
ssh_ready = true
|
30
35
|
else
|
31
36
|
puts("Failed to start ssh")
|
32
37
|
break
|
33
38
|
end
|
34
39
|
end
|
35
|
-
if pod_name.blank? or password.blank? or username.blank?
|
40
|
+
if pod_name.blank? or (password.blank? and !no_auth) or username.blank?
|
36
41
|
puts("Failed to get required params")
|
37
42
|
return
|
38
43
|
end
|
@@ -41,8 +46,8 @@ module Cnvrg
|
|
41
46
|
puts("host: 127.0.0.1")
|
42
47
|
puts("port: #{options["port"]}")
|
43
48
|
puts("username: #{username}")
|
44
|
-
puts("password: #{password}")
|
45
|
-
@job_ssh.run_portforward_command(pod_name, options["port"], options["kubeconfig"], namespace)
|
49
|
+
puts("password: #{password}") unless no_auth
|
50
|
+
@job_ssh.run_portforward_command(pod_name, options["port"], options["kubeconfig"], namespace, internal_port)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
data/lib/cnvrg/project.rb
CHANGED
@@ -328,15 +328,21 @@ module Cnvrg
|
|
328
328
|
end
|
329
329
|
|
330
330
|
def get_storage_client
|
331
|
-
|
332
|
-
|
333
|
-
|
331
|
+
client_params = nil
|
332
|
+
i = 0
|
333
|
+
begin
|
334
|
+
response = Cnvrg::API.request("users/#{@owner}/projects/#{@slug}/client", 'GET')
|
335
|
+
unless Cnvrg::CLI.is_response_success(response, false)
|
336
|
+
raise StandardError.new("Can't find project credentials")
|
337
|
+
end
|
334
338
|
client_params = response['client']
|
335
|
-
|
336
|
-
|
339
|
+
rescue StandardError
|
340
|
+
i += 1
|
341
|
+
sleep(5 * i)
|
342
|
+
retry if i < 10
|
337
343
|
client_params = get_storage_client_fallback
|
338
344
|
end
|
339
|
-
|
345
|
+
raise StandardError.new("Can't find project credentials") unless client_params
|
340
346
|
Cnvrg::Downloader::Client.factory(client_params)
|
341
347
|
end
|
342
348
|
|
@@ -378,14 +384,18 @@ module Cnvrg
|
|
378
384
|
[]
|
379
385
|
end
|
380
386
|
|
381
|
-
def generate_output_dir(output_dir)
|
387
|
+
def generate_output_dir(output_dir, local: false)
|
382
388
|
Cnvrg::Logger.log_info("Generating output dir for #{output_dir}")
|
383
389
|
upload_list = []
|
390
|
+
list = []
|
384
391
|
list = Dir.glob("/cnvrg/#{output_dir}/**/*", File::FNM_DOTMATCH)
|
392
|
+
if local
|
393
|
+
list += Dir.glob("#{output_dir}/**/*", File::FNM_DOTMATCH)
|
394
|
+
end
|
395
|
+
list.uniq!
|
385
396
|
Parallel.map(list, in_threads: IDXParallelThreads) do |e|
|
386
397
|
next if e.end_with? "/."
|
387
398
|
if File.directory? e
|
388
|
-
|
389
399
|
upload_list << e + "/"
|
390
400
|
else
|
391
401
|
upload_list << e
|
@@ -447,6 +457,10 @@ module Cnvrg
|
|
447
457
|
if list_ignore_new.include? label
|
448
458
|
next
|
449
459
|
end
|
460
|
+
if File.symlink?(e)
|
461
|
+
Cnvrg::Logger.log_info("Skipping symlink #{e}")
|
462
|
+
next
|
463
|
+
end
|
450
464
|
if File.directory? e
|
451
465
|
dir_name = (label.ends_with? "/") ? label : (label + "/")
|
452
466
|
tree_idx[dir_name] = nil
|
@@ -699,8 +713,11 @@ module Cnvrg
|
|
699
713
|
res = JSON.parse(resp['result']) rescue nil
|
700
714
|
return if res.blank?
|
701
715
|
config = self.get_config
|
702
|
-
config[:is_git] = res['git']
|
703
716
|
config[:project_name] = res['title']
|
717
|
+
config[:project_slug] = @slug
|
718
|
+
config[:owner] = @owner
|
719
|
+
config[:git] = res['git'] || false
|
720
|
+
config[:is_git] = res['git'] || false
|
704
721
|
self.set_config(config)
|
705
722
|
end
|
706
723
|
|
data/lib/cnvrg/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cnvrg
|
2
|
-
VERSION = '
|
3
|
-
end
|
2
|
+
VERSION = '2.0.6'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
8
8
|
- Leah Kolben
|
9
9
|
- Omer Shacham
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -96,6 +96,26 @@ dependencies:
|
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: ffi
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.9'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.9.10
|
109
|
+
type: :runtime
|
110
|
+
prerelease: false
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '1.9'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.9.10
|
99
119
|
- !ruby/object:Gem::Dependency
|
100
120
|
name: mimemagic
|
101
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +125,7 @@ dependencies:
|
|
105
125
|
version: 0.3.1
|
106
126
|
- - ">="
|
107
127
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.3.
|
128
|
+
version: 0.3.7
|
109
129
|
type: :runtime
|
110
130
|
prerelease: false
|
111
131
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -115,7 +135,7 @@ dependencies:
|
|
115
135
|
version: 0.3.1
|
116
136
|
- - ">="
|
117
137
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.3.
|
138
|
+
version: 0.3.7
|
119
139
|
- !ruby/object:Gem::Dependency
|
120
140
|
name: faraday
|
121
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,6 +322,20 @@ dependencies:
|
|
302
322
|
- - "~>"
|
303
323
|
- !ruby/object:Gem::Version
|
304
324
|
version: 0.1.1
|
325
|
+
- !ruby/object:Gem::Dependency
|
326
|
+
name: filewatch
|
327
|
+
requirement: !ruby/object:Gem::Requirement
|
328
|
+
requirements:
|
329
|
+
- - "~>"
|
330
|
+
- !ruby/object:Gem::Version
|
331
|
+
version: 0.9.0
|
332
|
+
type: :runtime
|
333
|
+
prerelease: false
|
334
|
+
version_requirements: !ruby/object:Gem::Requirement
|
335
|
+
requirements:
|
336
|
+
- - "~>"
|
337
|
+
- !ruby/object:Gem::Version
|
338
|
+
version: 0.9.0
|
305
339
|
- !ruby/object:Gem::Dependency
|
306
340
|
name: parallel
|
307
341
|
requirement: !ruby/object:Gem::Requirement
|
@@ -394,6 +428,7 @@ executables:
|
|
394
428
|
extensions: []
|
395
429
|
extra_rdoc_files: []
|
396
430
|
files:
|
431
|
+
- Readme.md
|
397
432
|
- bin/cnvrg
|
398
433
|
- cnvrg.gemspec
|
399
434
|
- lib/cnvrg.rb
|
@@ -438,7 +473,7 @@ files:
|
|
438
473
|
homepage: https://cnvrg.io
|
439
474
|
licenses: []
|
440
475
|
metadata: {}
|
441
|
-
post_install_message:
|
476
|
+
post_install_message:
|
442
477
|
rdoc_options: []
|
443
478
|
require_paths:
|
444
479
|
- lib
|
@@ -453,8 +488,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
453
488
|
- !ruby/object:Gem::Version
|
454
489
|
version: '0'
|
455
490
|
requirements: []
|
456
|
-
rubygems_version: 3.
|
457
|
-
signing_key:
|
491
|
+
rubygems_version: 3.2.22
|
492
|
+
signing_key:
|
458
493
|
specification_version: 4
|
459
494
|
summary: A CLI tool for interacting with cnvrg.io.
|
460
495
|
test_files: []
|