cnvrg 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cnvrg/Images.rb +0 -1
- data/lib/cnvrg/cli.rb +25 -52
- data/lib/cnvrg/data.rb +19 -1
- data/lib/cnvrg/datafiles.rb +6 -0
- data/lib/cnvrg/dataset.rb +41 -12
- data/lib/cnvrg/experiment.rb +13 -4
- data/lib/cnvrg/files.rb +1 -0
- data/lib/cnvrg/helpers.rb +8 -0
- data/lib/cnvrg/logger.rb +5 -0
- data/lib/cnvrg/project.rb +1 -0
- data/lib/cnvrg/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e33d716e3fce0ef29d6684c29dec59f6edd04173d0330343d0510ec11bd087a
|
4
|
+
data.tar.gz: 9a019b36e6611ffd4b627c7fb9b9edecbde44be360f26034b668c52da804da8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad76658b08c85dcab2cade07327e5e6c7f4843e9eecbc6d2c768d4e3d166723e2f007d8260d83fd6d2f3cabbb25daf85bf7b247fe7b0bd45445f8af7cae2b141
|
7
|
+
data.tar.gz: 22da11b1b04ec3e55fbb9a3586651783411daa1fc1c5d06548890f71770b0e152740589b883394f84172f3e5d0f0519001abaa4416031bfa0856cd553be685c3
|
data/lib/cnvrg/Images.rb
CHANGED
data/lib/cnvrg/cli.rb
CHANGED
@@ -449,6 +449,22 @@ module Cnvrg
|
|
449
449
|
end
|
450
450
|
|
451
451
|
|
452
|
+
desc 'auth', "hidden..", hide: true
|
453
|
+
def auth
|
454
|
+
@token = ENV['CNVRG_TOKEN']
|
455
|
+
owner = ENV['CNVRG_OWNER']
|
456
|
+
user = ENV['CNVRG_USER']
|
457
|
+
api = ENV['CNVRG_API']
|
458
|
+
@email = ENV['CNVRG_EMAIL']
|
459
|
+
|
460
|
+
netrc = Netrc.read
|
461
|
+
netrc[Cnvrg::Helpers.netrc_domain] = @email, @token
|
462
|
+
netrc.save
|
463
|
+
|
464
|
+
set_owner(owner, user, api)
|
465
|
+
end
|
466
|
+
|
467
|
+
|
452
468
|
desc 'login', 'Authenticate with cnvrg.io platform'
|
453
469
|
|
454
470
|
def login
|
@@ -488,39 +504,6 @@ module Cnvrg
|
|
488
504
|
choose_owner = owners[0]
|
489
505
|
end
|
490
506
|
|
491
|
-
# if owners.empty?
|
492
|
-
# else
|
493
|
-
# owners << choose_owner
|
494
|
-
# chosen = false
|
495
|
-
# while !chosen
|
496
|
-
# owners_id = owners.each_with_index.map { |x, i| "#{i+1}. #{x}" }
|
497
|
-
# choose_owner = ask("Choose default owner:\n"+owners_id.join("\n")+"\n")
|
498
|
-
#
|
499
|
-
# if choose_owner =~ /[[:digit:]]/
|
500
|
-
# ow_index = choose_owner.to_i-1
|
501
|
-
# if ow_index<0 or ow_index >= owners.size
|
502
|
-
# say "No such owner, please choose again", Thor::Shell::Color::BLUE
|
503
|
-
# chosen = false
|
504
|
-
# next
|
505
|
-
# end
|
506
|
-
# choose_owner = owners[choose_owner.to_i-1]
|
507
|
-
# chosen = true
|
508
|
-
#
|
509
|
-
# else
|
510
|
-
#
|
511
|
-
# owners_lower = owners.map { |o| o.downcase }
|
512
|
-
# ow_index = owners_lower.index(choose_owner.downcase)
|
513
|
-
# if ow_index.nil?
|
514
|
-
# say "Could not find owner named #{choose_owner}", Thor::Shell::Color::RED
|
515
|
-
# else
|
516
|
-
# chosen = true
|
517
|
-
# end
|
518
|
-
# end
|
519
|
-
#
|
520
|
-
# end
|
521
|
-
|
522
|
-
|
523
|
-
# end
|
524
507
|
|
525
508
|
if set_owner(choose_owner, result["username"], urls[ow_index])
|
526
509
|
log_message("Setting default owner: #{choose_owner}", Thor::Shell::Color::GREEN)
|
@@ -831,13 +814,10 @@ module Cnvrg
|
|
831
814
|
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
832
815
|
@files = Cnvrg::Datafiles.new(owner, slug)
|
833
816
|
log_message("Downloading files", Thor::Shell::Color::BLUE)
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
# return
|
839
|
-
|
840
|
-
# end
|
817
|
+
if only_tree
|
818
|
+
success = Dataset.clone_tree(commit: commit, dataset_home: dataset_home)
|
819
|
+
return if success
|
820
|
+
end
|
841
821
|
commit = response["result"]["commit"]
|
842
822
|
files_count = response["result"]["file_count"]
|
843
823
|
files = @files.get_clone_chunk(commit: commit)
|
@@ -1688,7 +1668,7 @@ module Cnvrg
|
|
1688
1668
|
end
|
1689
1669
|
|
1690
1670
|
|
1691
|
-
desc '
|
1671
|
+
desc 'link_git CNVRG_PROJECT_URL', 'Link git project to existed cnvrg project'
|
1692
1672
|
method_option :git, :type => :boolean, :aliases => ["-g", "--git"], :default => false
|
1693
1673
|
def link_git(project_url)
|
1694
1674
|
begin
|
@@ -3069,9 +3049,6 @@ module Cnvrg
|
|
3069
3049
|
exp_success = false
|
3070
3050
|
log_message("command \"#{cmd}\" couldn't be executed, verify command is valid", Thor::Shell::Color::RED)
|
3071
3051
|
log_error(e)
|
3072
|
-
# rescue Open4::ChildExited
|
3073
|
-
# exp_success = false
|
3074
|
-
# log_message("The process exited!", Thor::Shell::Color::RED)
|
3075
3052
|
rescue => e
|
3076
3053
|
res = @exp.end(log, 1, start_commit, 0, 0)
|
3077
3054
|
log_message("Error occurred,aborting", Thor::Shell::Color::RED)
|
@@ -3080,6 +3057,7 @@ module Cnvrg
|
|
3080
3057
|
end
|
3081
3058
|
::Process.wait pid
|
3082
3059
|
end
|
3060
|
+
end_time = Time.now
|
3083
3061
|
process_running = false
|
3084
3062
|
|
3085
3063
|
if !log.empty?
|
@@ -3116,7 +3094,7 @@ module Cnvrg
|
|
3116
3094
|
# log_thread.join
|
3117
3095
|
stats_thread.join
|
3118
3096
|
|
3119
|
-
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3097
|
+
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average, end_time: end_time)
|
3120
3098
|
|
3121
3099
|
|
3122
3100
|
if !exp_success
|
@@ -3410,12 +3388,7 @@ module Cnvrg
|
|
3410
3388
|
|
3411
3389
|
|
3412
3390
|
image = is_project_with_docker(working_dir)
|
3413
|
-
|
3414
|
-
image = Images.new(working_dir, "cnvrg")
|
3415
|
-
image_slug = image.image_slug
|
3416
|
-
else
|
3417
|
-
image_slug = image.image_slug
|
3418
|
-
end
|
3391
|
+
image_slug = 'cnvrg'
|
3419
3392
|
|
3420
3393
|
|
3421
3394
|
invoke :sync, [false], []
|
@@ -5961,7 +5934,7 @@ module Cnvrg
|
|
5961
5934
|
|
5962
5935
|
|
5963
5936
|
def parse_io(block_io_str)
|
5964
|
-
block_io = block_io_str.gsub
|
5937
|
+
block_io = block_io_str.gsub(" ", "").split('/')
|
5965
5938
|
input = block_io[0]
|
5966
5939
|
output = block_io[1]
|
5967
5940
|
r = Regexp.new('(\d+(\.\d+)?)([A-Za-z]+)')
|
data/lib/cnvrg/data.rb
CHANGED
@@ -114,7 +114,7 @@ module Cnvrg
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
desc '
|
117
|
+
desc 'data put dataset_url', 'clone datset'
|
118
118
|
method_option :dir, :type => :string, :aliases => ["-d", "--dir"], :default => ''
|
119
119
|
def put(dataset_url, *files)
|
120
120
|
cli = Cnvrg::CLI.new()
|
@@ -151,6 +151,24 @@ module Cnvrg
|
|
151
151
|
|
152
152
|
end
|
153
153
|
|
154
|
+
desc 'data files', 'list dataset files'
|
155
|
+
method_option :offset, :type => :numeric, :aliases => ["-o", "--offset"], :default => 0
|
156
|
+
method_option :limit, :type => :numeric, :aliases => ["-l", "--limit"], :default => 1000
|
157
|
+
method_option :expires, :type => :numeric, :aliases => ["-ex", "--expires"], :default => 3600
|
158
|
+
method_option :commit_sha1, :type => :string, :aliases => ["-c", "--commit"], :default => nil
|
159
|
+
def files(dataset_url)
|
160
|
+
cli = Cnvrg::CLI.new()
|
161
|
+
cli.verify_logged_in(false)
|
162
|
+
cli.log_start(__method__, args, options)
|
163
|
+
@dataset = Dataset.new(dataset_url: dataset_url)
|
164
|
+
files = @dataset.list_files(
|
165
|
+
commit_sha1: options[:commit_sha1],
|
166
|
+
limit: options[:limit],
|
167
|
+
expires: options[:expires],
|
168
|
+
offset: options[:offset])
|
169
|
+
cli.log_message(files)
|
170
|
+
end
|
171
|
+
|
154
172
|
desc 'data queries', 'list of all queries'
|
155
173
|
def queries()
|
156
174
|
cli = Cnvrg::CLI.new()
|
data/lib/cnvrg/datafiles.rb
CHANGED
@@ -875,6 +875,12 @@ module Cnvrg
|
|
875
875
|
end
|
876
876
|
end
|
877
877
|
|
878
|
+
def get_trees(commit: "latest")
|
879
|
+
response = Cnvrg::API.request("#{@base_resource}/clone_trees", 'POST',{commit: commit})
|
880
|
+
return nil unless Cnvrg::CLI.is_response_success(response, false)
|
881
|
+
response['result']['files']
|
882
|
+
end
|
883
|
+
|
878
884
|
def get_clone_chunk(latest_id: nil, chunk_size: 1000, commit: 'latest')
|
879
885
|
response = Cnvrg::API.request("#{@base_resource}/clone_chunk", 'POST',{commit: commit, chunk_size: chunk_size, latest_id: latest_id})
|
880
886
|
return nil unless Cnvrg::CLI.is_response_success(response, false)
|
data/lib/cnvrg/dataset.rb
CHANGED
@@ -7,14 +7,21 @@ module Cnvrg
|
|
7
7
|
IDXParallelThreads ||= 15
|
8
8
|
IDXParallelProcesses ||= Parallel.processor_count
|
9
9
|
|
10
|
-
def initialize(project_home)
|
10
|
+
def initialize(project_home = '', dataset_url: '')
|
11
11
|
begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
if project_home.present?
|
13
|
+
@local_path = project_home
|
14
|
+
@working_dir = project_home
|
15
|
+
config = YAML.load_file(project_home+"/.cnvrg/config.yml")
|
16
|
+
@title = config[:dataset_name]
|
17
|
+
@slug = config[:dataset_slug]
|
18
|
+
@owner = config[:owner]
|
19
|
+
else
|
20
|
+
owner, slug = Cnvrg::Helpers.extract_owner_slug_from_url(dataset_url, 'datasets')
|
21
|
+
@title = slug
|
22
|
+
@slug = slug
|
23
|
+
@owner = owner
|
24
|
+
end
|
18
25
|
rescue => e
|
19
26
|
|
20
27
|
end
|
@@ -306,6 +313,32 @@ module Cnvrg
|
|
306
313
|
return true
|
307
314
|
end
|
308
315
|
|
316
|
+
def list_files(commit_sha1: "latest", limit: 1000, offset: 0, expires: 3600)
|
317
|
+
response = Cnvrg::API.request("users/#{self.owner}/datasets/#{self.slug}/list", 'GET', {commit_sha1: commit_sha1, limit: limit, offset: offset, expires: expires})
|
318
|
+
return nil if response.blank?
|
319
|
+
response.to_json
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.clone_tree(commit: 'latest', dataset_home: nil)
|
323
|
+
@dataset = Cnvrg::Dataset.new(dataset_home)
|
324
|
+
@files = Cnvrg::Datafiles.new(@dataset.owner, @dataset.slug, dataset: @dataset)
|
325
|
+
trees = @files.get_trees(commit: commit)
|
326
|
+
return false if trees.nil?
|
327
|
+
pb = ProgressBar.create(:title => "Download Progress",
|
328
|
+
:progress_mark => '=',
|
329
|
+
:format => "%b>>%i| %p%% %t",
|
330
|
+
:starting_at => 0,
|
331
|
+
:total => trees.size,
|
332
|
+
:autofinish => true)
|
333
|
+
trees.each do |tree|
|
334
|
+
pb.progress += 1
|
335
|
+
@files.download_dir(dataset_home, tree)
|
336
|
+
end
|
337
|
+
pb.finish
|
338
|
+
@dataset.write_success
|
339
|
+
true
|
340
|
+
end
|
341
|
+
|
309
342
|
def write_success(in_folder = false)
|
310
343
|
file_path = ".cnvrg/config.yml"
|
311
344
|
file_path = "#{@slug}/" + file_path if !in_folder
|
@@ -623,11 +656,7 @@ module Cnvrg
|
|
623
656
|
idx_hash = YAML.load_file("#{self.local_path}/.cnvrg/idx.yml")
|
624
657
|
return idx_hash[:commit]
|
625
658
|
end
|
626
|
-
|
627
|
-
response = Cnvrg::API.request("users/#{self.owner}/datasets/#{self.slug}/list", 'GET', {commit_sha1:commit, as_json:json})
|
628
|
-
CLI.is_response_success(response,true)
|
629
|
-
return response
|
630
|
-
end
|
659
|
+
|
631
660
|
def compare_commit(commit)
|
632
661
|
if commit.nil? or commit.empty?
|
633
662
|
commit = last_local_commit
|
data/lib/cnvrg/experiment.rb
CHANGED
@@ -127,12 +127,21 @@ module Cnvrg
|
|
127
127
|
Cnvrg::CLI.is_response_success(response,false)
|
128
128
|
end
|
129
129
|
|
130
|
-
def end(output, exit_status, end_commit, cpu_average, memory_average)
|
130
|
+
def end(output, exit_status, end_commit, cpu_average, memory_average, end_time: nil)
|
131
131
|
#if remote try to remove
|
132
|
-
|
132
|
+
tries = 0
|
133
|
+
success = false
|
134
|
+
end_time ||= Time.now
|
135
|
+
while tries < 10 and success.blank?
|
136
|
+
sleep (tries*rand) ** 2 ### exponential backoff
|
137
|
+
## this call is super important so we cant let it crash.
|
138
|
+
|
139
|
+
tries += 1
|
140
|
+
response = Cnvrg::API.request(@base_resource + "experiment/end", 'POST', {output: output, exp_slug: @slug,
|
133
141
|
exit_status: exit_status, end_commit: end_commit,
|
134
|
-
cpu_average: cpu_average, memory_average: memory_average})
|
135
|
-
|
142
|
+
cpu_average: cpu_average, memory_average: memory_average, end_time: end_time})
|
143
|
+
success = Cnvrg::CLI.is_response_success(response,false)
|
144
|
+
end
|
136
145
|
|
137
146
|
begin
|
138
147
|
FileUtils.rm_rf(["/home/ds/.cnvrg/tmp/exec.log"])
|
data/lib/cnvrg/files.rb
CHANGED
@@ -584,6 +584,7 @@ module Cnvrg
|
|
584
584
|
#TODO: parallel
|
585
585
|
files_list.map do |file|
|
586
586
|
next [file, nil] unless File.exists? file
|
587
|
+
next [file, nil] if File.directory? file
|
587
588
|
sha1 = OpenSSL::Digest::SHA1.file(file).hexdigest
|
588
589
|
[file.gsub("#{@project_home}/", ""), sha1]
|
589
590
|
end.to_h
|
data/lib/cnvrg/helpers.rb
CHANGED
@@ -238,6 +238,14 @@ parameters:
|
|
238
238
|
return -1
|
239
239
|
end
|
240
240
|
|
241
|
+
def extract_owner_slug_from_url(url, breaker)
|
242
|
+
url_parts = url.split("/")
|
243
|
+
project_index = Cnvrg::Helpers.look_for_in_path(url, breaker)
|
244
|
+
slug = url_parts[project_index + 1]
|
245
|
+
owner = url_parts[project_index - 1]
|
246
|
+
return owner, slug
|
247
|
+
end
|
248
|
+
|
241
249
|
# cpu
|
242
250
|
|
243
251
|
def cpu_time
|
data/lib/cnvrg/logger.rb
CHANGED
@@ -92,6 +92,11 @@ module Cnvrg
|
|
92
92
|
$log.info message: msg, type: "info"
|
93
93
|
end
|
94
94
|
|
95
|
+
def log_json(json, msg: '')
|
96
|
+
Cnvrg::Logger.log_handler if $log.blank?
|
97
|
+
$log.info message: msg, type: "info", data: json
|
98
|
+
end
|
99
|
+
|
95
100
|
def jsonify_message(msg: '', success: true)
|
96
101
|
puts JSON[{
|
97
102
|
"msg": msg,
|
data/lib/cnvrg/project.rb
CHANGED
@@ -504,6 +504,7 @@ module Cnvrg
|
|
504
504
|
response['result']['tree']['added'] -= downloaded_files
|
505
505
|
response['result']['tree']['updated_on_server'] -= downloaded_files
|
506
506
|
end
|
507
|
+
Cnvrg::Logger.log_json(response, msg: "Comparing IDX response(tree)")
|
507
508
|
return response
|
508
509
|
end
|
509
510
|
|
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.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -412,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
412
412
|
version: '0'
|
413
413
|
requirements: []
|
414
414
|
rubyforge_project:
|
415
|
-
rubygems_version: 2.
|
415
|
+
rubygems_version: 2.7.9
|
416
416
|
signing_key:
|
417
417
|
specification_version: 4
|
418
418
|
summary: A CLI tool for interacting with cnvrg.io.
|