cnvrg 1.10.12 → 1.10.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cnvrg/cli.rb +15 -8
- data/lib/cnvrg/data.rb +9 -9
- data/lib/cnvrg/datafiles.rb +73 -44
- data/lib/cnvrg/dataset.rb +6 -1
- data/lib/cnvrg/downloader/client.rb +1 -1
- data/lib/cnvrg/downloader/clients/gcp_client.rb +2 -2
- data/lib/cnvrg/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 057f3283dffe548f882ed6cbdcfbc176e12fa75291f8a4867c8eee74fefd701f
|
4
|
+
data.tar.gz: fe30a40d86418cca0c98156ed89212ccfb159ead16dd248388a05f9d5bb3a05f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b5ccc6f603a06affd160bc928c8ee99acf045eccf3905dcc1c23ceca8b4efdb185c3f78716bb111973df0420a5356dbf3565c52a9fe298f4fccdc886f3b07d7
|
7
|
+
data.tar.gz: 1cc6cbaa4737fb0151bed559352292908479ffce6e2bb1ba65812aef19d91b935265ec80f8a2a0f52111c02b3944aecb79d89e8d72518f4db094c75766834228
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -1194,7 +1194,6 @@ module Cnvrg
|
|
1194
1194
|
desc '', '', :hide => true
|
1195
1195
|
def data_put(dataset_url, files: [], dir: '', commit: '', chunk_size: 1000, force: false, override: false, threads: 15, message: nil)
|
1196
1196
|
begin
|
1197
|
-
verify_logged_in(false)
|
1198
1197
|
log_start(__method__, args, options)
|
1199
1198
|
|
1200
1199
|
owner, slug = get_owner_slug(dataset_url)
|
@@ -1208,15 +1207,17 @@ module Cnvrg
|
|
1208
1207
|
log_message("Uploading #{@files.size} files", Thor::Shell::Color::GREEN)
|
1209
1208
|
number_of_chunks = (@files.size.to_f / chunk_size).ceil
|
1210
1209
|
if commit.blank?
|
1210
|
+
Cnvrg::Logger.info("Creating commit")
|
1211
1211
|
response = @datafiles.start_commit(false, force, chunks: number_of_chunks, message: message )
|
1212
1212
|
unless response #means we failed in the start commit.
|
1213
1213
|
raise SignalException.new(1, "Cant put files into dataset, check the dataset id")
|
1214
1214
|
end
|
1215
1215
|
@commit = response['result']['commit_sha1']
|
1216
1216
|
elsif commit.eql? "latest"
|
1217
|
+
Cnvrg::Logger.info("Put files in latest commit")
|
1217
1218
|
response = @datafiles.last_valid_commit()
|
1218
1219
|
unless response #means we failed in the start commit.
|
1219
|
-
raise SignalException.new(1, "Cant put files into commit:#{commit}, check the dataset id and
|
1220
|
+
raise SignalException.new(1, "Cant put files into commit:#{commit}, check the dataset id and commit")
|
1220
1221
|
end
|
1221
1222
|
@commit = response['result']['sha1']
|
1222
1223
|
else
|
@@ -1233,15 +1234,15 @@ module Cnvrg
|
|
1233
1234
|
override: override,
|
1234
1235
|
chunk_size: chunk_size,
|
1235
1236
|
prefix: dir,
|
1236
|
-
threads: threads
|
1237
|
+
threads: threads,
|
1237
1238
|
)
|
1238
|
-
|
1239
|
+
Cnvrg::Logger.info("Finished upload files")
|
1239
1240
|
# This is for backwards compatibility only and should be removed in future versions:
|
1240
1241
|
res = @datafiles.put_commit(@commit)
|
1241
1242
|
unless res.is_success?
|
1242
1243
|
raise SignalException.new(1, res.msg)
|
1243
1244
|
end
|
1244
|
-
|
1245
|
+
Cnvrg::Logger.info("Saving commit on server")
|
1245
1246
|
res = @datafiles.end_commit(@commit,force, success: true, commit_type: "put")
|
1246
1247
|
msg = res['result']
|
1247
1248
|
response = Cnvrg::Result.new(Cnvrg::CLI.is_response_success(res, true), msg)
|
@@ -3094,6 +3095,11 @@ module Cnvrg
|
|
3094
3095
|
emails = options["emails"]
|
3095
3096
|
wait = options["wait"]
|
3096
3097
|
|
3098
|
+
if wait && local
|
3099
|
+
log_message("WARN: `wait` option is not valid for local experiment, ignoring it", Thor::Shell::Color::YELLOW)
|
3100
|
+
wait = false
|
3101
|
+
end
|
3102
|
+
|
3097
3103
|
if !data.present? and data_query.present?
|
3098
3104
|
log_message("Please provide data with data_query", Thor::Shell::Color::RED)
|
3099
3105
|
exit(1)
|
@@ -3635,7 +3641,8 @@ module Cnvrg
|
|
3635
3641
|
sleep 3
|
3636
3642
|
else
|
3637
3643
|
result.each do |slug, value|
|
3638
|
-
|
3644
|
+
exit_status = value['exit_status']
|
3645
|
+
puts "Experiment #{slug} was exited with status #{exit_status}"
|
3639
3646
|
end
|
3640
3647
|
break
|
3641
3648
|
end
|
@@ -5301,8 +5308,8 @@ module Cnvrg
|
|
5301
5308
|
count += 1
|
5302
5309
|
end
|
5303
5310
|
if File.exist? logfile_old
|
5304
|
-
|
5305
|
-
|
5311
|
+
#@files = Cnvrg::Files.new(Cnvrg::CLI.get_owner, "")
|
5312
|
+
#@files.upload_log_file(logfile_old, "log_#{date}.log", yesterday)
|
5306
5313
|
FileUtils.remove logfile_old
|
5307
5314
|
end
|
5308
5315
|
|
data/lib/cnvrg/data.rb
CHANGED
@@ -232,15 +232,15 @@ module Cnvrg
|
|
232
232
|
threads = options[:threads]
|
233
233
|
chunk_size = options[:chunk_size]
|
234
234
|
cli.data_put(
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
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
|
244
244
|
)
|
245
245
|
end
|
246
246
|
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -52,7 +52,10 @@ module Cnvrg
|
|
52
52
|
end
|
53
53
|
raise SignalException.new(1, "Cant find file #{file}") unless File.exists? "#{Dir.pwd}/#{file}"
|
54
54
|
end
|
55
|
-
paths.
|
55
|
+
paths.each_slice(1000) do |chunk|
|
56
|
+
chunk.each { |p| p.gsub!(/^\.\//, '') }
|
57
|
+
end
|
58
|
+
paths
|
56
59
|
end
|
57
60
|
|
58
61
|
def get_files_and_folders(paths)
|
@@ -316,21 +319,21 @@ module Cnvrg
|
|
316
319
|
#Cnvrg::Logger.log_method(bind: binding)
|
317
320
|
retry_count += 1
|
318
321
|
|
319
|
-
|
320
|
-
puts upload_resp
|
322
|
+
Cnvrg::Logger.log_info("Failed request upload files: #{Time.current}, retry: #{retry_count}")
|
321
323
|
|
322
|
-
if retry_count >
|
323
|
-
|
324
|
+
if retry_count > 20
|
325
|
+
puts "Failed to upload files: #{Time.current}, trying next chunk"
|
326
|
+
return nil
|
324
327
|
end
|
325
328
|
sleep 5
|
326
329
|
next
|
327
330
|
end
|
328
331
|
return upload_resp['result'].with_indifferent_access
|
329
332
|
end
|
330
|
-
|
331
333
|
end
|
332
334
|
|
333
335
|
def upload_multiple_files_optimized(files, commit_sha1, threads: 15, chunk_size: 1000, override: false, new_branch: false, prefix: '', partial_commit: nil)
|
336
|
+
Thread.report_on_exception = false
|
334
337
|
cli = CLI.new
|
335
338
|
cli.log_message("Using #{threads} threads with chunk size of #{chunk_size}.", Thor::Shell::Color::GREEN)
|
336
339
|
|
@@ -342,6 +345,7 @@ module Cnvrg
|
|
342
345
|
file_queue = Queue.new
|
343
346
|
progress_queue = Queue.new
|
344
347
|
worker_threads = []
|
348
|
+
progress_threads = []
|
345
349
|
|
346
350
|
# Vars to keep track of uploaded files and directories
|
347
351
|
dirs = []
|
@@ -359,45 +363,69 @@ module Cnvrg
|
|
359
363
|
cli.log_message("Error while uploading file: #{file[:absolute_path]}", Thor::Shell::Color::RED)
|
360
364
|
Cnvrg::Logger.log_error_message("Error while upload single file #{file["path"]}")
|
361
365
|
end
|
366
|
+
while progress_queue.size > 15000
|
367
|
+
sleep(0.1)
|
368
|
+
end
|
362
369
|
progress_queue << file
|
363
370
|
end
|
364
371
|
end
|
365
372
|
end
|
366
373
|
|
367
374
|
# init the thread that handles the file upload progress and saving them in the server
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
375
|
+
threads.times do |i|
|
376
|
+
progress_threads[i] = Thread.new do
|
377
|
+
loop do
|
378
|
+
file = progress_queue.deq(non_block: true) rescue nil # to prevent deadlocks
|
379
|
+
unless file.nil?
|
380
|
+
blob_ids = []
|
381
|
+
dirs_to_upload = []
|
382
|
+
|
383
|
+
progress_mutex.synchronize {
|
384
|
+
progressbar.progress += 1
|
385
|
+
uploaded_files.append(file) if file[:success]
|
386
|
+
|
387
|
+
if uploaded_files.size >= chunk_size or progressbar.finished?
|
388
|
+
blob_ids = uploaded_files.map {|f| f['bv_id']}
|
389
|
+
dirs_to_upload = dirs.clone
|
390
|
+
uploaded_files = []
|
391
|
+
dirs = []
|
392
|
+
end
|
393
|
+
}
|
394
|
+
|
395
|
+
if blob_ids.present?
|
396
|
+
refresh_storage_token
|
397
|
+
Cnvrg::Logger.info("Finished upload chunk of #{chunk_size} files, Sending Upload files save")
|
398
|
+
|
399
|
+
|
400
|
+
retry_count = 0
|
401
|
+
loop do
|
402
|
+
upload_resp = Cnvrg::API.request(@base_resource + "upload_files_save", "POST", {commit: commit_sha1, blob_ids: blob_ids, dirs: dirs_to_upload})
|
403
|
+
|
404
|
+
if not (Cnvrg::CLI.is_response_success(upload_resp, false))
|
405
|
+
retry_count += 1
|
406
|
+
Cnvrg::Logger.log_error_message("Failed request save files: #{Time.current}, retry: #{retry_count}")
|
407
|
+
Cnvrg::Logger.info("Got an error message from server, #{upload_resp.try(:fetch, "message")}")
|
408
|
+
if retry_count > 20
|
409
|
+
puts "Failed to save files: #{Time.current}, trying next chunk"
|
410
|
+
break
|
411
|
+
end
|
412
|
+
sleep 5
|
413
|
+
next
|
414
|
+
end
|
415
|
+
Cnvrg::Logger.info("Chunk saved on server")
|
416
|
+
break
|
417
|
+
end
|
387
418
|
end
|
388
|
-
|
389
|
-
|
390
|
-
dirs = []
|
419
|
+
else
|
420
|
+
sleep(0.1)
|
391
421
|
end
|
392
|
-
else
|
393
|
-
sleep(0.1)
|
394
|
-
end
|
395
422
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
423
|
+
if progressbar.finished?
|
424
|
+
Cnvrg::Logger.info("Progress bar finished closing queues")
|
425
|
+
file_queue.close()
|
426
|
+
progress_queue.close()
|
427
|
+
Thread.exit
|
428
|
+
end
|
401
429
|
end
|
402
430
|
end
|
403
431
|
end
|
@@ -405,9 +433,11 @@ module Cnvrg
|
|
405
433
|
file_chunks = files.each_slice(chunk_size).to_a
|
406
434
|
# Fetch the required files from the server:
|
407
435
|
Parallel.map((file_chunks), in_threads: 10) do |files_chunk|
|
408
|
-
|
436
|
+
Cnvrg::Logger.info("Generating chunk idx")
|
409
437
|
tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads)
|
438
|
+
Cnvrg::Logger.info("Getting files info from server")
|
410
439
|
results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
|
440
|
+
next unless results
|
411
441
|
|
412
442
|
if results['files'].blank?
|
413
443
|
progress_mutex.synchronize { progressbar.progress += tree.keys.length }
|
@@ -430,12 +460,11 @@ module Cnvrg
|
|
430
460
|
file_queue.push tree[key].merge(files_to_upload[key])
|
431
461
|
end
|
432
462
|
end
|
433
|
-
|
434
|
-
|
463
|
+
Cnvrg::Logger.info("Waiting to progress and workers to finish")
|
464
|
+
progress_threads.each(&:join)
|
435
465
|
worker_threads.each(&:join)
|
436
|
-
|
466
|
+
Thread.report_on_exception = true
|
437
467
|
rescue => e
|
438
|
-
puts e
|
439
468
|
Cnvrg::Logger.log_method(bind: binding)
|
440
469
|
Cnvrg::Logger.log_error(e)
|
441
470
|
raise e
|
@@ -499,7 +528,7 @@ module Cnvrg
|
|
499
528
|
upload_resp = Cnvrg::API.request(@base_resource + "upload_file", 'POST_FILE', {absolute_path: absolute_path, relative_path: relative_path,
|
500
529
|
commit_sha1: commit_sha1, file_name: file_name,
|
501
530
|
file_size: file_size, file_content_type: content_type, sha1: sha1})
|
502
|
-
|
531
|
+
|
503
532
|
|
504
533
|
end
|
505
534
|
|
@@ -546,7 +575,7 @@ module Cnvrg
|
|
546
575
|
return false
|
547
576
|
end
|
548
577
|
rescue => e
|
549
|
-
puts e.message
|
578
|
+
#puts e.message
|
550
579
|
return false
|
551
580
|
end
|
552
581
|
end
|
@@ -791,7 +820,7 @@ module Cnvrg
|
|
791
820
|
return resp
|
792
821
|
|
793
822
|
rescue => e
|
794
|
-
puts e.message
|
823
|
+
#puts e.message
|
795
824
|
return false
|
796
825
|
|
797
826
|
end
|
data/lib/cnvrg/dataset.rb
CHANGED
@@ -557,7 +557,12 @@ module Cnvrg
|
|
557
557
|
if File.directory? file
|
558
558
|
tree[label + "/"] = nil
|
559
559
|
else
|
560
|
-
|
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)
|
@@ -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:
|
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
|
data/lib/cnvrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
8
8
|
- Leah Kolben
|
9
9
|
- Omer Shacham
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-09-
|
13
|
+
date: 2020-09-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -438,7 +438,7 @@ files:
|
|
438
438
|
homepage: https://cnvrg.io
|
439
439
|
licenses: []
|
440
440
|
metadata: {}
|
441
|
-
post_install_message:
|
441
|
+
post_install_message:
|
442
442
|
rdoc_options: []
|
443
443
|
require_paths:
|
444
444
|
- lib
|
@@ -453,8 +453,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
453
453
|
- !ruby/object:Gem::Version
|
454
454
|
version: '0'
|
455
455
|
requirements: []
|
456
|
-
rubygems_version: 3.
|
457
|
-
signing_key:
|
456
|
+
rubygems_version: 3.1.2
|
457
|
+
signing_key:
|
458
458
|
specification_version: 4
|
459
459
|
summary: A CLI tool for interacting with cnvrg.io.
|
460
460
|
test_files: []
|