cnvrg 1.11.6 → 1.11.7
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 +8 -2
- data/lib/cnvrg/datafiles.rb +1 -1
- 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/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: 1402d0759d20d1c1d9182cebc35fe5539c14a8a1bb2c4eeddf791f43ff768082
|
4
|
+
data.tar.gz: 4146973b1a98ea3d26af0efb96ee481093e29fe9fce6fb88c54a539b34e5c0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53951eb4b7f82322640e75fdeae5ece07bb7189cc5b81257a9a78fd1398ab04c43ef0ed2784c1963f8d53dd983f874f2ed1ccc0ac4953ffced37deb75953d679
|
7
|
+
data.tar.gz: 8a046e229d0d14a2d36cb896c467aff3599e98b0e1cfb93e96fb72e80342751a47df4e1a90a57ff62e09ed92f1720afb783fe354dd34a5e06767e98c5bd8bdb6
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -972,6 +972,7 @@ module Cnvrg
|
|
972
972
|
|
973
973
|
if Dataset.blank_clone(owner, dataset_name, dataset_slug)
|
974
974
|
dataset = Dataset.new(dataset_home)
|
975
|
+
downloader = dataset.get_storage_client
|
975
976
|
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
976
977
|
parallel_options = {
|
977
978
|
:progress => {
|
@@ -994,15 +995,20 @@ module Cnvrg
|
|
994
995
|
relative_path_dir = relative_path_dir.join("/")
|
995
996
|
abs_path = dataset_home + "/" + relative_path_dir
|
996
997
|
abs_path = dataset_home if flatten
|
998
|
+
fullpath = abs_path + "/" + file_name
|
997
999
|
|
998
1000
|
begin
|
999
|
-
FileUtils.mkdir_p(abs_path) unless File.exist? (
|
1001
|
+
FileUtils.mkdir_p(abs_path) unless File.exist? (fullpath)
|
1000
1002
|
rescue
|
1001
1003
|
log_message("Could not create directory: #{abs_path}", Thor::Shell::Color::RED)
|
1002
1004
|
exit(1)
|
1003
1005
|
end
|
1004
1006
|
begin
|
1005
|
-
|
1007
|
+
unless File.exist?(fullpath)
|
1008
|
+
downloader.safe_operation("#{abs_path}/#{file_name}") do
|
1009
|
+
File.open(fullpath, "w") { |f| f.write open(f["url"]).read }
|
1010
|
+
end
|
1011
|
+
end
|
1006
1012
|
rescue => e
|
1007
1013
|
log_message("Could not download file: #{f["fullpath"]}", Thor::Shell::Color::RED)
|
1008
1014
|
exit(1)
|
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)
|
@@ -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/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.7
|
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-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|