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 +4 -4
- data/lib/cnvrg/cli.rb +40 -13
- data/lib/cnvrg/data.rb +12 -11
- data/lib/cnvrg/datafiles.rb +69 -43
- data/lib/cnvrg/dataset.rb +6 -7
- data/lib/cnvrg/downloader/clients/gcp_client.rb +2 -2
- data/lib/cnvrg/version.rb +1 -1
- 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: 8009827a102d9ea4bda3e07d95ad52a23fe7202b2670850952fb345acac7b906
|
4
|
+
data.tar.gz: aa91b22c83120d50f0631945d06f4d878e1cea4d2f9d950f6e29fbba17305f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2159ce3f1e3b55390b599a72b80c1b6de559554380d5b294922ddd001cff2c944cf6614bb582f184c62be6299826f4a1860257a5426c6534a254ea195bb9910c
|
7
|
+
data.tar.gz: ccb989d604602dbcfcee6f40725ae8a45875744f222b7aa717ddfe2760483361d03a16f6e016179acf82c0c493d9a3518a548d18dbb850a7cf0fc0b99aef0120
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -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"]}/
|
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
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
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,
|
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
|
-
|
5286
|
-
|
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
|
|
data/lib/cnvrg/data.rb
CHANGED
@@ -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
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
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
|
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -316,21 +316,21 @@ module Cnvrg
|
|
316
316
|
#Cnvrg::Logger.log_method(bind: binding)
|
317
317
|
retry_count += 1
|
318
318
|
|
319
|
-
|
320
|
-
puts upload_resp
|
319
|
+
Cnvrg::Logger.log_info("Failed request upload files: #{Time.current}, retry: #{retry_count}")
|
321
320
|
|
322
|
-
if retry_count >
|
323
|
-
|
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
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
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
|
-
|
389
|
-
|
390
|
-
dirs = []
|
416
|
+
else
|
417
|
+
sleep(0.1)
|
391
418
|
end
|
392
|
-
else
|
393
|
-
sleep(0.1)
|
394
|
-
end
|
395
419
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
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
|
-
|
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
|
-
|
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
|
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)
|
@@ -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:
|
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,7 +1,7 @@
|
|
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.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-
|
13
|
+
date: 2020-09-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|