cnvrg 1.10.20 → 1.11.5

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: 443373b68531083498c571cacf504da4dc02d005ef5c749a0077b7a4efce49ac
4
- data.tar.gz: 6b944be355bd91eccc138792fbcf117dc4fdb8b505b75a7b888dcd74f47aa1ed
3
+ metadata.gz: b48bf1399bcafb013474322d63fb0d06ad9c484866f4d59dce963eddcd2fb67a
4
+ data.tar.gz: bc4ed0f3b02a869babc60beec4b090542492d5b53db50810ca7cbe5eaa7901f7
5
5
  SHA512:
6
- metadata.gz: b7ff78d2eceb2a420f46d2ed96ac06ab2c96cc031d8949581069f2b4a4c9d45f210120024c2c25fe93b4542c9f0de0d3dcf893745911f129b8986cda716d3505
7
- data.tar.gz: 56d85bf1fb4d16c1ec3ce46dfd5e38363c71a5242daaddb6e7f8cfa335526961abf4c6cf2345426fd8689d97e7d9a4e03b75c34e16ca32d440aca42459ed07e3
6
+ metadata.gz: b685ded1e59dfdb12a766ccd05e682b9e053a3069adf377ddc09fdae7d94be0ede6bd3f2ef67dbefdc0c6dc4d8d9a0c4e0ca9754a5cc939aa93340f33cbc295b
7
+ data.tar.gz: 20a00dbc9a98c4f96785ea1bb684b9f217aa97ad39a583f1638c317a392ccb821f58de01c939bccde883c8aa02cf124b60757b0f4f1eaade669d87784aa394b5
@@ -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
@@ -1781,8 +1784,7 @@ module Cnvrg
1781
1784
  print_table(list)
1782
1785
  end
1783
1786
 
1784
- desc 'commits', 'List all commits for a specific Project'
1785
-
1787
+ desc 'commits', 'List all commits for a specific Project', :hide => true
1786
1788
  def list_commits()
1787
1789
  verify_logged_in(true)
1788
1790
  log_start(__method__, args, options)
@@ -1796,7 +1798,7 @@ module Cnvrg
1796
1798
  end
1797
1799
 
1798
1800
 
1799
- desc 'unlink', 'Unlink a project from current directory'
1801
+ desc 'unlink', 'Unlink a project from current directory', :hide => true
1800
1802
 
1801
1803
  def unlink
1802
1804
  verify_logged_in(false)
@@ -2893,7 +2895,7 @@ module Cnvrg
2893
2895
  end
2894
2896
  end
2895
2897
 
2896
- desc 'show', 'Show specific file from a specific commit'
2898
+ desc 'show', 'Show specific file from a specific commit', :hide => true
2897
2899
  method_option :path, :type => :string, :aliases => ["-p"], :desc => "File path", :default => ""
2898
2900
  method_option :commit, :type => :string, :aliases => ["-c"], :desc => "Commit sha1", :default => nil
2899
2901
 
@@ -4806,8 +4808,7 @@ module Cnvrg
4806
4808
 
4807
4809
  end
4808
4810
 
4809
- desc 'list_machines', 'Lists all machines belong to your organization'
4810
-
4811
+ desc 'list_machines', 'Lists all machines belong to your organization', :hide => true
4811
4812
  def list_machines
4812
4813
  begin
4813
4814
  verify_logged_in(false)
@@ -52,7 +52,7 @@ 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.map{|p| p.gsub(/^\.\//, '')}
55
+ paths
56
56
  end
57
57
 
58
58
  def get_files_and_folders(paths)
@@ -429,9 +429,10 @@ module Cnvrg
429
429
 
430
430
  file_chunks = files.each_slice(chunk_size).to_a
431
431
  # Fetch the required files from the server:
432
- 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(/^\.\//, '')}
433
434
  Cnvrg::Logger.info("Generating chunk idx")
434
- 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)
435
436
  Cnvrg::Logger.info("Getting files info from server")
436
437
  results = request_upload_files(commit_sha1, tree, override, new_branch, partial_commit)
437
438
  next unless results
@@ -1199,7 +1200,9 @@ module Cnvrg
1199
1200
  end
1200
1201
 
1201
1202
  def end_commit(commit_sha1, force, success: true, uploaded_files: 0, commit_type: nil)
1203
+ counter = 0
1202
1204
  begin
1205
+ counter += 1
1203
1206
  response = Cnvrg::API.request(
1204
1207
  "#{base_resource}/commit/end",
1205
1208
  'POST',
@@ -1211,9 +1214,11 @@ module Cnvrg
1211
1214
  commit_type: commit_type
1212
1215
  }
1213
1216
  )
1214
- 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
1215
1219
  return response
1216
1220
  rescue => e
1221
+ retry if counter <= 20
1217
1222
  return false
1218
1223
  end
1219
1224
  end
@@ -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
- 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
490
- @dataset.write_success
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
 
@@ -541,7 +556,7 @@ module Cnvrg
541
556
  "#{url}/#{self.owner}/datasets/#{self.slug}"
542
557
  end
543
558
 
544
- def generate_chunked_idx(list_files = [], threads: 15, prefix: '')
559
+ def generate_chunked_idx(list_files = [], threads: 15, prefix: '', cli: nil)
545
560
  tree = {}
546
561
  Parallel.map(list_files, in_threads: threads) do |file|
547
562
 
@@ -552,7 +567,11 @@ module Cnvrg
552
567
  label = safe_path.gsub(self.local_path + "/", "")
553
568
  label = "#{prefix}/#{label}" if prefix.present?
554
569
  if not Cnvrg::Files.valid_file_name?(label)
555
- raise StandardError.new("#{label} is not a valid file name.")
570
+ if cli
571
+ cli.log_message("#{label} is not a valid file name, skipping it", Thor::Shell::Color::RED)
572
+ else
573
+ puts "#{label} is not a valid file name, , skipping it"
574
+ end
556
575
  end
557
576
  if File.directory? file
558
577
  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.20'
2
+ VERSION = '1.11.5'
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.20
4
+ version: 1.11.5
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-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler