cnvrg 1.11.23 → 1.11.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cnvrg/api.rb +4 -0
- data/lib/cnvrg/cli.rb +1 -0
- data/lib/cnvrg/datafiles.rb +46 -12
- data/lib/cnvrg/dataset.rb +3 -1
- data/lib/cnvrg/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a5d09f38ee4ce25caecdaf73b77e37fadff3b745454030cb15863210c1b319
|
4
|
+
data.tar.gz: 1f3e27bc4fa778ff048e7257f2ce753009ceaf0801c4ca3f4facfdc3011ad940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d79f14723eff1d8df81907183fabbe97270fd49610d4aa456fa820e4c19994c3d2bd1b7c64160f4d66a0636ff385a32b86f6fed2bedf9c0ed98c7968267c23
|
7
|
+
data.tar.gz: 80b4644fc6f560e54280ab726983f4e5d89978255991b29c510452b5514019025a3dcae45e4ad5f9a36e97823909eb6d1f2ee892cc63ef5090fa78ecacf595fe
|
data/lib/cnvrg/api.rb
CHANGED
@@ -31,6 +31,10 @@ module Cnvrg
|
|
31
31
|
end
|
32
32
|
def self.request(resource, method = 'GET', data = {}, parse_request = true)
|
33
33
|
resource = URI::encode resource
|
34
|
+
|
35
|
+
# We need to remoe all double slashes from the url to work with the proxy
|
36
|
+
resource = resource.gsub(/[\/]{2,}/, "/").gsub("https:/", "https://").gsub("http:/", "http://")
|
37
|
+
|
34
38
|
begin
|
35
39
|
n = Netrc.read
|
36
40
|
rescue => e
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -1210,6 +1210,7 @@ module Cnvrg
|
|
1210
1210
|
@dataset = Dataset.new(dataset_info: {:owner => owner, :slug => slug})
|
1211
1211
|
@datafiles = Cnvrg::Datafiles.new(owner, slug, dataset: @dataset)
|
1212
1212
|
@files = @datafiles.verify_files_exists(files)
|
1213
|
+
@files = @files.uniq { |t| t.gsub('./', '')}
|
1213
1214
|
|
1214
1215
|
if @files.blank?
|
1215
1216
|
raise SignalException.new(1, "Cant find files to upload, exiting.")
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -47,6 +47,7 @@ module Cnvrg
|
|
47
47
|
file = file[0..-2] if file.end_with? '/'
|
48
48
|
if File.exists? file
|
49
49
|
if File.directory? file
|
50
|
+
paths << file unless file == '.'
|
50
51
|
paths += Dir.glob("#{file}/**/*")
|
51
52
|
else
|
52
53
|
paths << file
|
@@ -351,11 +352,11 @@ module Cnvrg
|
|
351
352
|
progress_mutex = Mutex.new
|
352
353
|
file_queue = Queue.new
|
353
354
|
progress_queue = Queue.new
|
355
|
+
dirs_queue = Queue.new
|
354
356
|
worker_threads = []
|
355
357
|
progress_threads = []
|
356
358
|
|
357
359
|
# Vars to keep track of uploaded files and directories
|
358
|
-
dirs = []
|
359
360
|
uploaded_files = []
|
360
361
|
|
361
362
|
begin
|
@@ -378,6 +379,29 @@ module Cnvrg
|
|
378
379
|
end
|
379
380
|
end
|
380
381
|
|
382
|
+
dir_thread = Thread.new do
|
383
|
+
dirs_to_create = []
|
384
|
+
loop do
|
385
|
+
progress_mutex.synchronize {
|
386
|
+
dir = dirs_queue.deq(non_block: true) rescue nil
|
387
|
+
dirs_to_create << dir unless dir.nil?
|
388
|
+
}
|
389
|
+
if dirs_to_create.size >= 1000 || progressbar.finished?
|
390
|
+
resp = Cnvrg::API.request(@base_resource + "create_dirs", "POST", {dirs: dirs_to_create, commit_sha1: commit_sha1})
|
391
|
+
|
392
|
+
break if resp == false # if resp is false it means 404 which is old server
|
393
|
+
unless Cnvrg::CLI.is_response_success(resp, false)
|
394
|
+
time = Time.current
|
395
|
+
Cnvrg::Logger.log_error_message("Failed to create dirs: #{time}, #{resp.try(:fetch, "message")}")
|
396
|
+
dirs_to_create = []
|
397
|
+
next
|
398
|
+
end
|
399
|
+
dirs_to_create = []
|
400
|
+
end
|
401
|
+
break if progressbar.finished? && dirs_queue.empty? && dirs_to_create.empty?
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
381
405
|
# init the thread that handles the file upload progress and saving them in the server
|
382
406
|
threads.times do |i|
|
383
407
|
progress_threads[i] = Thread.new do
|
@@ -385,7 +409,6 @@ module Cnvrg
|
|
385
409
|
file = progress_queue.deq(non_block: true) rescue nil # to prevent deadlocks
|
386
410
|
unless file.nil?
|
387
411
|
blob_ids = []
|
388
|
-
dirs_to_upload = []
|
389
412
|
|
390
413
|
progress_mutex.synchronize {
|
391
414
|
progressbar.progress += 1
|
@@ -393,9 +416,7 @@ module Cnvrg
|
|
393
416
|
|
394
417
|
if uploaded_files.size >= chunk_size or progressbar.finished?
|
395
418
|
blob_ids = uploaded_files.map {|f| f['bv_id']}
|
396
|
-
dirs_to_upload = dirs.clone
|
397
419
|
uploaded_files = []
|
398
|
-
dirs = []
|
399
420
|
end
|
400
421
|
}
|
401
422
|
|
@@ -403,10 +424,9 @@ module Cnvrg
|
|
403
424
|
refresh_storage_token
|
404
425
|
Cnvrg::Logger.info("Finished upload chunk of #{chunk_size} files, Sending Upload files save")
|
405
426
|
|
406
|
-
|
407
427
|
retry_count = 0
|
408
428
|
loop do
|
409
|
-
upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids
|
429
|
+
upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids})
|
410
430
|
|
411
431
|
if not (Cnvrg::CLI.is_response_success(upload_resp, false))
|
412
432
|
retry_count += 1
|
@@ -429,8 +449,8 @@ module Cnvrg
|
|
429
449
|
|
430
450
|
if progressbar.finished?
|
431
451
|
Cnvrg::Logger.info("Progress bar finished closing queues")
|
432
|
-
file_queue.close
|
433
|
-
progress_queue.close
|
452
|
+
file_queue.close
|
453
|
+
progress_queue.close
|
434
454
|
Thread.exit
|
435
455
|
end
|
436
456
|
end
|
@@ -443,7 +463,21 @@ module Cnvrg
|
|
443
463
|
files_chunk = chunk.map{|p| p.gsub(/^\.\//, '')}
|
444
464
|
Cnvrg::Logger.info("Generating chunk idx")
|
445
465
|
tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads, cli: cli)
|
466
|
+
|
467
|
+
progress_mutex.synchronize {
|
468
|
+
# Handle directories:
|
469
|
+
new_dirs = tree.keys.select { |k| tree[k].nil? }
|
470
|
+
|
471
|
+
if new_dirs.blank?
|
472
|
+
## we need to send 1 file so we will inflated dirs from in case when we dont have folders in the tree
|
473
|
+
file = tree.keys.find { |k| tree[k] != nil }
|
474
|
+
dirs_queue.push file
|
475
|
+
end
|
476
|
+
|
477
|
+
new_dirs.each { |dir| dirs_queue.push dir }
|
478
|
+
}
|
446
479
|
Cnvrg::Logger.info("Getting files info from server")
|
480
|
+
|
447
481
|
results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
|
448
482
|
next unless results
|
449
483
|
|
@@ -452,11 +486,8 @@ module Cnvrg
|
|
452
486
|
next
|
453
487
|
end
|
454
488
|
|
455
|
-
# Handle directories:
|
456
|
-
new_dirs = tree.keys.select {|k| tree[k].nil?}
|
457
|
-
dirs += new_dirs
|
458
|
-
|
459
489
|
files_to_upload = results['files']
|
490
|
+
|
460
491
|
progress_mutex.synchronize {
|
461
492
|
progressbar.progress += tree.keys.length - files_to_upload.length
|
462
493
|
}
|
@@ -468,7 +499,10 @@ module Cnvrg
|
|
468
499
|
file_queue.push tree[key].merge(files_to_upload[key])
|
469
500
|
end
|
470
501
|
end
|
502
|
+
|
471
503
|
Cnvrg::Logger.info("Waiting to progress and workers to finish")
|
504
|
+
dir_thread.join
|
505
|
+
dirs_queue.close
|
472
506
|
progress_threads.each(&:join)
|
473
507
|
worker_threads.each(&:join)
|
474
508
|
Thread.report_on_exception = true
|
data/lib/cnvrg/dataset.rb
CHANGED
@@ -564,7 +564,8 @@ module Cnvrg
|
|
564
564
|
safe_path = file
|
565
565
|
safe_path = file[1..-1] if file.start_with? "/"
|
566
566
|
|
567
|
-
|
567
|
+
dataset_local_path = self.local_path + "/"
|
568
|
+
label = safe_path.start_with?(dataset_local_path) ? safe_path.sub(dataset_local_path, "") : safe_path
|
568
569
|
label = "#{prefix}/#{label}" if prefix.present?
|
569
570
|
if not Cnvrg::Files.valid_file_name?(label)
|
570
571
|
if cli
|
@@ -598,6 +599,7 @@ module Cnvrg
|
|
598
599
|
}
|
599
600
|
end
|
600
601
|
end
|
602
|
+
|
601
603
|
if prefix.present? #add the prefix as dirs to the files
|
602
604
|
#lets say the prefix is a/b/c so we want that a/, a/b/, a/b/c/ will be in our files_list
|
603
605
|
dirs = prefix.split('/')
|
data/lib/cnvrg/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cnvrg
|
2
|
-
VERSION = '1.11.
|
3
|
-
end
|
2
|
+
VERSION = '1.11.24'
|
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.11.
|
4
|
+
version: 1.11.24
|
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-02-
|
13
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|