cnvrg 2.0.6 → 2.0.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b238ce877c0fa8da80c63c6d3d165ce974c250ea9c3f3d21ff092098356aa5a5
4
- data.tar.gz: 7c7b4aa637b3bcaf5f18a7eb973d6995f0f1e25147a16a2ccfb1ce3d6dea91e3
3
+ metadata.gz: 7c04990b9e466d74e4ba90092109234a5488f1845db38bac6e3c121d8e6a7508
4
+ data.tar.gz: 253358287a518824c5d22aeda7f4b9c2a9197e57d14177c8757806470258021a
5
5
  SHA512:
6
- metadata.gz: fb1b724199e92fddfa2be4c04b9eb1a8a94e1df65759482fb6c3173f7c3c7632d236c22836749e5f1d6578115555b838285b58d1a95a42ce2df67d3a354da043
7
- data.tar.gz: c840826e01dcd8061fdb1bf065f416d97ca3fe35575649171814741c32332b458c7bac57fa248e9afd45f337b60b18003077cc72d5927527490689572608ad6b
6
+ metadata.gz: df209c738e03b869cc5ccc50694a2ce705fe3c9ba2459a1ddbbeb64b9ab433fdf8bd880bbd4f1d24ce2420ebbf0180b53c87b564e89d3b41df86c55a3b6a5ede
7
+ data.tar.gz: 9bcd79dafb0d9b00626df5b873e8c787731afe2e297292bb184c2e2250062e4ccf5766539a9600d1c078568e2db8c13e9e88842dc6262c8a0c40cc75c80ab07a
data/Readme.md CHANGED
@@ -39,4 +39,33 @@
39
39
  * DEV-10189 - Bug: CLI Sync -file/folder with broken symlink will cause sync to fail
40
40
  ## Version v2.0.6
41
41
  2021-07-18
42
- * DEV-10209 - Bug: some experiments in grid failed on cnvrg-cli commands (docker container id was missing)
42
+ * DEV-10209 - Bug: some experiments in grid failed on cnvrg-cli commands (docker container id was missing)
43
+ ## Version v2.0.7
44
+ 2021-07-27
45
+ * DEV-10186 - Bug: CLI/run an experiment with --local tag giver server error
46
+ ## Version v2.0.8
47
+ 2021-09-06
48
+ * DEV-10697 - Bug: Tensorboard not starting in workspace and experiment.
49
+ ## Version v2.0.9
50
+ 2021-09-12
51
+ * DEV-10502 - Bug: Periodic sync stuck
52
+ ## Version v2.0.10
53
+ 2021-09-12
54
+ * DEV-10502 - Bug: Periodic sync stuck
55
+ ## Version v2.0.11
56
+ 2021-10-21
57
+ ## Version v2.0.12
58
+ 2021-10-25
59
+ * DEV-11544 - Sub-bug: local experiment is failing to run
60
+ ## Version v2.0.13
61
+ 2021-10-27
62
+ * DEV-11054 - Task: Create organization and user by default
63
+ ## Version v2.0.14
64
+ 2021-11-11
65
+ * DEV-11834 - Sub-task: add device name to hpu metrics
66
+ ## Version v2.0.15
67
+ 2021-12-12
68
+ * DEV-12316 - Improvement: cli login should identify saas users automatically
69
+ ## Version v2.0.16
70
+ 2021-12-16
71
+ * DEV-12316 - Improvement: cli login should identify saas users automatically
data/lib/cnvrg/api.rb CHANGED
@@ -57,6 +57,7 @@ module Cnvrg
57
57
  conn = Faraday.new "#{endpoint_uri}"
58
58
  end
59
59
  conn.headers['Auth-Token'] = @pass
60
+ conn.headers['Authorization'] = "CAPI #{@pass}"
60
61
  conn.headers['User-Agent'] = "#{Cnvrg::API::USER_AGENT}"
61
62
  conn.options.timeout = 420
62
63
  conn.options.open_timeout=180
@@ -169,6 +170,7 @@ module Cnvrg
169
170
  when 'POST_FILE'
170
171
  conn = Faraday.new do |fr|
171
172
  fr.headers['Auth-Token'] = @pass
173
+ fr.headers['Authorization'] = "CAPI #{@pass}"
172
174
  fr.headers['User-Agent'] = "#{Cnvrg::API::USER_AGENT}"
173
175
  fr.headers["Content-Type"] = "multipart/form-data"
174
176
  if !Helpers.is_verify_ssl
data/lib/cnvrg/api_v2.rb CHANGED
@@ -22,6 +22,7 @@ module Cnvrg
22
22
 
23
23
  conn = Faraday.new endpoint_uri, :ssl => {:verify => !!Helpers.is_verify_ssl}
24
24
  conn.headers['Auth-Token'] = pass
25
+ conn.headers['Authorization'] = "CAPI #{pass}"
25
26
  conn.headers['User-Agent'] = Cnvrg::API::USER_AGENT
26
27
  conn.headers['Content-Type'] = "application/json"
27
28
  conn.options.timeout = 420
data/lib/cnvrg/auth.rb CHANGED
@@ -44,7 +44,7 @@ module Cnvrg
44
44
  end
45
45
  end
46
46
 
47
- def sign_in(email, password)
47
+ def sign_in(email, password, token: nil)
48
48
  url = Cnvrg::API.endpoint_uri()
49
49
  url = URI.parse(url+ "/users/sign_in")
50
50
  http = Net::HTTP.new(url.host, url.port)
@@ -61,6 +61,9 @@ module Cnvrg
61
61
 
62
62
  req.add_field("EMAIL", email)
63
63
  req.add_field("PASSWORD", password)
64
+ if token.present?
65
+ req.add_field("Authorization", "CAPI #{token}")
66
+ end
64
67
 
65
68
  response = http.request(req)
66
69
 
@@ -1,7 +1,7 @@
1
1
  module Cnvrg
2
2
  class LibraryCli < SubCommandBase
3
-
4
- desc "library import", ''
3
+ map push: :import
4
+ desc "library push", 'Push a new library to AI Library'
5
5
  def import
6
6
  unless File.exists? "library.yml"
7
7
  Cnvrg::CLI.log_message("Can't find library.yml", 'red')
data/lib/cnvrg/cli.rb CHANGED
@@ -496,8 +496,10 @@ module Cnvrg
496
496
 
497
497
 
498
498
  desc 'login', 'Authenticate with cnvrg.io platform'
499
+ method_option :sso, :type => :boolean, :aliases => ["-s", "--sso"], :default => false
499
500
 
500
501
  def login
502
+ use_token = options["sso"]
501
503
  begin
502
504
  log_handler()
503
505
  log_start(__method__, args, options)
@@ -515,12 +517,23 @@ module Cnvrg
515
517
  exit(0)
516
518
  end
517
519
  @email = ask("Enter your email:")
518
- password = cmd.ask("Enter your password (hidden):") {|q| q.echo = "*"}
519
- result = @auth.sign_in(@email, password)
520
+ url = Cnvrg::API.endpoint_uri()
521
+ use_token = true if url.include?("cloud.cnvrg.io")
522
+ if use_token
523
+ @token = cmd.ask("Enter your token (hidden):") {|q| q.echo = "*"}
524
+ netrc[Cnvrg::Helpers.netrc_domain] = @email, @token
525
+ netrc.save
526
+ password = ""
527
+ else
528
+ password = cmd.ask("Enter your password (hidden):") {|q| q.echo = "*"}
529
+ end
530
+ result = @auth.sign_in(@email, password, token: @token)
520
531
 
521
532
  if !result["token"].nil?
522
- netrc[Cnvrg::Helpers.netrc_domain] = @email, result["token"]
523
- netrc.save
533
+ unless use_token
534
+ netrc[Cnvrg::Helpers.netrc_domain] = @email, result["token"]
535
+ netrc.save
536
+ end
524
537
 
525
538
  log_message("Authenticated successfully as #{@email}", Thor::Shell::Color::GREEN)
526
539
 
@@ -3147,7 +3160,7 @@ module Cnvrg
3147
3160
  invoke :exec, [cmd], :sync_before => sync_before, :sync_after => sync_after, :title => title,
3148
3161
  :log => log, :email_notification => email_notification, :upload_output => upload_output,
3149
3162
  :commit => commit, :image => image, :data => data, :data_commit => data_commit,
3150
- :ignore => ignore, :force => force, :output_dir=>output_dir, :data_query=>data_query
3163
+ :ignore => ignore, :force => force, :output_dir=>output_dir, :data_query=>data_query, :local => local
3151
3164
  return
3152
3165
  end
3153
3166
  else
@@ -3204,6 +3217,7 @@ module Cnvrg
3204
3217
  method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => nil
3205
3218
  method_option :use_bash, :type => :boolean, :aliases => ["-b", "--use_bash"], :default => false
3206
3219
  method_option :docker_stats, :type => :boolean, :aliases => ["--docker_stats"], :default => true
3220
+ method_option :local, :type => :boolean, :aliases => ["-l", "--local"], :default => false
3207
3221
 
3208
3222
  def exec(*cmd)
3209
3223
  log = []
@@ -3228,6 +3242,7 @@ module Cnvrg
3228
3242
  project_home = get_project_home
3229
3243
  data_query = options["data_query"]
3230
3244
  docker_stats = options["docker_stats"]
3245
+ local = options[:local] || false
3231
3246
  @project = Project.new(project_home)
3232
3247
  if @project.is_git
3233
3248
  sync_before = false
@@ -3323,43 +3338,49 @@ module Cnvrg
3323
3338
  if @exp.get_cmd.present?
3324
3339
  cmd = @exp.get_cmd
3325
3340
  end
3326
- command_slug = (0...18).map { (65 + rand(26)).chr }.join
3327
- result_file = "/conf/result-#{command_slug}"
3328
- data = {cmd: cmd, async: true, format: true, file_name: result_file, use_script: true, use_bash: options["use_bash"]}
3329
-
3330
- conn = Cnvrg::Helpers::Executer.get_main_conn
3331
- response = conn.post('command', data.to_json)
3332
- if response.to_hash[:status].to_i != 200
3333
- exit_status = 129
3334
- raise StandardError.new("Cant send command to slave")
3335
- end
3336
- t = FileWatch::Tail.new
3337
- filename = result_file
3338
- lines = []
3339
- t.tail(filename)
3340
- t.subscribe do |path, line|
3341
- begin
3342
- cur_log = JSON.parse(line)
3343
- if cur_log["type"] == "endMessage"
3344
- exit_status = cur_log["real"].to_i
3345
- break
3346
- else
3347
- puts(cur_log.to_json)
3348
- STDOUT.flush
3349
- cur_log["time"] = Time.parse(cur_log["timestamp"])
3350
- cur_log["message"] = cur_log["message"].to_s + "\r\n"
3351
- log << cur_log
3352
- end
3353
- if log.size >= 10
3354
- @exp.upload_temp_log(log)
3355
- log = []
3356
- elsif (start_time + 15.seconds) <= Time.now
3357
- @exp.upload_temp_log(log) unless log.empty?
3358
- log = []
3359
- start_time = Time.now
3341
+
3342
+ if local
3343
+ exec_local(cmd, print_log, start_commit, real, start_time)
3344
+ exit_status = $?.exitstatus
3345
+
3346
+ else
3347
+ command_slug = (0...18).map { (65 + rand(26)).chr }.join
3348
+ result_file = "/conf/result-#{command_slug}"
3349
+ data = {cmd: cmd, async: true, format: true, file_name: result_file, use_script: true, use_bash: options["use_bash"]}
3350
+ conn = Cnvrg::Helpers::Executer.get_main_conn
3351
+ response = conn.post('command', data.to_json)
3352
+ if response.to_hash[:status].to_i != 200
3353
+ exit_status = 129
3354
+ raise StandardError.new("Cant send command to slave")
3355
+ end
3356
+ t = FileWatch::Tail.new
3357
+ filename = result_file
3358
+ lines = []
3359
+ t.tail(filename)
3360
+ t.subscribe do |path, line|
3361
+ begin
3362
+ cur_log = JSON.parse(line)
3363
+ if cur_log["type"] == "endMessage"
3364
+ exit_status = cur_log["real"].to_i
3365
+ break
3366
+ else
3367
+ puts(cur_log.to_json)
3368
+ STDOUT.flush
3369
+ cur_log["time"] = Time.parse(cur_log["timestamp"])
3370
+ cur_log["message"] = cur_log["message"].to_s + "\r\n"
3371
+ log << cur_log
3372
+ end
3373
+ if log.size >= 10
3374
+ @exp.upload_temp_log(log)
3375
+ log = []
3376
+ elsif (start_time + 15.seconds) <= Time.now
3377
+ @exp.upload_temp_log(log) unless log.empty?
3378
+ log = []
3379
+ start_time = Time.now
3380
+ end
3381
+ rescue => e
3382
+ log_error(e)
3360
3383
  end
3361
- rescue => e
3362
- log_error(e)
3363
3384
  end
3364
3385
  end
3365
3386
  end_time = Time.now
@@ -4692,6 +4713,7 @@ module Cnvrg
4692
4713
  data_result.each_with_index do |res, i|
4693
4714
  timestamp, value = res["value"]
4694
4715
  uuid = res["metric"]["UUID"].presence || i
4716
+ uuid = res["metric"]["device"] if query_name == "gaudi"
4695
4717
  stat_value = value.present? ? ("%.2f" % value) : 0 # converting 34.685929244444445 to 34.69
4696
4718
  stat_value = stat_value.to_i == stat_value.to_f ? stat_value.to_i : stat_value.to_f # converting 34.00 to 34
4697
4719
  if query_name.include? 'block'
@@ -5007,7 +5029,7 @@ module Cnvrg
5007
5029
  end
5008
5030
  end
5009
5031
 
5010
- desc 'experiments', 'List project experiments'
5032
+ desc 'experiments', 'List project experiments', :hide => true
5011
5033
  method_option :id, :type => :string, :aliases => ["--id"], :desc => "Get info for specific experiments", :default => ""
5012
5034
  method_option :tag, :type => :string, :aliases => ["-t"], :desc => "Get info for specific experiment tag", :default => ""
5013
5035
 
@@ -5876,6 +5898,57 @@ module Cnvrg
5876
5898
  end
5877
5899
  end
5878
5900
 
5901
+ def exec_local(cmd , print_log, start_commit, real, start_time)
5902
+ log = []
5903
+ PTY.spawn(@exp.as_env, cmd) do |stdout, stdin, pid, stderr|
5904
+ begin
5905
+ stdout.each do |line|
5906
+ cur_time = Time.now
5907
+ real_time = Time.now - real
5908
+ cur_log = {time: cur_time,
5909
+ message: line,
5910
+ type: "stdout",
5911
+ real: real_time
5912
+ }
5913
+ if print_log
5914
+ puts({log: line, timestamp: Time.now, exp_logs: true}.to_json)
5915
+ end
5916
+ log << cur_log
5917
+ if log.size >= 10
5918
+ @exp.upload_temp_log(log) unless log.empty?
5919
+ log = []
5920
+ elsif (start_time + 15.seconds) <= Time.now
5921
+ @exp.upload_temp_log(log) unless log.empty?
5922
+ log = []
5923
+ start_time = Time.now
5924
+ end
5925
+ end
5926
+ if stderr
5927
+ stderr.each do |err|
5928
+ log << {time: Time.now, message: err, type: "stderr"}
5929
+ end
5930
+ end
5931
+ rescue Errno::EIO => e
5932
+ log_error(e)
5933
+ if !log.empty?
5934
+ temp_log = log
5935
+ @exp.upload_temp_log(temp_log) unless temp_log.empty?
5936
+ log -= temp_log
5937
+ end
5938
+ rescue Errno::ENOENT => e
5939
+ exp_success = false
5940
+ log_message("command \"#{cmd}\" couldn't be executed, verify command is valid", Thor::Shell::Color::RED)
5941
+ log_error(e)
5942
+ rescue => e
5943
+ res = @exp.end(log, 1, start_commit, 0, 0)
5944
+ log_message("Error occurred,aborting", Thor::Shell::Color::RED)
5945
+ log_error(e)
5946
+ exit(0)
5947
+ end
5948
+ ::Process.wait pid
5949
+ end
5950
+ end
5951
+
5879
5952
  end
5880
5953
  end
5881
5954
 
data/lib/cnvrg/project.rb CHANGED
@@ -661,7 +661,11 @@ module Cnvrg
661
661
 
662
662
  def fetch_webapp_slugs(webapp_slug, slugs: nil)
663
663
  response = Cnvrg::API_V2.request("#{self.owner}/projects/#{self.slug}/webapps/#{webapp_slug}" , 'GET')
664
- return response["experiments"]
664
+
665
+ if response.key?("experiments")
666
+ return response["experiments"]
667
+ end
668
+ return response["data"]["attributes"]["experiments"]
665
669
  rescue
666
670
  slugs
667
671
  end
data/lib/cnvrg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '2.0.6'
2
+ VERSION = '2.0.16'
3
3
  end
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: 2.0.6
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yochay Ettun
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-07-20 00:00:00.000000000 Z
13
+ date: 2021-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -488,7 +488,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
488
488
  - !ruby/object:Gem::Version
489
489
  version: '0'
490
490
  requirements: []
491
- rubygems_version: 3.2.22
491
+ rubygems_version: 3.2.32
492
492
  signing_key:
493
493
  specification_version: 4
494
494
  summary: A CLI tool for interacting with cnvrg.io.