cnvrg 1.10.19 → 1.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 057f3283dffe548f882ed6cbdcfbc176e12fa75291f8a4867c8eee74fefd701f
4
- data.tar.gz: fe30a40d86418cca0c98156ed89212ccfb159ead16dd248388a05f9d5bb3a05f
3
+ metadata.gz: 5b5e5904880441ee1b4610eb69e2d3d5c74e0e58f4f7d1dbd0e1547de0c47e9c
4
+ data.tar.gz: 37b7b8c6f82b00ca93ccc8a323c84653e2c83757008c57c04d5a98c32bcad2de
5
5
  SHA512:
6
- metadata.gz: 5b5ccc6f603a06affd160bc928c8ee99acf045eccf3905dcc1c23ceca8b4efdb185c3f78716bb111973df0420a5356dbf3565c52a9fe298f4fccdc886f3b07d7
7
- data.tar.gz: 1cc6cbaa4737fb0151bed559352292908479ffce6e2bb1ba65812aef19d91b935265ec80f8a2a0f52111c02b3944aecb79d89e8d72518f4db094c75766834228
6
+ metadata.gz: 8a5d6540f9da9ab77321435d5f4ece63010faf6d0ce05a76ce938236eaa6cd4c1853aa004f732313d69b644b66df50da505b9c55a4fc165a6e353f7e48c414c9
7
+ data.tar.gz: 4f9f90f9f465db06e62a2f25fe84161b0a0994afb68d9d7ff4604959f3627bdbea20eead733fa50942e5a93191d445b010f7b152211c9948b746e69e8c4e839f
@@ -896,10 +896,12 @@ module Cnvrg
896
896
  return
897
897
  end
898
898
 
899
+
899
900
  if only_tree
900
- success = Dataset.clone_tree(commit: commit, dataset_home: dataset_home)
901
- return if success
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")
@@ -964,10 +967,9 @@ module Cnvrg
964
967
  Cnvrg::CLI.is_response_success(response,true)
965
968
  dataset_name = response["results"]["name"]
966
969
  dataset_slug = response["results"]["slug"]
967
- dataset_home = Dir.pwd+"/"+dataset_slug
970
+ dataset_home = Dir.pwd + "/" + dataset_slug
968
971
  Dataset.stop_if_dataset_present(dataset_home, dataset_name) if soft
969
972
 
970
- # dataset_home = Dir.pwd
971
973
  if Dataset.blank_clone(owner, dataset_name, dataset_slug)
972
974
  dataset = Dataset.new(dataset_home)
973
975
  log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
@@ -986,12 +988,13 @@ module Cnvrg
986
988
  begin
987
989
  log_message("Downloading files", Thor::Shell::Color::BLUE)
988
990
  Parallel.map((response["results"]["query_files"]), parallel_options) do |f|
989
- relative_path = f["fullpath"].gsub(/^#{dataset_home}/, "")
991
+ relative_path = f["fullpath"].gsub(/^#{dataset_home}/, "").gsub(/^#{slug}/, "")
990
992
  relative_path_dir = relative_path.split("/")
991
993
  file_name = relative_path_dir.pop()
992
994
  relative_path_dir = relative_path_dir.join("/")
993
995
  abs_path = dataset_home + "/" + relative_path_dir
994
996
  abs_path = dataset_home if flatten
997
+
995
998
  begin
996
999
  FileUtils.mkdir_p(abs_path) unless File.exist? (abs_path + "/" + file_name)
997
1000
  rescue
@@ -1194,6 +1197,7 @@ module Cnvrg
1194
1197
  desc '', '', :hide => true
1195
1198
  def data_put(dataset_url, files: [], dir: '', commit: '', chunk_size: 1000, force: false, override: false, threads: 15, message: nil)
1196
1199
  begin
1200
+ verify_logged_in(false)
1197
1201
  log_start(__method__, args, options)
1198
1202
 
1199
1203
  owner, slug = get_owner_slug(dataset_url)
@@ -1217,7 +1221,7 @@ module Cnvrg
1217
1221
  Cnvrg::Logger.info("Put files in latest commit")
1218
1222
  response = @datafiles.last_valid_commit()
1219
1223
  unless response #means we failed in the start commit.
1220
- raise SignalException.new(1, "Cant put files into commit:#{commit}, check the dataset id and commit")
1224
+ raise SignalException.new(1, "Cant put files into commit:#{commit}, check the dataset id and commitc")
1221
1225
  end
1222
1226
  @commit = response['result']['sha1']
1223
1227
  else
@@ -1780,8 +1784,7 @@ module Cnvrg
1780
1784
  print_table(list)
1781
1785
  end
1782
1786
 
1783
- desc 'commits', 'List all commits for a specific Project'
1784
-
1787
+ desc 'commits', 'List all commits for a specific Project', :hide => true
1785
1788
  def list_commits()
1786
1789
  verify_logged_in(true)
1787
1790
  log_start(__method__, args, options)
@@ -1795,7 +1798,7 @@ module Cnvrg
1795
1798
  end
1796
1799
 
1797
1800
 
1798
- desc 'unlink', 'Unlink a project from current directory'
1801
+ desc 'unlink', 'Unlink a project from current directory', :hide => true
1799
1802
 
1800
1803
  def unlink
1801
1804
  verify_logged_in(false)
@@ -2892,7 +2895,7 @@ module Cnvrg
2892
2895
  end
2893
2896
  end
2894
2897
 
2895
- desc 'show', 'Show specific file from a specific commit'
2898
+ desc 'show', 'Show specific file from a specific commit', :hide => true
2896
2899
  method_option :path, :type => :string, :aliases => ["-p"], :desc => "File path", :default => ""
2897
2900
  method_option :commit, :type => :string, :aliases => ["-c"], :desc => "Commit sha1", :default => nil
2898
2901
 
@@ -4805,8 +4808,7 @@ module Cnvrg
4805
4808
 
4806
4809
  end
4807
4810
 
4808
- desc 'list_machines', 'Lists all machines belong to your organization'
4809
-
4811
+ desc 'list_machines', 'Lists all machines belong to your organization', :hide => true
4810
4812
  def list_machines
4811
4813
  begin
4812
4814
  verify_logged_in(false)
@@ -52,9 +52,6 @@ module Cnvrg
52
52
  end
53
53
  raise SignalException.new(1, "Cant find file #{file}") unless File.exists? "#{Dir.pwd}/#{file}"
54
54
  end
55
- paths.each_slice(1000) do |chunk|
56
- chunk.each { |p| p.gsub!(/^\.\//, '') }
57
- end
58
55
  paths
59
56
  end
60
57
 
@@ -432,9 +429,10 @@ module Cnvrg
432
429
 
433
430
  file_chunks = files.each_slice(chunk_size).to_a
434
431
  # Fetch the required files from the server:
435
- Parallel.map((file_chunks), in_threads: 10) do |files_chunk|
432
+ Parallel.map((file_chunks), in_threads: threads) do |chunk|
433
+ files_chunk = chunk.map{|p| p.gsub(/^\.\//, '')}
436
434
  Cnvrg::Logger.info("Generating chunk idx")
437
- tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads)
435
+ tree = @dataset.generate_chunked_idx(files_chunk, prefix: prefix, threads: threads, cli: cli)
438
436
  Cnvrg::Logger.info("Getting files info from server")
439
437
  results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
440
438
  next unless results
@@ -1202,7 +1200,9 @@ module Cnvrg
1202
1200
  end
1203
1201
 
1204
1202
  def end_commit(commit_sha1, force, success: true, uploaded_files: 0, commit_type: nil)
1203
+ counter = 0
1205
1204
  begin
1205
+ counter += 1
1206
1206
  response = Cnvrg::API.request(
1207
1207
  "#{base_resource}/commit/end",
1208
1208
  'POST',
@@ -1214,9 +1214,11 @@ module Cnvrg
1214
1214
  commit_type: commit_type
1215
1215
  }
1216
1216
  )
1217
- Cnvrg::CLI.is_response_success(response, true)
1217
+ is_success = Cnvrg::CLI.is_response_success(response, false)
1218
+ raise Exception.new("Invalid response #{response}") unless is_success
1218
1219
  return response
1219
1220
  rescue => e
1221
+ retry if counter <= 20
1220
1222
  return false
1221
1223
  end
1222
1224
  end
@@ -471,22 +471,32 @@ 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
- pb = ProgressBar.create(:title => "Download Progress",
480
- :progress_mark => '=',
481
- :format => "%b>>%i| %p%% %t",
482
- :starting_at => 0,
483
- :total => trees.size,
484
- :autofinish => true)
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
- pb.finish
498
+
499
+ pb.finish unless progressbar
490
500
  @dataset.write_success
491
501
  true
492
502
  end
@@ -541,7 +551,7 @@ module Cnvrg
541
551
  "#{url}/#{self.owner}/datasets/#{self.slug}"
542
552
  end
543
553
 
544
- def generate_chunked_idx(list_files = [], threads: 15, prefix: '')
554
+ def generate_chunked_idx(list_files = [], threads: 15, prefix: '', cli: nil)
545
555
  tree = {}
546
556
  Parallel.map(list_files, in_threads: threads) do |file|
547
557
 
@@ -552,7 +562,11 @@ module Cnvrg
552
562
  label = safe_path.gsub(self.local_path + "/", "")
553
563
  label = "#{prefix}/#{label}" if prefix.present?
554
564
  if not Cnvrg::Files.valid_file_name?(label)
555
- raise StandardError.new("#{label} is not a valid file name.")
565
+ if cli
566
+ cli.log_message("#{label} is not a valid file name, skipping it", Thor::Shell::Color::RED)
567
+ else
568
+ puts "#{label} is not a valid file name, , skipping it"
569
+ end
556
570
  end
557
571
  if File.directory? file
558
572
  tree[label + "/"] = nil
@@ -14,8 +14,15 @@ module Cnvrg
14
14
  end
15
15
 
16
16
  def extract_key_iv(sts_path)
17
- sts = open(sts_path, {ssl_verify_mode: 0}).read rescue nil
18
- raise StandardError.new("Cant open sts") if sts.blank?
17
+ count = 20
18
+ begin
19
+ count += 1
20
+ sts = open(sts_path, {ssl_verify_mode: 0}).read rescue nil
21
+ rescue => e
22
+ Cnvrg::Logger.log_error(e)
23
+ retry if count <= 20
24
+ raise StandardError.new("Cant access storage: #{e.message}")
25
+ end
19
26
  sts.split("\n")
20
27
  end
21
28
 
@@ -115,7 +115,7 @@ module Cnvrg
115
115
  #upload files
116
116
  blob_id_chunk = Parallel.map(files.keys, in_threads: ParallelThreads) do |file|
117
117
  begin
118
- Cnvrg::Helpers.try_until_success{self.upload_single_file(files[file].merge(parsed_chunk_of_files[file]))}
118
+ upload_single_file(files[file].merge(parsed_chunk_of_files[file]))
119
119
  rescue => e
120
120
  Cnvrg::CLI.log_message("Failed to upload #{file}: #{e.message}", 'red') unless suppress_exceptions
121
121
  Cnvrg::Logger.log_error(e)
@@ -188,7 +188,7 @@ module Cnvrg
188
188
  def upload_single_file(file)
189
189
  path = file['path']
190
190
  absolute_path = file[:absolute_path]
191
- @client.upload(path, absolute_path)
191
+ @client.safe_upload(path, absolute_path)
192
192
  end
193
193
 
194
194
  def parse_file(file)
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '1.10.19'
2
+ VERSION = '1.11.3'
3
3
  end
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.19
4
+ version: 1.11.3
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-09-22 00:00:00.000000000 Z
13
+ date: 2020-11-08 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.1.2
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.