cnvrg 1.10.7 → 1.10.17

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: 1232c4c81a6429fdf01484ba321224d3e9a03c19914a59575eb867d12b206bdd
4
- data.tar.gz: 21ab04f21f6850fc6c9e7eddbcf807b6f7ac312f3c00a857be24cf38d710a784
3
+ metadata.gz: 29b4ab96b94066d5e799cbd5e648eaae0871a634ac6383a66ca3c82a3af9a038
4
+ data.tar.gz: aca3f52a3959cf6db6614bed5b7669c41e9607f0abf25ec83e870783c997f484
5
5
  SHA512:
6
- metadata.gz: 27c2738e285408a315fa8384b230d7c3e108e0b98ecf6b6bb57ee5d7996cbcce37db94fb8b98846195535ac24d7539a7ccfb72ef94fdc82955de1cc2e6e60300
7
- data.tar.gz: 470f1e94d6bbba179a637fdd9765c9b052f91bf1c37742d56541f592cb5a4fd38c11ffd12d554ed6d38b1a0d6f3eeacef84f3032afc175fc6a041880578c9e6e
6
+ metadata.gz: 96fbd5de39c5aa44d93e24c529b5e149cbd8f689c56329e7c5b4a6f9990d19ca8a7d1fdb1f5f00b8abc05c8dccc061a74de65ac8c81524c27f65b0e349dfdc23
7
+ data.tar.gz: 2412c51b6926725be234c022faca6191110caf45de2c83381b171e411f7d7bee78e74d519b91f42e01d07b69413df5df009747f35bd34e480d5733718ccd824c
@@ -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
@@ -11,7 +11,7 @@ module Cnvrg
11
11
  @tempfile = nil
12
12
  @bucket_name = Cnvrg::Helpers.decrypt(@key, @iv, bucket_name)
13
13
  init_gcp_credentials
14
- @storage = Google::Cloud::Storage.new(project_id: @project_id, credentials: @credentials, retries: 20)
14
+ @storage = Google::Cloud::Storage.new(project_id: @project_id, credentials: @credentials, retries: 50, timeout: 43200)
15
15
  @bucket = @storage.bucket(@bucket_name)
16
16
  @bucket.name
17
17
  rescue => e
@@ -47,4 +47,4 @@ module Cnvrg
47
47
  end
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '1.10.7'
2
+ VERSION = '1.10.17'
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.7
4
+ version: 1.10.17
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-15 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.