cnvrg 1.10.4 → 1.10.12

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
  SHA256:
3
- metadata.gz: 2c24bbf4a254e135ea5de9795e5394c0b480ddfdce161faeb60db440c398f129
4
- data.tar.gz: 292d5f3fac1c85ed16d2fbb254c8d8296246f0672f885cfb8723cda155e92272
3
+ metadata.gz: d9c519291dee531a33698f1737d8019b9a9affff30c00c60ebb5904cf2ab4daa
4
+ data.tar.gz: 1dd54d29c1f0b7db384bfe62ae6f3678a118375515d6da451ef58094adfa334d
5
5
  SHA512:
6
- metadata.gz: 44ffaa361515845b54a148d727385c224b29e539870abe2c7da88ab9357a9a69ae021ed1d3201bba92875895707c43aaa11c225918ac331c59b31086bf97b13e
7
- data.tar.gz: fa2cec0111bf41e16efa30ae14e9c343fa2a29c8678660a2b7246ea3a1e3a1bb9a58ccf21955da849fc0362d9d1c756df7b8975ec497fdab5918f973d302aeeb
6
+ metadata.gz: d4ce4dea833009867b132bdf6db3fa79bcc7396e828d2f7ad05433ca5c73bf06a999eb40d75d8895f8ae4108d7d6fb30fdc3149001edd63a25f785956abb2472
7
+ data.tar.gz: 1082b5f3dc5da602bb2089a97dec85774bed3a43c05c9247acf64c0bff7a6d50a641dee92f8a4b8999dd3732c5d3c75eec14c6e4b578c9b09d49f5bab7452e39
@@ -1268,11 +1268,22 @@ module Cnvrg
1268
1268
  @datafiles = Cnvrg::Datafiles.new(owner, slug, dataset: @dataset)
1269
1269
 
1270
1270
  # Init a new commit
1271
- response = @datafiles.start_commit(false, true, chunks: 1, message: message )
1271
+ response = @datafiles.start_commit(false, false, chunks: 1, message: message )
1272
1272
  unless response #means we failed in the start commit.
1273
1273
  raise SignalException.new(1, "Cant put files into dataset, check the dataset id")
1274
1274
  end
1275
1275
  @commit = response['result']['commit_sha1']
1276
+
1277
+ # Server expects certain regex format with * so fix those that dont comply
1278
+ regex_list = regex_list.map do |regex|
1279
+ if regex.end_with? "/"
1280
+ # if user wants to delete entire folder add regex to delete contents as well
1281
+ [regex, "#{regex}*"]
1282
+ else
1283
+ regex
1284
+ end
1285
+ end.flatten
1286
+
1276
1287
  files_to_delete, folders_to_delete, job_id = @datafiles.delete_multiple_files(@commit, regex_list)
1277
1288
  log_message("Deleting #{files_to_delete} files and #{folders_to_delete} folders", Thor::Shell::Color::GREEN)
1278
1289
 
@@ -3598,20 +3609,35 @@ module Cnvrg
3598
3609
  exit_status = 0
3599
3610
 
3600
3611
  if options['wait']
3612
+ end_pos = 0
3601
3613
  while true
3602
3614
  tries = 0
3603
3615
  begin
3604
3616
  result = Cnvrg::API_V2.request(
3605
- "#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}/status"
3617
+ "#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}/info",
3618
+ 'GET',
3619
+ { exit_status: true, grid: res["result"]["grid"], pos: end_pos }
3606
3620
  )
3607
- exit_status = result["exit_status"]
3608
- if exit_status
3609
- puts "Experiment was exited with status: #{exit_status}"
3610
- break
3611
- else
3612
- system("clear") || system("cls")
3613
- puts "#{Time.current}: waiting for experiment to finish"
3621
+
3622
+ exit_statuses = result.values.pluck('exit_status')
3623
+ if exit_statuses.include? nil
3624
+ if res["result"]["grid"]
3625
+ system("clear") || system("cls")
3626
+ msg = "#{Time.current}: waiting for all experiments to finish"
3627
+ puts msg
3628
+ else
3629
+ end_pos = result[res['result']['exp_url']]['end_pos']
3630
+ logs = result[res['result']['exp_url']]['logs']
3631
+ logs.each do |log|
3632
+ puts log['message']
3633
+ end
3634
+ end
3614
3635
  sleep 3
3636
+ else
3637
+ result.each do |slug, value|
3638
+ puts "Experiment #{slug} was exited with status #{value['exit_status']}"
3639
+ end
3640
+ break
3615
3641
  end
3616
3642
  rescue => e
3617
3643
  log_error(e)
@@ -4849,17 +4875,19 @@ module Cnvrg
4849
4875
  exp_name = exp["title"]
4850
4876
  if exp["end_commit"].present? and exp["status"] != "Ongoing"
4851
4877
  log_message("#{exp_name} has ended, getting files from end commit", Thor::Shell::Color::BLUE)
4852
- Cnvrg::Helpers.get_experiment_events_log_from_server(exp, @project)
4878
+ num_of_new_files = Cnvrg::Helpers.get_experiment_events_log_from_server(exp, @project)
4853
4879
  exps_map[exp_slug] = exp
4854
4880
  else
4855
4881
  log_message("#{exp_name} is running should get logs", Thor::Shell::Color::BLUE)
4856
- success = Cnvrg::Helpers.get_experiment_events_log_via_kubectl(exp, namespace)
4882
+ success, num_of_new_files = Cnvrg::Helpers.get_experiment_events_log_via_kubectl(exp, namespace)
4857
4883
  if !success and exp["last_successful_commit"].present? and !copied_commits.include?(exp["last_successful_commit"])
4858
4884
  log_message("Failed to get kube files, using last commit", Thor::Shell::Color::BLUE)
4859
- Cnvrg::Helpers.get_experiment_events_log_from_server(exp, @project, commit: exp["last_successful_commit"])
4885
+ num_of_new_files = Cnvrg::Helpers.get_experiment_events_log_from_server(exp, @project, commit: exp["last_successful_commit"])
4860
4886
  copied_commits << exp["last_successful_commit"]
4861
4887
  end
4862
4888
  end
4889
+
4890
+ log_message("New tf files copied", Thor::Shell::Color::BLUE) if num_of_new_files > 0
4863
4891
  rescue => e
4864
4892
  Cnvrg::Logger.log_error(e)
4865
4893
  end
@@ -214,7 +214,7 @@ module Cnvrg
214
214
 
215
215
  desc 'data put DATASET_URL FILES_PREFIX', 'Upload selected files from local dataset directory to remote server'
216
216
  method_option :dir, :type => :string, :aliases => ["-d", "--dir"], :default => ''
217
- method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ''
217
+ # method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ''
218
218
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
219
219
  method_option :override, :type => :boolean, :aliases => ["--override"], :default => false
220
220
  method_option :threads, :type => :numeric, :aliases => ["-t","--threads"], :default => 15
@@ -226,7 +226,8 @@ module Cnvrg
226
226
  dir = options[:dir]
227
227
  force = options[:force]
228
228
  override = options[:override]
229
- commit = options[:commit]
229
+ # commit = options[:commit]
230
+ commit = ''
230
231
  message = options[:message]
231
232
  threads = options[:threads]
232
233
  chunk_size = options[:chunk_size]
@@ -409,8 +409,6 @@ module Cnvrg
409
409
  tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads)
410
410
  results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
411
411
 
412
- # puts "Got #{results['files'].size} files to upload from #{files_chunk.size} files"
413
-
414
412
  if results['files'].blank?
415
413
  progress_mutex.synchronize { progressbar.progress += tree.keys.length }
416
414
  next
@@ -544,8 +544,12 @@ module Cnvrg
544
544
  def generate_chunked_idx(list_files = [], threads: 15, prefix: '')
545
545
  tree = {}
546
546
  Parallel.map(list_files, in_threads: threads) do |file|
547
- #check if prefix exists do prefix/path otherwise path
548
- label = file.gsub(self.local_path + "/", "")
547
+
548
+ # Fix for root path issue
549
+ safe_path = file
550
+ safe_path = file[1..-1] if file.start_with? "/"
551
+
552
+ label = safe_path.gsub(self.local_path + "/", "")
549
553
  label = "#{prefix}/#{label}" if prefix.present?
550
554
  if not Cnvrg::Files.valid_file_name?(label)
551
555
  raise StandardError.new("#{label} is not a valid file name.")
@@ -558,9 +562,16 @@ module Cnvrg
558
562
  file_size = File.size(file).to_f
559
563
  mime_type = MimeMagic.by_path(file)
560
564
  content_type = !(mime_type.nil? or mime_type.text?) ? mime_type.type : "text/plain"
561
- relative_path = file.gsub(/^#{@local_path + "/"}/, "")
565
+ relative_path = safe_path.gsub(/^#{@local_path + "/"}/, "")
562
566
  relative_path = "#{prefix}/#{relative_path}" if prefix.present?
563
- tree[label] = {sha1: sha1, file_name: file_name, file_size: file_size, content_type: content_type, absolute_path: file, relative_path: relative_path}
567
+ tree[label] = {
568
+ sha1: sha1,
569
+ file_name: file_name,
570
+ file_size: file_size,
571
+ content_type: content_type,
572
+ absolute_path: file,
573
+ relative_path: relative_path
574
+ }
564
575
  end
565
576
  end
566
577
  if prefix.present? #add the prefix as dirs to the files
@@ -873,13 +884,8 @@ module Cnvrg
873
884
  end
874
885
 
875
886
  def self.stop_if_dataset_present(dataset_home, dataset_name, commit: nil)
876
-
877
887
  cli = Cnvrg::CLI.new()
878
888
  config = YAML.load_file(dataset_home + "/.cnvrg/config.yml")
879
- if commit.present?
880
- local_commit = YAML.load_file(dataset_home + "/.cnvrg/idx.yml")[:commit] rescue nil
881
- return if commit != local_commit or local_commit.blank?
882
- end
883
889
  if config[:dataset_name] == dataset_name
884
890
  cli.log_message("Dataset already present, clone aborted")
885
891
  exit(0)
@@ -887,6 +893,5 @@ module Cnvrg
887
893
  rescue => e
888
894
  nil
889
895
  end
890
-
891
896
  end
892
897
  end
@@ -364,11 +364,14 @@ parameters:
364
364
  @files.download_files(files, commit_sha1, progress: nil)
365
365
  FileUtils.rm_rf("#{dest_dir}")
366
366
  FileUtils.mkdir_p(dest_dir)
367
+ num_of_new_files = 0
367
368
  files.each do |f|
368
369
  file_dir = "#{dest_dir}/#{File.dirname(f)}"
369
370
  FileUtils.mkdir_p(file_dir)
371
+ num_of_new_files += 1 unless File.exist?("#{dest_dir}/#{f}")
370
372
  FileUtils.mv(f, "#{dest_dir}/#{f}")
371
373
  end
374
+ return num_of_new_files
372
375
  end
373
376
 
374
377
  def get_experiment_events_log_via_kubectl(exp, namespace)
@@ -376,7 +379,7 @@ parameters:
376
379
  result = `kubectl -n #{namespace} get pods | grep #{exp["slug"]}`
377
380
 
378
381
  pod_name = result.split(" ")[0]
379
- return false if pod_name.blank?
382
+ return false, 0 if pod_name.blank?
380
383
  FileUtils.mkdir_p(dest_dir)
381
384
  working_dir = `kubectl -n #{namespace} exec #{pod_name} -c agent -- pwd`
382
385
  working_dir.strip!
@@ -399,16 +402,18 @@ parameters:
399
402
  end
400
403
  end
401
404
 
405
+ num_of_new_files = 0
402
406
  all_files.each do |file|
403
407
  file_dir = "#{dest_dir}/#{File.dirname(file)}"
404
408
  FileUtils.mkdir_p(file_dir)
409
+ num_of_new_files += 1 unless File.exist?("#{dest_dir}/#{file}")
405
410
  res = `kubectl -n #{namespace} cp #{pod_name}:#{file} -c agent #{dest_dir}/#{file}`
406
411
  end
407
412
 
408
- return true
413
+ return true, num_of_new_files
409
414
  rescue => e
410
415
  Cnvrg::Logger.log_error(e)
411
- return false
416
+ return false, 0
412
417
  end
413
418
  end
414
419
 
@@ -421,7 +421,7 @@ module Cnvrg
421
421
 
422
422
  def generate_idx(deploy: false, files: [])
423
423
  if File.exists? "#{self.local_path}/.cnvrg/idx.yml"
424
- old_idx = YAML.load_file("#{self.local_path}/.cnvrg/idx.yml")
424
+ old_idx = YAML.load_file("#{self.local_path}/.cnvrg/idx.yml") rescue {:tree => {}, :commit => nil}
425
425
  else
426
426
  old_idx = {:tree => {}, :commit => nil}
427
427
  end
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '1.10.4'
2
+ VERSION = '1.10.12'
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: 1.10.4
4
+ version: 1.10.12
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: 2020-08-04 00:00:00.000000000 Z
13
+ date: 2020-09-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler