cnvrg 1.11.5 → 1.11.10
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 +18 -20
- 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/experiment.rb +2 -1
- data/lib/cnvrg/files.rb +2 -2
- data/lib/cnvrg/storage.rb +1 -1
- data/lib/cnvrg/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54dfcb511e29a518772481a3d99a6b30107234c4a218655babc69ddc36496d6d
|
4
|
+
data.tar.gz: 42ea59d4ef4fedef1afd2ba5fb8dcc7e86e439a2e9cc2dfa084409769dc7daf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c82e60bebc3777880873744d66a366cd2a8893443c62b82606f2986afaa5812a6cf7816f0f2fd9ba35f28819baede432e65c89440c7c594e94d767b31f102c5
|
7
|
+
data.tar.gz: e345d41daab3f9109f47f0d56fb0fd0c1d6d0991bb43b01b5718f1b1f35c182af35989eef36030f384cbbc758524656fa1e08c75d5bbc2abccbeae5be26114a9
|
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") { |file| file.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)
|
@@ -3062,6 +3068,7 @@ module Cnvrg
|
|
3062
3068
|
method_option :notify_on_success, :type => :boolean, :aliases => ["-nos", "--notify_on_success"], :default => nil
|
3063
3069
|
method_option :emails, :type => :string, :aliases => ["-es", "--emails"], :default => "", :desc => "additional emails to notify on success / or error, comma separated"
|
3064
3070
|
method_option :wait, :type => :boolean, :aliases => ["-w", "--wait"], :default => false, :desc => "keep command session open until experiment finished to return exit status"
|
3071
|
+
method_option :debug, :type => :boolean, :aliases => ["--debug"], :default => true
|
3065
3072
|
|
3066
3073
|
def run(*cmd)
|
3067
3074
|
verify_logged_in(true)
|
@@ -3070,6 +3077,7 @@ module Cnvrg
|
|
3070
3077
|
sync_before = options["sync_before"]
|
3071
3078
|
sync_after = options["sync_after"]
|
3072
3079
|
log = options["log"]
|
3080
|
+
debug = options["debug"]
|
3073
3081
|
title = options["title"]
|
3074
3082
|
commit = options["commit"] || nil
|
3075
3083
|
email_notification = options["email_notification"]
|
@@ -3103,6 +3111,7 @@ module Cnvrg
|
|
3103
3111
|
wait = false
|
3104
3112
|
end
|
3105
3113
|
|
3114
|
+
|
3106
3115
|
if !data.present? and data_query.present?
|
3107
3116
|
log_message("Please provide data with data_query", Thor::Shell::Color::RED)
|
3108
3117
|
exit(1)
|
@@ -3149,7 +3158,7 @@ module Cnvrg
|
|
3149
3158
|
:image => image, :grid => grid, :data => data, :data_commit => data_commit, :ignore => ignore, :force => force, :sync_before_terminate => sync_before_terminate,
|
3150
3159
|
:max_time => max_time,
|
3151
3160
|
:periodic_sync => periodic_sync, :dataset_only_tree=> dataset_only_tree,
|
3152
|
-
:output_dir=>output_dir, :data_query=>data_query, :git_commit =>git_commit, :git_branch=> git_branch,
|
3161
|
+
:output_dir=>output_dir, :data_query=>data_query, :git_commit =>git_commit, :git_branch=> git_branch, :debug => debug,
|
3153
3162
|
:restart_if_stuck =>restart_if_stuck, :local_folders => local_folders, :datasets => datasets, :prerun => prerun, :requirements => requirements,
|
3154
3163
|
:email_notification_error => email_notification_error, :email_notification_success => email_notification_success, :emails => emails, :wait => wait
|
3155
3164
|
|
@@ -3475,6 +3484,7 @@ module Cnvrg
|
|
3475
3484
|
method_option :email_notification_success, :type => :boolean, :aliases => ["-nos", "--email_notification_success"], :default => true
|
3476
3485
|
method_option :emails, :type => :string, :aliases => ["-es", "--emails"], :default => "", :desc => "additional emails to notify on success / or error"
|
3477
3486
|
method_option :wait, :type => :boolean, :aliases => ["-w", "--wait"], :default => false, :desc => "keep command session open until experiment finished to return exit status"
|
3487
|
+
method_option :debug, :type => :boolean, :aliases => ["--debug"], :default => true
|
3478
3488
|
|
3479
3489
|
def exec_remote(*cmd)
|
3480
3490
|
|
@@ -3492,6 +3502,7 @@ module Cnvrg
|
|
3492
3502
|
data_query = options["data_query"] || nil
|
3493
3503
|
sync_before = options["sync_before"]
|
3494
3504
|
force = options["force"]
|
3505
|
+
debug = options["debug"]
|
3495
3506
|
prerun = options["prerun"]
|
3496
3507
|
requirements = options["requirements"]
|
3497
3508
|
email_notification_error = options["email_notification_error"]
|
@@ -3535,8 +3546,8 @@ module Cnvrg
|
|
3535
3546
|
local_folders_options = options["local_folders"]
|
3536
3547
|
options_hash.except!("schedule", "recurring", "machine_type", "image", "upload_output", "grid", "data", "data_commit", "title",
|
3537
3548
|
"local", "small", "medium", "large", "gpu", "gpuxl", "gpuxxl","max_time","dataset_only_tree",
|
3538
|
-
"data_query", "git_commit","git_branch",
|
3539
|
-
"requirements", "prerun", "email_notification_error", "email_notification_success", "emails", "wait")
|
3549
|
+
"data_query", "git_commit","git_branch","restart_if_stuck","local_folders","output_dir", "commit", "datasets",
|
3550
|
+
"requirements", "prerun", "email_notification_error", "email_notification_success", "emails", "wait","debug")
|
3540
3551
|
exec_options = options_hash.map {|x| "--#{x[0]}=#{x[1]}"}.flatten.join(" ")
|
3541
3552
|
command = "#{exec_options} #{remote} #{upload_output_option} #{cmd.flatten.join(" ")}"
|
3542
3553
|
commit_to_run = options["commit"] || nil
|
@@ -3579,20 +3590,6 @@ module Cnvrg
|
|
3579
3590
|
end
|
3580
3591
|
end
|
3581
3592
|
|
3582
|
-
if command.include? "'"
|
3583
|
-
oc = command.to_enum(:scan, /'/).map {Regexp.last_match}
|
3584
|
-
pairs = oc.enum_for(:each_slice, 2).to_a
|
3585
|
-
pairs.each_with_index do |p, i|
|
3586
|
-
add = 0
|
3587
|
-
if i != 0
|
3588
|
-
add = 2 * i
|
3589
|
-
end
|
3590
|
-
total_loc = command[p[0].offset(0)[0] + add..p[1].offset(0)[0] + add]
|
3591
|
-
command[p[0].offset(0)[0] + add..p[1].offset(0)[0] + add] = "\"#{total_loc}\""
|
3592
|
-
end
|
3593
|
-
|
3594
|
-
|
3595
|
-
end
|
3596
3593
|
log_message("Running remote experiment", Thor::Shell::Color::BLUE)
|
3597
3594
|
exp = Experiment.new(project.owner, project.slug)
|
3598
3595
|
if forced_commit and (commit_to_run.nil? or commit_to_run.empty?)
|
@@ -3603,7 +3600,7 @@ module Cnvrg
|
|
3603
3600
|
|
3604
3601
|
res = exp.exec_remote(command, commit_to_run, instance_type, image, schedule, local_timestamp, grid, path_to_cmd, data, data_commit,
|
3605
3602
|
periodic_sync, sync_before_terminate, max_time, ds_sync_options,output_dir,
|
3606
|
-
data_query, git_commit, git_branch, restart_if_stuck,local_folders_options, title, datasets, prerun: prerun, requirements: requirements, recurring: recurring,
|
3603
|
+
data_query, git_commit, git_branch,debug, restart_if_stuck,local_folders_options, title, datasets, prerun: prerun, requirements: requirements, recurring: recurring,
|
3607
3604
|
email_notification_error: email_notification_error, email_notification_success: email_notification_success, emails_to_notify: emails)
|
3608
3605
|
if Cnvrg::CLI.is_response_success(res)
|
3609
3606
|
check = Helpers.checkmark()
|
@@ -3655,6 +3652,7 @@ module Cnvrg
|
|
3655
3652
|
sleep 3
|
3656
3653
|
tries += 1
|
3657
3654
|
retry if tries <= 5
|
3655
|
+
exit(1)
|
3658
3656
|
end
|
3659
3657
|
end
|
3660
3658
|
end
|
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/experiment.rb
CHANGED
@@ -110,7 +110,7 @@ module Cnvrg
|
|
110
110
|
|
111
111
|
def exec_remote(command, commit_to_run, instance_type, image_slug,schedule,local_timestamp, grid,path_to_cmd,data, data_commit,periodic_sync,
|
112
112
|
sync_before_terminate, max_time, ds_sync_options=0,output_dir=nil,data_query=nil,
|
113
|
-
git_commit=nil, git_branch=nil, restart_if_stuck=nil, local_folders=nil,title=nil, datasets=nil, prerun: true, requirements: true, recurring: nil,
|
113
|
+
git_commit=nil, git_branch=nil,debug=true, restart_if_stuck=nil, local_folders=nil,title=nil, datasets=nil, prerun: true, requirements: true, recurring: nil,
|
114
114
|
email_notification_error: false, email_notification_success: false, emails_to_notify: nil)
|
115
115
|
response = Cnvrg::API.request("users/#{@owner}/projects/#{@project_slug}/experiment/remote", 'POST', {command: command, image_slug: image_slug,
|
116
116
|
commit_sha1: commit_to_run,
|
@@ -119,6 +119,7 @@ module Cnvrg
|
|
119
119
|
local_timestamp:local_timestamp,
|
120
120
|
datasets: datasets,
|
121
121
|
grid: grid,
|
122
|
+
debug:debug,
|
122
123
|
path_to_cmd:path_to_cmd,dataset_slug:data,
|
123
124
|
dataset_commit: data_commit,max_time:max_time,
|
124
125
|
periodic_sync:periodic_sync, sync_before_terminate:sync_before_terminate,
|
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.10
|
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-12-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -453,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
453
453
|
- !ruby/object:Gem::Version
|
454
454
|
version: '0'
|
455
455
|
requirements: []
|
456
|
-
rubygems_version: 3.
|
456
|
+
rubygems_version: 3.0.4
|
457
457
|
signing_key:
|
458
458
|
specification_version: 4
|
459
459
|
summary: A CLI tool for interacting with cnvrg.io.
|