cnvrg 1.11.2 → 1.11.8
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 +14 -5
- data/lib/cnvrg/datafiles.rb +1 -1
- data/lib/cnvrg/dataset.rb +24 -9
- data/lib/cnvrg/downloader/client.rb +24 -16
- data/lib/cnvrg/downloader/clients/gcp_client.rb +1 -1
- data/lib/cnvrg/files.rb +2 -2
- data/lib/cnvrg/helpers.rb +1 -1
- data/lib/cnvrg/storage.rb +1 -1
- 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: 75a73acbac75b972943707353f376c6c6cbda9fabc9c29b4a4dc5a454e9f531c
|
4
|
+
data.tar.gz: fd8b9ae0ea9c0ddeef86c6f25a8679457a66a6fd0dfdb4f06f8d7fa5cdf8e63b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c034b4c2bab31d420d8343d1007824baf78ada4ca20f245848d12ed61f37941ebe2d6a9e707d6d5f80f989b519623b640d941197a1a9ff3b8f5035c0142e6d2e
|
7
|
+
data.tar.gz: aff33e7fecc6419102cc02082116efd341b53f395f8362258015369839d87b68131bced0125b083ef3afc6bd7d233d3ad29fde9e549b07e1d74f285f5748a592
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -896,10 +896,12 @@ module Cnvrg
|
|
896
896
|
return
|
897
897
|
end
|
898
898
|
|
899
|
+
|
899
900
|
if only_tree
|
900
|
-
|
901
|
-
return
|
901
|
+
Dataset.clone_tree(commit: commit, dataset_home: dataset_home)
|
902
|
+
return
|
902
903
|
end
|
904
|
+
|
903
905
|
commit = response["result"]["commit"]
|
904
906
|
files_count = response["result"]["file_count"]
|
905
907
|
files = @files.get_clone_chunk(commit: commit)
|
@@ -911,6 +913,7 @@ module Cnvrg
|
|
911
913
|
:total => files_count,
|
912
914
|
:autofinish => true)
|
913
915
|
|
916
|
+
Dataset.clone_tree(commit: commit, dataset_home: dataset_home, progressbar: progressbar)
|
914
917
|
|
915
918
|
while files['keys'].length > 0
|
916
919
|
Cnvrg::Logger.log_info("download multiple files, #{downloaded_files.size} files downloaded")
|
@@ -969,6 +972,7 @@ module Cnvrg
|
|
969
972
|
|
970
973
|
if Dataset.blank_clone(owner, dataset_name, dataset_slug)
|
971
974
|
dataset = Dataset.new(dataset_home)
|
975
|
+
downloader = dataset.get_storage_client
|
972
976
|
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
973
977
|
parallel_options = {
|
974
978
|
:progress => {
|
@@ -991,15 +995,20 @@ module Cnvrg
|
|
991
995
|
relative_path_dir = relative_path_dir.join("/")
|
992
996
|
abs_path = dataset_home + "/" + relative_path_dir
|
993
997
|
abs_path = dataset_home if flatten
|
998
|
+
fullpath = abs_path + "/" + file_name
|
994
999
|
|
995
1000
|
begin
|
996
|
-
FileUtils.mkdir_p(abs_path) unless File.exist? (
|
1001
|
+
FileUtils.mkdir_p(abs_path) unless File.exist? (fullpath)
|
997
1002
|
rescue
|
998
1003
|
log_message("Could not create directory: #{abs_path}", Thor::Shell::Color::RED)
|
999
1004
|
exit(1)
|
1000
1005
|
end
|
1001
1006
|
begin
|
1002
|
-
|
1007
|
+
unless File.exist?(fullpath)
|
1008
|
+
downloader.safe_operation("#{abs_path}/#{file_name}") do
|
1009
|
+
File.open(fullpath, "w") { |file| file.write open(f["url"]).read }
|
1010
|
+
end
|
1011
|
+
end
|
1003
1012
|
rescue => e
|
1004
1013
|
log_message("Could not download file: #{f["fullpath"]}", Thor::Shell::Color::RED)
|
1005
1014
|
exit(1)
|
@@ -1905,7 +1914,7 @@ module Cnvrg
|
|
1905
1914
|
log_message("Remove dir in order to clone #{project_name}", Thor::Shell::Color::RED)
|
1906
1915
|
exit(1)
|
1907
1916
|
end
|
1908
|
-
|
1917
|
+
|
1909
1918
|
end
|
1910
1919
|
clone_resp = Project.clone_dir(slug, owner, project_name,git)
|
1911
1920
|
project_home = Dir.pwd + "/" + project_name
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -1338,7 +1338,7 @@ module Cnvrg
|
|
1338
1338
|
# Cnvrg::Logger.log_info("Trying to download #{local_path} but its already exists, skipping..")
|
1339
1339
|
# next
|
1340
1340
|
# end
|
1341
|
-
resp = @downloader.
|
1341
|
+
resp = @downloader.safe_download(storage_path, local_path)
|
1342
1342
|
Cnvrg::Logger.log_info("Download #{local_path} success resp: #{resp}")
|
1343
1343
|
rescue => e
|
1344
1344
|
Cnvrg::Logger.log_error(e)
|
data/lib/cnvrg/dataset.rb
CHANGED
@@ -471,23 +471,38 @@ module Cnvrg
|
|
471
471
|
response.to_json
|
472
472
|
end
|
473
473
|
|
474
|
-
def self.clone_tree(commit: 'latest', dataset_home: nil)
|
474
|
+
def self.clone_tree(commit: 'latest', dataset_home: nil, progressbar: nil)
|
475
475
|
@dataset = Cnvrg::Dataset.new(dataset_home)
|
476
476
|
@files = Cnvrg::Datafiles.new(@dataset.owner, @dataset.slug, dataset: @dataset)
|
477
477
|
trees = @files.get_trees(commit: commit)
|
478
478
|
return false if trees.nil?
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
479
|
+
|
480
|
+
if progressbar
|
481
|
+
pb = progressbar
|
482
|
+
pb.total += trees.size
|
483
|
+
else
|
484
|
+
pb = ProgressBar.create(
|
485
|
+
:title => "Download Progress",
|
486
|
+
:progress_mark => '=',
|
487
|
+
:format => "%b>>%i| %p%% %t",
|
488
|
+
:starting_at => 0,
|
489
|
+
:total => trees.size,
|
490
|
+
:autofinish => true
|
491
|
+
)
|
492
|
+
end
|
493
|
+
|
485
494
|
trees.each do |tree|
|
486
495
|
pb.progress += 1
|
487
496
|
@files.download_dir(dataset_home, tree)
|
488
497
|
end
|
489
|
-
|
490
|
-
|
498
|
+
|
499
|
+
unless progressbar
|
500
|
+
# if progessbar sent it means that its not only tree so we dont want to finish the progress bar
|
501
|
+
# and we dont want to write success
|
502
|
+
|
503
|
+
pb.finish
|
504
|
+
@dataset.write_success
|
505
|
+
end
|
491
506
|
true
|
492
507
|
end
|
493
508
|
|
@@ -30,10 +30,14 @@ module Cnvrg
|
|
30
30
|
file.gsub(prefix, '').gsub(/^\/*/, '')
|
31
31
|
end
|
32
32
|
|
33
|
-
def download(storage_path, local_path)
|
33
|
+
def download(storage_path, local_path, decrypt: true)
|
34
34
|
### need to be implemented..
|
35
35
|
end
|
36
36
|
|
37
|
+
def safe_download(storage_path, local_path, decrypt: true)
|
38
|
+
safe_operation(local_path) { self.download(storage_path, local_path, decrypt: decrypt) }
|
39
|
+
end
|
40
|
+
|
37
41
|
def upload(storage_path, local_path)
|
38
42
|
### need to be implemented..
|
39
43
|
end
|
@@ -51,17 +55,34 @@ module Cnvrg
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def safe_upload(storage_path, local_path)
|
58
|
+
safe_operation(local_path) { self.upload(storage_path, local_path) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.factory(params)
|
62
|
+
params = params.as_json
|
63
|
+
case params["storage"]
|
64
|
+
when 's3', 'minio'
|
65
|
+
return Cnvrg::Downloader::Clients::S3Client.new(sts_path: params["path_sts"], access_key: params["sts_a"], secret: params["sts_s"], session_token: params["sts_st"], region: params["region"], bucket: params["bucket"], encryption: params["encryption"], endpoint: params["endpoint"], storage: params["storage"])
|
66
|
+
when 'azure'
|
67
|
+
azure_params = params.symbolize_keys.slice(*[:storage_account_name, :storage_access_key, :container, :sts])
|
68
|
+
return Cnvrg::Downloader::Clients::AzureClient.new(**azure_params)
|
69
|
+
when 'gcp'
|
70
|
+
return Cnvrg::Downloader::Clients::GcpClient.new(project_id: params["project_id"], credentials: params["credentials"], bucket_name: params["bucket_name"], sts: params["sts"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def safe_operation(local_path)
|
54
75
|
n = 1
|
55
76
|
error = nil
|
56
77
|
while n <= RETRIES
|
57
78
|
begin
|
58
|
-
|
79
|
+
yield
|
59
80
|
error = nil
|
60
81
|
break
|
61
82
|
rescue => e
|
62
83
|
backoff_time_seconds = backoff_time(n)
|
63
84
|
|
64
|
-
message = "Got error: #{e.class.name} with message: #{e.message} while uploading a single file: #{local_path}, retry: #{n} of: #{RETRIES}"
|
85
|
+
message = "Got error: #{e.class.name} with message: #{e.message} while uploading / downloading a single file: #{local_path}, retry: #{n} of: #{RETRIES}"
|
65
86
|
if n < RETRIES
|
66
87
|
message += ", next retry in: #{backoff_time_seconds} seconds"
|
67
88
|
else
|
@@ -79,19 +100,6 @@ module Cnvrg
|
|
79
100
|
true
|
80
101
|
end
|
81
102
|
|
82
|
-
def self.factory(params)
|
83
|
-
params = params.as_json
|
84
|
-
case params["storage"]
|
85
|
-
when 's3', 'minio'
|
86
|
-
return Cnvrg::Downloader::Clients::S3Client.new(sts_path: params["path_sts"], access_key: params["sts_a"], secret: params["sts_s"], session_token: params["sts_st"], region: params["region"], bucket: params["bucket"], encryption: params["encryption"], endpoint: params["endpoint"], storage: params["storage"])
|
87
|
-
when 'azure'
|
88
|
-
azure_params = params.symbolize_keys.slice(*[:storage_account_name, :storage_access_key, :container, :sts])
|
89
|
-
return Cnvrg::Downloader::Clients::AzureClient.new(**azure_params)
|
90
|
-
when 'gcp'
|
91
|
-
return Cnvrg::Downloader::Clients::GcpClient.new(project_id: params["project_id"], credentials: params["credentials"], bucket_name: params["bucket_name"], sts: params["sts"])
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
103
|
private
|
96
104
|
|
97
105
|
def random_number_milliseconds
|
data/lib/cnvrg/files.rb
CHANGED
@@ -789,7 +789,7 @@ module Cnvrg
|
|
789
789
|
end
|
790
790
|
local_path = project_home+"/"+file_path
|
791
791
|
storage_path = f["path"]
|
792
|
-
@client.
|
792
|
+
@client.safe_download(storage_path, local_path)
|
793
793
|
progress.progress += 1 if progress.present?
|
794
794
|
download_succ_count += 1
|
795
795
|
rescue => e
|
@@ -962,7 +962,7 @@ module Cnvrg
|
|
962
962
|
|
963
963
|
def download_file(file_path: '', key: '', iv: '', bucket: '', path: '', client: nil)
|
964
964
|
local_path = @project_home+"/"+file_path
|
965
|
-
@client.
|
965
|
+
@client.safe_download(path, local_path)
|
966
966
|
end
|
967
967
|
|
968
968
|
def delete(file)
|
data/lib/cnvrg/helpers.rb
CHANGED
data/lib/cnvrg/storage.rb
CHANGED
@@ -34,7 +34,7 @@ module Cnvrg
|
|
34
34
|
@element.get_clone_chunk(commit: commit, chunk_size: params[:limit], offset: params[:offset])
|
35
35
|
end
|
36
36
|
action = Proc.new do |storage, local|
|
37
|
-
@client.
|
37
|
+
@client.safe_download(storage, local)
|
38
38
|
end
|
39
39
|
|
40
40
|
@stats = @element.get_stats
|
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.11.
|
4
|
+
version: 1.11.8
|
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-11-
|
13
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|