cnvrg 1.10.6 → 1.10.16

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: e91c3bfecec9012b07c62d288260fe11c7a650df39e06ce493f6857ccd17ea0f
4
- data.tar.gz: cb65a865545d566b183d2829c3e76b6bacce56b741e3216b500f5ba691e529a4
3
+ metadata.gz: 5db0dade8678ab44aff68dbe2869601f2d328099cbf9206c8bd321380e3f2f27
4
+ data.tar.gz: 0571504e35f30357bca6a1b0aea9224602a9ff8bde6c4a5191bacb5e34bcb886
5
5
  SHA512:
6
- metadata.gz: 80e70d6faecdc53cabce9812ef6621c0dc2c72890d1122dca724544510e119b21b63f941f244097b1efe200dc6c94f83ecccc159fe891ad3a78b19c909f960ed
7
- data.tar.gz: 9084beb5aceea84f51f1fb187e7fdb0f4c1bd3ebe2035c0969a0f6819ba36fbf77a171d0db6674edbf8cd4c5bee74d926a6a9ee74bf664f4f0c4cac283b23d0d
6
+ metadata.gz: 69dc6323bfeb7639a7ff729b974c0e485566b975ad0356e31aaaf690e32ce08ac4518b0c7dee3ec4cb6d013009e928ba51679d3d4296a0505b46506c822f2fc0
7
+ data.tar.gz: a030f21f9ded5523f7b606c7b01d38b949b5c4036474de017c37d40727efade68113672c80e5c8bcb8dc7138a0593435af9bd6efddf4b09c063fcd838bbcb9f3
@@ -1208,12 +1208,14 @@ module Cnvrg
1208
1208
  log_message("Uploading #{@files.size} files", Thor::Shell::Color::GREEN)
1209
1209
  number_of_chunks = (@files.size.to_f / chunk_size).ceil
1210
1210
  if commit.blank?
1211
+ Cnvrg::Logger.info("Creating commit")
1211
1212
  response = @datafiles.start_commit(false, force, chunks: number_of_chunks, message: message )
1212
1213
  unless response #means we failed in the start commit.
1213
1214
  raise SignalException.new(1, "Cant put files into dataset, check the dataset id")
1214
1215
  end
1215
1216
  @commit = response['result']['commit_sha1']
1216
1217
  elsif commit.eql? "latest"
1218
+ Cnvrg::Logger.info("Put files in latest commit")
1217
1219
  response = @datafiles.last_valid_commit()
1218
1220
  unless response #means we failed in the start commit.
1219
1221
  raise SignalException.new(1, "Cant put files into commit:#{commit}, check the dataset id and commitc")
@@ -1233,15 +1235,15 @@ module Cnvrg
1233
1235
  override: override,
1234
1236
  chunk_size: chunk_size,
1235
1237
  prefix: dir,
1236
- threads: threads
1238
+ threads: threads,
1237
1239
  )
1238
-
1240
+ Cnvrg::Logger.info("Finished upload files")
1239
1241
  # This is for backwards compatibility only and should be removed in future versions:
1240
1242
  res = @datafiles.put_commit(@commit)
1241
1243
  unless res.is_success?
1242
1244
  raise SignalException.new(1, res.msg)
1243
1245
  end
1244
-
1246
+ Cnvrg::Logger.info("Saving commit on server")
1245
1247
  res = @datafiles.end_commit(@commit,force, success: true, commit_type: "put")
1246
1248
  msg = res['result']
1247
1249
  response = Cnvrg::Result.new(Cnvrg::CLI.is_response_success(res, true), msg)
@@ -1273,6 +1275,17 @@ module Cnvrg
1273
1275
  raise SignalException.new(1, "Cant put files into dataset, check the dataset id")
1274
1276
  end
1275
1277
  @commit = response['result']['commit_sha1']
1278
+
1279
+ # Server expects certain regex format with * so fix those that dont comply
1280
+ regex_list = regex_list.map do |regex|
1281
+ if regex.end_with? "/"
1282
+ # if user wants to delete entire folder add regex to delete contents as well
1283
+ [regex, "#{regex}*"]
1284
+ else
1285
+ regex
1286
+ end
1287
+ end.flatten
1288
+
1276
1289
  files_to_delete, folders_to_delete, job_id = @datafiles.delete_multiple_files(@commit, regex_list)
1277
1290
  log_message("Deleting #{files_to_delete} files and #{folders_to_delete} folders", Thor::Shell::Color::GREEN)
1278
1291
 
@@ -3083,6 +3096,11 @@ module Cnvrg
3083
3096
  emails = options["emails"]
3084
3097
  wait = options["wait"]
3085
3098
 
3099
+ if wait && local
3100
+ log_message("WARN: `wait` option is not valid for local experiment, ignoring it", Thor::Shell::Color::YELLOW)
3101
+ wait = false
3102
+ end
3103
+
3086
3104
  if !data.present? and data_query.present?
3087
3105
  log_message("Please provide data with data_query", Thor::Shell::Color::RED)
3088
3106
  exit(1)
@@ -3598,24 +3616,33 @@ module Cnvrg
3598
3616
  exit_status = 0
3599
3617
 
3600
3618
  if options['wait']
3619
+ end_pos = 0
3601
3620
  while true
3602
3621
  tries = 0
3603
3622
  begin
3604
3623
  result = Cnvrg::API_V2.request(
3605
- "#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}/exit_status",
3624
+ "#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}/info",
3606
3625
  'GET',
3607
- { grid: res["result"]["grid"]}
3626
+ { exit_status: true, grid: res["result"]["grid"], pos: end_pos }
3608
3627
  )
3609
3628
 
3610
- exit_statuses = result.values
3629
+ exit_statuses = result.values.pluck('exit_status')
3611
3630
  if exit_statuses.include? nil
3612
- system("clear") || system("cls")
3613
- msg = "#{Time.current}: waiting for experiment to finish"
3614
- msg = "#{Time.current}: waiting for all experiments to finish" if res["result"]["grid"]
3615
- puts msg
3631
+ if res["result"]["grid"]
3632
+ system("clear") || system("cls")
3633
+ msg = "#{Time.current}: waiting for all experiments to finish"
3634
+ puts msg
3635
+ else
3636
+ end_pos = result[res['result']['exp_url']]['end_pos']
3637
+ logs = result[res['result']['exp_url']]['logs']
3638
+ logs.each do |log|
3639
+ puts log['message']
3640
+ end
3641
+ end
3616
3642
  sleep 3
3617
3643
  else
3618
- result.each do |slug, exit_status|
3644
+ result.each do |slug, value|
3645
+ exit_status = value['exit_status']
3619
3646
  puts "Experiment #{slug} was exited with status #{exit_status}"
3620
3647
  end
3621
3648
  break
@@ -5282,8 +5309,8 @@ module Cnvrg
5282
5309
  count += 1
5283
5310
  end
5284
5311
  if File.exist? logfile_old
5285
- @files = Cnvrg::Files.new(Cnvrg::CLI.get_owner, "")
5286
- @files.upload_log_file(logfile_old, "log_#{date}.log", yesterday)
5312
+ #@files = Cnvrg::Files.new(Cnvrg::CLI.get_owner, "")
5313
+ #@files.upload_log_file(logfile_old, "log_#{date}.log", yesterday)
5287
5314
  FileUtils.remove logfile_old
5288
5315
  end
5289
5316
 
@@ -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,20 +226,21 @@ 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]
233
234
  cli.data_put(
234
- dataset_url,
235
- files: files,
236
- dir: dir,
237
- commit: commit,
238
- force: force,
239
- override: override,
240
- threads: threads,
241
- chunk_size: chunk_size,
242
- message: message
235
+ dataset_url,
236
+ files: files,
237
+ dir: dir,
238
+ commit: commit,
239
+ force: force,
240
+ override: override,
241
+ threads: threads,
242
+ chunk_size: chunk_size,
243
+ message: message
243
244
  )
244
245
  end
245
246
 
@@ -376,16 +376,16 @@ module Cnvrg
376
376
 
377
377
  if uploaded_files.size == chunk_size or progressbar.finished?
378
378
  refresh_storage_token
379
- # puts "progress: #{progress_queue.length}"
380
- # puts "files: #{file_queue.length}"
379
+ Cnvrg::Logger.info("Finished upload chunk of #{chunk_size} files")
381
380
  Cnvrg::Logger.info("Sending Upload files save")
382
381
  blob_ids = uploaded_files.map {|f| f['bv_id']}
382
+ Cnvrg::Logger.info("Sending chunk to server")
383
383
  upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids, dirs: dirs})
384
384
  unless Cnvrg::CLI.is_response_success(upload_resp, false)
385
385
  Cnvrg::Logger.log_method(bind: binding)
386
386
  raise Exception.new("Got an error message from server, #{upload_resp.try(:fetch, "message")}")
387
387
  end
388
- # cli.log_message("Saved file chunk to server", Thor::Shell::Color::GREEN)
388
+ Cnvrg::Logger.info("Chunk saved on server")
389
389
  uploaded_files = []
390
390
  dirs = []
391
391
  end
@@ -394,7 +394,7 @@ module Cnvrg
394
394
  end
395
395
 
396
396
  if progressbar.finished?
397
- # puts "finished"
397
+ Cnvrg::Logger.info("Progress bar finished closing queues")
398
398
  file_queue.close()
399
399
  progress_queue.close()
400
400
  Thread.exit
@@ -405,12 +405,11 @@ module Cnvrg
405
405
  file_chunks = files.each_slice(chunk_size).to_a
406
406
  # Fetch the required files from the server:
407
407
  Parallel.map((file_chunks), in_threads: 10) do |files_chunk|
408
-
408
+ Cnvrg::Logger.info("Generating chunk idx")
409
409
  tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads)
410
+ Cnvrg::Logger.info("Getting files info from server")
410
411
  results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
411
412
 
412
- # puts "Got #{results['files'].size} files to upload from #{files_chunk.size} files"
413
-
414
413
  if results['files'].blank?
415
414
  progress_mutex.synchronize { progressbar.progress += tree.keys.length }
416
415
  next
@@ -432,7 +431,7 @@ module Cnvrg
432
431
  file_queue.push tree[key].merge(files_to_upload[key])
433
432
  end
434
433
  end
435
-
434
+ Cnvrg::Logger.info("Finishing sub processes of datasets' upload")
436
435
  progress_thread.join()
437
436
  worker_threads.each(&:join)
438
437
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '1.10.6'
2
+ VERSION = '1.10.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: 1.10.6
4
+ version: 1.10.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: 2020-08-16 00:00:00.000000000 Z
13
+ date: 2020-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -453,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
453
453
  - !ruby/object:Gem::Version
454
454
  version: '0'
455
455
  requirements: []
456
- rubygems_version: 3.0.4
456
+ rubygems_version: 3.1.2
457
457
  signing_key:
458
458
  specification_version: 4
459
459
  summary: A CLI tool for interacting with cnvrg.io.