cnvrg 1.10.8 → 1.10.18

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: d9e8e76336bf9862fca95649740a7b5a5148565469ece725f4760041db28ffc4
4
- data.tar.gz: f65852f97fb1294258c3c6b4b6941fb62248eeb1691d432e47bb4e2acb60a313
3
+ metadata.gz: 8009827a102d9ea4bda3e07d95ad52a23fe7202b2670850952fb345acac7b906
4
+ data.tar.gz: aa91b22c83120d50f0631945d06f4d878e1cea4d2f9d950f6e29fbba17305f21
5
5
  SHA512:
6
- metadata.gz: c5be8e6c872dd256560805d8146b3e2d7672a72844b932081dddc94c62e3fde4f9d7f66dd18d4f882c005c9e6e2183a91de689254b6dce07c265932058a4a1b0
7
- data.tar.gz: 345eee06f18b24a30826665c7803b1275bdbc33d94779e5e37812cce7f95738bb819c5e2064871618145a27e72d133373e2493fb57f63b1c85ce8072c6057a54
6
+ metadata.gz: 2159ce3f1e3b55390b599a72b80c1b6de559554380d5b294922ddd001cff2c944cf6614bb582f184c62be6299826f4a1860257a5426c6534a254ea195bb9910c
7
+ data.tar.gz: ccb989d604602dbcfcee6f40725ae8a45875744f222b7aa717ddfe2760483361d03a16f6e016179acf82c0c493d9a3518a548d18dbb850a7cf0fc0b99aef0120
@@ -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
 
@@ -316,21 +316,21 @@ module Cnvrg
316
316
  #Cnvrg::Logger.log_method(bind: binding)
317
317
  retry_count += 1
318
318
 
319
- puts "Failed request upload files: #{Time.current}"
320
- puts upload_resp
319
+ Cnvrg::Logger.log_info("Failed request upload files: #{Time.current}, retry: #{retry_count}")
321
320
 
322
- if retry_count > 5
323
- raise Exception.new("Got an error message from server, #{upload_resp.try(:fetch, "message")}")
321
+ if retry_count > 20
322
+ puts "Failed to upload files: #{Time.current}, trying next chunk"
323
+ return nil
324
324
  end
325
325
  sleep 5
326
326
  next
327
327
  end
328
328
  return upload_resp['result'].with_indifferent_access
329
329
  end
330
-
331
330
  end
332
331
 
333
332
  def upload_multiple_files_optimized(files, commit_sha1, threads: 15, chunk_size: 1000, override: false, new_branch: false, prefix: '', partial_commit: nil)
333
+ Thread.report_on_exception = false
334
334
  cli = CLI.new
335
335
  cli.log_message("Using #{threads} threads with chunk size of #{chunk_size}.", Thor::Shell::Color::GREEN)
336
336
 
@@ -342,6 +342,7 @@ module Cnvrg
342
342
  file_queue = Queue.new
343
343
  progress_queue = Queue.new
344
344
  worker_threads = []
345
+ progress_threads = []
345
346
 
346
347
  # Vars to keep track of uploaded files and directories
347
348
  dirs = []
@@ -359,45 +360,69 @@ module Cnvrg
359
360
  cli.log_message("Error while uploading file: #{file[:absolute_path]}", Thor::Shell::Color::RED)
360
361
  Cnvrg::Logger.log_error_message("Error while upload single file #{file["path"]}")
361
362
  end
363
+ while progress_queue.size > 15000
364
+ sleep(0.1)
365
+ end
362
366
  progress_queue << file
363
367
  end
364
368
  end
365
369
  end
366
370
 
367
371
  # init the thread that handles the file upload progress and saving them in the server
368
- progress_thread = Thread.new do
369
- loop do
370
- file = progress_queue.deq(non_block: true) rescue nil # to prevent deadlocks
371
- unless file.nil?
372
- progress_mutex.synchronize {
373
- progressbar.progress += 1
374
- uploaded_files.append(file) if file[:success]
375
- }
376
-
377
- if uploaded_files.size == chunk_size or progressbar.finished?
378
- refresh_storage_token
379
- # puts "progress: #{progress_queue.length}"
380
- # puts "files: #{file_queue.length}"
381
- Cnvrg::Logger.info("Sending Upload files save")
382
- blob_ids = uploaded_files.map {|f| f['bv_id']}
383
- upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids, dirs: dirs})
384
- unless Cnvrg::CLI.is_response_success(upload_resp, false)
385
- Cnvrg::Logger.log_method(bind: binding)
386
- raise Exception.new("Got an error message from server, #{upload_resp.try(:fetch, "message")}")
372
+ threads.times do |i|
373
+ progress_threads[i] = Thread.new do
374
+ loop do
375
+ file = progress_queue.deq(non_block: true) rescue nil # to prevent deadlocks
376
+ unless file.nil?
377
+ blob_ids = []
378
+ dirs_to_upload = []
379
+
380
+ progress_mutex.synchronize {
381
+ progressbar.progress += 1
382
+ uploaded_files.append(file) if file[:success]
383
+
384
+ if uploaded_files.size >= chunk_size or progressbar.finished?
385
+ blob_ids = uploaded_files.map {|f| f['bv_id']}
386
+ dirs_to_upload = dirs.clone
387
+ uploaded_files = []
388
+ dirs = []
389
+ end
390
+ }
391
+
392
+ if blob_ids.present?
393
+ refresh_storage_token
394
+ Cnvrg::Logger.info("Finished upload chunk of #{chunk_size} files, Sending Upload files save")
395
+
396
+
397
+ retry_count = 0
398
+ loop do
399
+ upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids, dirs: dirs_to_upload})
400
+
401
+ if not (Cnvrg::CLI.is_response_success(upload_resp, false))
402
+ retry_count += 1
403
+ Cnvrg::Logger.log_error_message("Failed request save files: #{Time.current}, retry: #{retry_count}")
404
+ Cnvrg::Logger.info("Got an error message from server, #{upload_resp.try(:fetch, "message")}")
405
+ if retry_count > 20
406
+ puts "Failed to save files: #{Time.current}, trying next chunk"
407
+ break
408
+ end
409
+ sleep 5
410
+ next
411
+ end
412
+ Cnvrg::Logger.info("Chunk saved on server")
413
+ break
414
+ end
387
415
  end
388
- # cli.log_message("Saved file chunk to server", Thor::Shell::Color::GREEN)
389
- uploaded_files = []
390
- dirs = []
416
+ else
417
+ sleep(0.1)
391
418
  end
392
- else
393
- sleep(0.1)
394
- end
395
419
 
396
- if progressbar.finished?
397
- # puts "finished"
398
- file_queue.close()
399
- progress_queue.close()
400
- Thread.exit
420
+ if progressbar.finished?
421
+ Cnvrg::Logger.info("Progress bar finished closing queues")
422
+ file_queue.close()
423
+ progress_queue.close()
424
+ Thread.exit
425
+ end
401
426
  end
402
427
  end
403
428
  end
@@ -405,9 +430,11 @@ module Cnvrg
405
430
  file_chunks = files.each_slice(chunk_size).to_a
406
431
  # Fetch the required files from the server:
407
432
  Parallel.map((file_chunks), in_threads: 10) do |files_chunk|
408
-
433
+ Cnvrg::Logger.info("Generating chunk idx")
409
434
  tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads)
435
+ Cnvrg::Logger.info("Getting files info from server")
410
436
  results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
437
+ next unless results
411
438
 
412
439
  if results['files'].blank?
413
440
  progress_mutex.synchronize { progressbar.progress += tree.keys.length }
@@ -430,12 +457,11 @@ module Cnvrg
430
457
  file_queue.push tree[key].merge(files_to_upload[key])
431
458
  end
432
459
  end
433
-
434
- progress_thread.join()
460
+ Cnvrg::Logger.info("Waiting to progress and workers to finish")
461
+ progress_threads.each(&:join)
435
462
  worker_threads.each(&:join)
436
-
463
+ Thread.report_on_exception = true
437
464
  rescue => e
438
- puts e
439
465
  Cnvrg::Logger.log_method(bind: binding)
440
466
  Cnvrg::Logger.log_error(e)
441
467
  raise e
@@ -499,7 +525,7 @@ module Cnvrg
499
525
  upload_resp = Cnvrg::API.request(@base_resource + "upload_file", 'POST_FILE', {absolute_path: absolute_path, relative_path: relative_path,
500
526
  commit_sha1: commit_sha1, file_name: file_name,
501
527
  file_size: file_size, file_content_type: content_type, sha1: sha1})
502
- puts upload_resp
528
+
503
529
 
504
530
  end
505
531
 
@@ -546,7 +572,7 @@ module Cnvrg
546
572
  return false
547
573
  end
548
574
  rescue => e
549
- puts e.message
575
+ #puts e.message
550
576
  return false
551
577
  end
552
578
  end
@@ -791,7 +817,7 @@ module Cnvrg
791
817
  return resp
792
818
 
793
819
  rescue => e
794
- puts e.message
820
+ #puts e.message
795
821
  return false
796
822
 
797
823
  end
@@ -557,7 +557,12 @@ module Cnvrg
557
557
  if File.directory? file
558
558
  tree[label + "/"] = nil
559
559
  else
560
- sha1 = OpenSSL::Digest::SHA1.file(file).hexdigest
560
+ begin
561
+ sha1 = OpenSSL::Digest::SHA1.file(file).hexdigest
562
+ rescue => e
563
+ #puts "Could'nt calculate sha1 for: #{file}, Error: #{e.message}"
564
+ next
565
+ end
561
566
  file_name = File.basename file
562
567
  file_size = File.size(file).to_f
563
568
  mime_type = MimeMagic.by_path(file)
@@ -884,13 +889,8 @@ module Cnvrg
884
889
  end
885
890
 
886
891
  def self.stop_if_dataset_present(dataset_home, dataset_name, commit: nil)
887
-
888
892
  cli = Cnvrg::CLI.new()
889
893
  config = YAML.load_file(dataset_home + "/.cnvrg/config.yml")
890
- if commit.present?
891
- local_commit = YAML.load_file(dataset_home + "/.cnvrg/idx.yml")[:commit] rescue nil
892
- return if commit != local_commit or local_commit.blank?
893
- end
894
894
  if config[:dataset_name] == dataset_name
895
895
  cli.log_message("Dataset already present, clone aborted")
896
896
  exit(0)
@@ -898,6 +898,5 @@ module Cnvrg
898
898
  rescue => e
899
899
  nil
900
900
  end
901
-
902
901
  end
903
902
  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.8'
2
+ VERSION = '1.10.18'
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.8
4
+ version: 1.10.18
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-20 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