cnvrg 1.4.9.4 → 1.5.0

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: 57cfbe5e8781c875703c195139bb558edd39db3c70d35920efc48152412f63d2
4
- data.tar.gz: 35c51593cfef1e3a54e33a95f801e5b09114df80ce5be03f2770408cc33bb0f5
3
+ metadata.gz: 7f9ea846489f30df4e7a770ef453e640e3dcaff0176ebbc6a4ae000bfbcba0e8
4
+ data.tar.gz: 7f5bb7c85aaa16c43834bf705325470bacf8edd2bd342e8d5cf39bd853843136
5
5
  SHA512:
6
- metadata.gz: b60b3f6689af7a7d7446a52cf01c34043af9811ad3e132a5788372b51bbc83cd429ffe94d899ca53121018d3328028b14d82046bf1d0be22fefa0118fb0a17e3
7
- data.tar.gz: 3c083bf5f3dc563a4863b34ba0db6a82e53f134c324b2d37e20ad08dbfc9ad9e6809e3778df197a897a43df2538a18f571293ae2e26bc62a484d738f91c56d22
6
+ metadata.gz: 30cc30763ae8758f8526eb8cac1ef559f3e39c649d521112c7f22908226719da771340907c5928f9ab86f3672fc5f37c1b3a2bd6dd09b8d2b1ac10fe809ad9ed
7
+ data.tar.gz: f1f20925bd2b889676303efbcd657ba063f7bc28274ab074048ccc91a904ebb1046883d8a4854bf77f2c951b88c6b4f75cf468e5221a203a5ac3d0b4692d42c7
@@ -44,5 +44,4 @@ Gem::Specification.new do |spec|
44
44
  spec.add_runtime_dependency 'ruby-progressbar'
45
45
  spec.add_runtime_dependency 'net-ssh'
46
46
  spec.add_runtime_dependency 'down'
47
- spec.add_runtime_dependency 'thread'
48
47
  end
@@ -167,7 +167,7 @@ module Cnvrg
167
167
  super
168
168
  end
169
169
  end
170
- desc "data", "upload and manage datasets", :hide => false
170
+ desc "data [COMMAND]", "Upload and manage datasets", :hide => false
171
171
  subcommand "data", Data
172
172
 
173
173
  desc "job", "manage running jobs", :hide => false
@@ -242,13 +242,16 @@ module Cnvrg
242
242
 
243
243
  map %w(-v --version) => :version
244
244
 
245
- desc 'api', 'set api url, e.g cnvrg --api "https://cnvrg.io/api"'
245
+ desc 'api CNVRG_APPLICATION_URL', 'Set api url, e.g cnvrg --api "https://cnvrg.io/api"'
246
246
  method_option :verify_ssl, :type => :boolean, :aliases => ["-s", "--verify_ssl"], :default => true
247
247
 
248
248
  def set_api_url(url)
249
249
  log_handler()
250
250
  log_start(__method__, args, options)
251
251
  home_dir = File.expand_path('~')
252
+ if url.end_with? "/"
253
+ url = url.chomp("/")
254
+ end
252
255
  if !url.end_with? "/api"
253
256
  url = url + "/api"
254
257
  end
@@ -356,9 +359,9 @@ module Cnvrg
356
359
  end
357
360
  end
358
361
 
359
- map %w(-api --api) => :set_api_url
362
+ map %w(api -api --api) => :set_api_url
360
363
 
361
- desc 'set_default_owner', 'set default owner'
364
+ desc 'set_default_owner', 'Set default owner'
362
365
 
363
366
  def set_default_owner
364
367
  begin
@@ -423,7 +426,7 @@ module Cnvrg
423
426
  end
424
427
  end
425
428
 
426
- desc 'set_compression_path', 'set compression path'
429
+ desc 'set_compression_path', 'Set compression path'
427
430
  method_option :reset, :type => :boolean, :aliases => ["-r", "--reset"], :default => false
428
431
 
429
432
  def set_compression_path(*compression_path)
@@ -765,7 +768,7 @@ module Cnvrg
765
768
  end
766
769
  end
767
770
 
768
- desc 'data init', 'Init dataset directory'
771
+ desc 'data init', 'Init dataset directory', :hide => true
769
772
  method_option :public, :type => :boolean, :aliases => ["-p", "--public"], :default => false
770
773
 
771
774
  def init_data(public, bucket: nil)
@@ -804,7 +807,7 @@ module Cnvrg
804
807
  exit(1)
805
808
  end
806
809
  end
807
- desc 'data delete', 'delete dataset'
810
+ desc 'data delete', 'delete dataset', :hide => true
808
811
  def delete_data(dataset_slug)
809
812
  begin
810
813
  verify_logged_in(false)
@@ -829,7 +832,7 @@ module Cnvrg
829
832
  end
830
833
  end
831
834
 
832
- desc 'data verify', 'Verify datasets'
835
+ desc 'data verify', 'Verify datasets', :hide => true
833
836
  method_option :timeout, :type => :numeric, :aliases => ["-t", "--timeout"], :desc => "Time to wait before returning final answer", :default => 15
834
837
 
835
838
  def verify_datasets(dataset_titles, timeout=0)
@@ -848,7 +851,7 @@ module Cnvrg
848
851
  end
849
852
  end
850
853
 
851
- desc 'data clone', 'Clone dataset'
854
+ desc 'data clone', 'Clone dataset', :hide => true
852
855
  method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ""
853
856
  method_option :only_tree, :type => :boolean, :aliases => ["-t", "--tree"], :default => false
854
857
  method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => nil
@@ -884,7 +887,10 @@ module Cnvrg
884
887
  @files = Cnvrg::Datafiles.new(owner, slug, dataset: @dataset)
885
888
  log_message("Downloading files", Thor::Shell::Color::BLUE)
886
889
  if @dataset.softlinked?
887
- return @dataset.download_softlink
890
+ @files.cp_ds
891
+ Cnvrg::CLI.log_message("Clone finished successfully", Thor::Shell::Color::GREEN)
892
+ @dataset.write_success
893
+ return
888
894
  end
889
895
 
890
896
  if only_tree
@@ -903,6 +909,7 @@ module Cnvrg
903
909
  :total => files_count,
904
910
  :autofinish => true)
905
911
 
912
+
906
913
  while files['keys'].length > 0
907
914
  Cnvrg::Logger.log_info("download multiple files, #{downloaded_files.size} files downloaded")
908
915
  @files.download_multiple_files_s3(files, @dataset.local_path, progressbar: progressbar, read_only: read)
@@ -933,7 +940,7 @@ module Cnvrg
933
940
  end
934
941
  end
935
942
 
936
- desc 'data clone_query', 'Clone dataset _query'
943
+ desc 'data clone_query', 'Clone dataset _query', :hide => true
937
944
  method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => ""
938
945
  def clone_data_query(dataset_url,query=nil)
939
946
  begin
@@ -1074,7 +1081,7 @@ module Cnvrg
1074
1081
  end
1075
1082
  end
1076
1083
 
1077
- desc 'data download', 'pull data'
1084
+ desc 'data download', 'pull data', :hide => true
1078
1085
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
1079
1086
  method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
1080
1087
 
@@ -1432,7 +1439,7 @@ module Cnvrg
1432
1439
  end
1433
1440
 
1434
1441
 
1435
- desc 'data upload', 'push data'
1442
+ desc 'data upload', 'Upload files from local dataset directory to remote server', :hide => true
1436
1443
  method_option :ignore, :type => :array, :aliases => ["-i", "--i"], :desc => "ignore following files"
1437
1444
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
1438
1445
  method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
@@ -1630,7 +1637,7 @@ module Cnvrg
1630
1637
 
1631
1638
  end
1632
1639
 
1633
- desc 'data list', 'List all dataset you currently have'
1640
+ desc 'data list', 'List all dataset you currently have', :hide => true
1634
1641
 
1635
1642
  def list_dataset
1636
1643
  verify_logged_in(false)
@@ -1652,7 +1659,7 @@ module Cnvrg
1652
1659
 
1653
1660
  end
1654
1661
 
1655
- desc 'data queries', 'List all data search queries you currently have'
1662
+ desc 'data queries', 'List all data search queries you currently have', :hide => true
1656
1663
 
1657
1664
  def queries
1658
1665
  verify_logged_in(false)
@@ -1663,7 +1670,7 @@ module Cnvrg
1663
1670
  print_table(result)
1664
1671
  end
1665
1672
 
1666
- desc 'data download_tags_yaml', 'Download dataset tags yml file in current directory'
1673
+ desc 'data download_tags_yaml', 'Download dataset tags yml files in current directory', :hide => true
1667
1674
 
1668
1675
  def download_tags_yaml
1669
1676
  verify_logged_in(false)
@@ -1678,7 +1685,7 @@ module Cnvrg
1678
1685
  end
1679
1686
  end
1680
1687
 
1681
- desc 'data query_files', 'List all data search queries you currently have'
1688
+ desc 'data query_files', 'List all data search queries you currently have', :hide => true
1682
1689
  def query_files(query)
1683
1690
  verify_logged_in(false)
1684
1691
  log_start(__method__, args, options)
@@ -1689,7 +1696,7 @@ module Cnvrg
1689
1696
  print_table(result)
1690
1697
  end
1691
1698
 
1692
- desc 'data commits', 'List all commits for a specific dataset'
1699
+ desc 'data commits', 'List all commits for a specific dataset', :hide => true
1693
1700
 
1694
1701
  def list_dataset_commits()
1695
1702
  verify_logged_in(true)
@@ -1704,7 +1711,7 @@ module Cnvrg
1704
1711
 
1705
1712
  end
1706
1713
 
1707
- desc 'commits', 'List all commits for a specific dataset'
1714
+ desc 'commits', 'List all commits for a specific Project'
1708
1715
 
1709
1716
  def list_commits()
1710
1717
  verify_logged_in(true)
@@ -1774,7 +1781,7 @@ module Cnvrg
1774
1781
 
1775
1782
  end
1776
1783
 
1777
- desc 'clone', 'Clone project'
1784
+ desc 'clone PROJECT_URL', 'Clone project'
1778
1785
  method_option :remote, :type => :boolean, :aliases => ["-r", "--r"], :default => false
1779
1786
  method_option :commit, :type => :string, :aliases => ["-c", "--c"], :default => nil
1780
1787
 
@@ -1956,7 +1963,7 @@ module Cnvrg
1956
1963
  :direct=>false, :force =>force, :sync =>true, :tags =>tags, :parallel => parallel
1957
1964
 
1958
1965
  end
1959
- desc 'upload_data_new', 'upload_data_new'
1966
+ desc 'upload_data_new', 'upload_data_new', :hide => true
1960
1967
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
1961
1968
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
1962
1969
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
@@ -2005,7 +2012,7 @@ module Cnvrg
2005
2012
  end
2006
2013
  end
2007
2014
 
2008
- desc 'start_commit', 'start data commit'
2015
+ desc 'start_commit', 'start data commit', :hide => true
2009
2016
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
2010
2017
  method_option :direct, :type => :boolean, :aliases => ["-d", "--direct"], :desc => "was called directed", :default => true
2011
2018
  method_option :force, :type => :boolean, :aliases => ["-f", "--force"], :default => false
@@ -2039,7 +2046,7 @@ module Cnvrg
2039
2046
  end
2040
2047
 
2041
2048
 
2042
- desc 'end_commit', 'start data commit'
2049
+ desc 'end_commit', 'start data commit', :hide => true
2043
2050
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
2044
2051
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
2045
2052
 
@@ -2066,7 +2073,7 @@ module Cnvrg
2066
2073
  end
2067
2074
  end
2068
2075
  end
2069
- desc 'list_files', 'list files in dataset'
2076
+ desc 'list_files', 'list files in dataset', :hide => true
2070
2077
  method_option :json, :type => :boolean, :aliases => ["-j","--json"],:default => true, :desc => "response as json"
2071
2078
  method_option :commit, :type => :string, :aliases => ["-c","--commit"], :default => nil
2072
2079
 
@@ -2100,7 +2107,7 @@ module Cnvrg
2100
2107
  end
2101
2108
 
2102
2109
  end
2103
- desc 'upload_data', 'Upload updated files'
2110
+ desc 'upload_data', 'Upload updated files', :hide => true
2104
2111
  method_option :ignore, :type => :string, :aliases => ["-i"], :desc => "ignore following files", :default => ""
2105
2112
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
2106
2113
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
@@ -2347,7 +2354,7 @@ module Cnvrg
2347
2354
  end
2348
2355
  end
2349
2356
 
2350
- desc 'download_file_data', 'Download one data files'
2357
+ desc 'download_file_data', 'Download one data files', :hide => true
2351
2358
  method_option :verbose, :type => :boolean, :aliases => ["-v", "--verbose"], :default => false
2352
2359
  method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :desc => "download specified commit", :default => nil
2353
2360
  method_option :link, :type => :boolean, :aliases => ["-l","--link"], :desc => "download specified commit", :default => false
@@ -2409,7 +2416,7 @@ module Cnvrg
2409
2416
  end
2410
2417
 
2411
2418
 
2412
- desc 'download_data_new', 'Download updated files'
2419
+ desc 'download_data_new', 'Download updated files', :hide => true
2413
2420
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
2414
2421
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
2415
2422
  method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
@@ -2642,7 +2649,7 @@ module Cnvrg
2642
2649
 
2643
2650
 
2644
2651
 
2645
- desc 'jump', 'jump to specific commit'
2652
+ desc 'jump', 'Jump to specific commit'
2646
2653
  def jump(commit_sha1)
2647
2654
  begin
2648
2655
  verify_logged_in()
@@ -3071,8 +3078,8 @@ module Cnvrg
3071
3078
  stats = remote ? usage_metrics_in_docker(docker_id) : Helpers.ubuntu? ? {memory: memory_usage, cpu: cpu_usage} : {}
3072
3079
  if is_on_gpu
3073
3080
  gu = gpu_util
3074
- stats['gpu'] = gu[0]
3075
- stats['gpu_util'] = gu[1]
3081
+ stats['gpu_util'] = gu[0]
3082
+ stats['gpu'] = gu[1]
3076
3083
  end
3077
3084
  @exp.send_machine_stats [stats] unless stats.empty?
3078
3085
  rescue => e
@@ -3508,7 +3515,7 @@ module Cnvrg
3508
3515
  method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
3509
3516
  method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => ""
3510
3517
 
3511
- desc 'notebook', 'starts a notebook session remotely or locally'
3518
+ desc 'notebook', 'Starts a notebook session remotely or locally'
3512
3519
 
3513
3520
  def notebook
3514
3521
  verify_logged_in(true)
@@ -3636,7 +3643,7 @@ module Cnvrg
3636
3643
  end
3637
3644
  end
3638
3645
 
3639
- desc 'remote_notebook', 'run notebook server on remote server'
3646
+ desc 'remote_notebook', 'Run notebook server on remote server'
3640
3647
  method_option :machine_type, :type => :string, :default => ""
3641
3648
  method_option :notebook_type, :type => :string, :aliases => ["-n", "--notebook_type"], :default => ""
3642
3649
  method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
@@ -4439,7 +4446,7 @@ module Cnvrg
4439
4446
 
4440
4447
  end
4441
4448
 
4442
- desc 'push', 'push image to cnvrg repository'
4449
+ desc 'push', 'push image to cnvrg repository', :hide=> true
4443
4450
 
4444
4451
  def push(*name)
4445
4452
  verify_logged_in(true)
@@ -4846,7 +4853,7 @@ module Cnvrg
4846
4853
 
4847
4854
  end
4848
4855
 
4849
- desc 'upload_image', 'Upload new docker image to cnvrg'
4856
+ desc 'upload_image', 'Upload new docker image to cnvrg', :hide => true
4850
4857
  method_option :workdir, :type => :string, :aliases => ["-w","--workdir"], :desc => "workdir of docker image", :default => "/root"
4851
4858
  method_option :description, :type => :string, :aliases => ["-d", "--description"], :desc => "description for docker image", :default => ""
4852
4859
  method_option :user, :type => :string, :aliases => ["-u","--user"], :default => "root"
@@ -4999,7 +5006,7 @@ module Cnvrg
4999
5006
  end
5000
5007
  end
5001
5008
 
5002
- desc 'list_images', 'lists all custom images you can pull'
5009
+ desc 'list_images', 'lists all custom images you can pull', :hide => true
5003
5010
 
5004
5011
  def list_images
5005
5012
  begin
@@ -5026,7 +5033,7 @@ module Cnvrg
5026
5033
 
5027
5034
  end
5028
5035
 
5029
- desc 'list_machines', 'lists all machines belong to your organization'
5036
+ desc 'list_machines', 'Lists all machines belong to your organization'
5030
5037
 
5031
5038
  def list_machines
5032
5039
  begin
@@ -5051,7 +5058,7 @@ module Cnvrg
5051
5058
 
5052
5059
  end
5053
5060
 
5054
- desc 'experiments', 'list project experiments'
5061
+ desc 'experiments', 'List project experiments'
5055
5062
  method_option :id, :type => :string, :aliases => ["-id"], :desc => "Get info for specific experiments", :default => ""
5056
5063
  method_option :tag, :type => :string, :aliases => ["-t"], :desc => "Get info for specific experiment tag", :default => ""
5057
5064
 
@@ -5134,7 +5141,7 @@ module Cnvrg
5134
5141
  end
5135
5142
 
5136
5143
 
5137
- desc 'pull_image', 'downloads and loads an image'
5144
+ desc 'pull_image', 'downloads and loads an image', :hide => true
5138
5145
 
5139
5146
  def pull_image(image_name)
5140
5147
  begin
@@ -5217,7 +5224,7 @@ module Cnvrg
5217
5224
 
5218
5225
  end
5219
5226
 
5220
- desc 'set_image', 'set image to a porject'
5227
+ desc 'set_image', 'set image to a porject', :hide => true
5221
5228
 
5222
5229
  def set_image(docker_image)
5223
5230
  verify_logged_in(true)
@@ -1,6 +1,5 @@
1
- require 'thread/pool'
2
- require 'thread/future'
3
-
1
+ require 'cnvrg/cli'
2
+ require 'thor'
4
3
  class SubCommandBase < Thor
5
4
  def self.banner(command, namespace = nil, subcommand = false)
6
5
  "#{basename} #{command.usage}"
@@ -14,7 +13,7 @@ end
14
13
  module Cnvrg
15
14
  class Data < SubCommandBase
16
15
  class_option :no_compression, :type => :boolean, :aliases => ["-nc", "--no_compression"], :default => false
17
- desc "data init", "init data folder"
16
+ desc "data init", "Set current directory as dataset directory"
18
17
  method_option :public, :type => :boolean, :aliases => ["-p", "--public"], :default => false
19
18
  method_option :bucket, :type => :string, :aliases => ["-b", "--bucket"], :default => ""
20
19
  def init
@@ -23,7 +22,7 @@ module Cnvrg
23
22
  bucket = options["bucket"]
24
23
  cli.init_data(public, bucket: bucket)
25
24
  end
26
- desc "data upload", "upload data folder"
25
+ desc "data upload", "Upload files from local dataset directory to remote server"
27
26
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
28
27
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
29
28
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
@@ -40,7 +39,7 @@ module Cnvrg
40
39
  tags = options["tags"]
41
40
  cli.upload_data_new(new_branch, verbose,sync,force, tags, chunk_size)
42
41
  end
43
- desc 'sync', 'sync_data_new'
42
+ desc 'data sync', 'Synchronise local dataset directory with remote server'
44
43
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
45
44
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
46
45
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
@@ -64,7 +63,7 @@ module Cnvrg
64
63
  init = options["init"]
65
64
  cli.sync_data_new(new_branch, force, verbose,commit,all_files, tags,parallel, chunk_size, init)
66
65
  end
67
- desc 'data download', 'pull data'
66
+ desc 'data download', 'Download files from remote server'
68
67
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits", :default => false
69
68
  method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
70
69
  method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
@@ -80,7 +79,7 @@ module Cnvrg
80
79
  all_files = options["all_files"]
81
80
  cli.download_data_new(verbose,sync,new_branch, commit,all_files)
82
81
  end
83
- desc 'data clone', 'clone datset'
82
+ desc 'data clone DATASET_URL', 'Clone dataset'
84
83
  method_option :only_tree, :type => :boolean, :aliases => ["-t", "--tree"], :default => false
85
84
  method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => nil
86
85
  method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => nil
@@ -97,7 +96,7 @@ module Cnvrg
97
96
  cli.clone_data(dataset_url, only_tree=only_tree,commit=commit, query=query, read=read, remote=remote)
98
97
  end
99
98
 
100
- desc 'data verify', 'verify datasets', :hide => true
99
+ desc 'data verify DATASETS_TITLES', 'verify datasets', :hide => true
101
100
  method_option :timeout, :type => :numeric, :aliases => ["-t", "--timeout"], :desc => "Time to wait before returning final answer", :default => 15
102
101
 
103
102
  def verify(*dataset_titles)
@@ -106,7 +105,7 @@ module Cnvrg
106
105
  cli.verify_datasets(dataset_titles, timeout)
107
106
  end
108
107
 
109
- desc 'data set --url=dataset_url', 'Set dataset url to other url'
108
+ desc 'data set --url=DATASET_URL', 'Set dataset url to other url'
110
109
  method_option :url, :type => :string, :aliases => ["--url"], :default => ''
111
110
  def set
112
111
  cli = Cnvrg::CLI.new
@@ -117,7 +116,7 @@ module Cnvrg
117
116
  end
118
117
  end
119
118
 
120
- desc 'data put dataset_url', 'clone datset'
119
+ desc 'data put DATASET_URL FILES_PREFIX', 'Upload selected files from local dataset directory to remote server'
121
120
  method_option :dir, :type => :string, :aliases => ["-d", "--dir"], :default => ''
122
121
  def put(dataset_url, *files)
123
122
  cli = Cnvrg::CLI.new()
@@ -125,7 +124,7 @@ module Cnvrg
125
124
  cli.data_put(dataset_url, files: files, dir: dir)
126
125
  end
127
126
 
128
- desc 'data clone_query', 'clone query datset'
127
+ desc 'data clone_query --query=QUERY_SLUG DATASET_URL', 'Clone dataset with specific query'
129
128
  method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => nil
130
129
  def clone_query(dataset_url)
131
130
  cli = Cnvrg::CLI.new()
@@ -133,20 +132,20 @@ module Cnvrg
133
132
  cli.clone_data_query(dataset_url,query=query)
134
133
  end
135
134
 
136
- desc 'data delete', 'delete datset'
135
+ desc 'data delete DATASET_SLUG', 'Delete dataset'
137
136
  def delete(dataset_slug)
138
137
  cli = Cnvrg::CLI.new()
139
138
  cli.delete_data(dataset_slug)
140
139
 
141
140
  end
142
- desc 'data list', 'list of datasets'
141
+ desc 'data list', 'Show list of all datasets'
143
142
  def list()
144
143
  cli = Cnvrg::CLI.new()
145
144
 
146
145
  cli.list_dataset()
147
146
 
148
147
  end
149
- desc 'data commits', 'pull data'
148
+ desc 'data commits', 'List all commits for a current dataset'
150
149
 
151
150
  def commits()
152
151
  cli = Cnvrg::CLI.new()
@@ -154,7 +153,7 @@ module Cnvrg
154
153
 
155
154
  end
156
155
 
157
- desc 'data files', 'list dataset files'
156
+ desc 'data files DATASET_URL', 'Show list of dataset files'
158
157
  method_option :offset, :type => :numeric, :aliases => ["-o", "--offset"], :default => 0
159
158
  method_option :limit, :type => :numeric, :aliases => ["-l", "--limit"], :default => 1000
160
159
  method_option :expires, :type => :numeric, :aliases => ["-ex", "--expires"], :default => 3600
@@ -172,19 +171,19 @@ module Cnvrg
172
171
  cli.log_message(files)
173
172
  end
174
173
 
175
- desc 'data queries', 'list of all queries'
174
+ desc 'data queries', 'List all dataset queries related to current dataset'
176
175
  def queries()
177
176
  cli = Cnvrg::CLI.new()
178
177
  cli.queries()
179
178
  end
180
179
 
181
- desc 'data query_files', 'list of all queries'
180
+ desc 'data query_files QUERY_NAME', 'Show list of all files in specific query'
182
181
  def query_files(query)
183
182
  cli = Cnvrg::CLI.new()
184
183
  cli.query_files(query)
185
184
  end
186
185
 
187
- desc 'data download_tags_yaml', 'Download dataset tags yml file in current directory'
186
+ desc 'data download_tags_yaml', 'Download dataset tags yml files in current dataset directory'
188
187
  def download_tags_yaml
189
188
  cli = Cnvrg::CLI.new()
190
189
  cli.download_tags_yaml()
@@ -70,6 +70,35 @@ module Cnvrg
70
70
  end
71
71
  end
72
72
 
73
+ def cp_ds
74
+ prefix = @dataset.get_dataset["bucket_prefix"]
75
+ current_batch = @downloader.fetch_files(prefix: prefix, limit: 500)
76
+ pbar = ProgressBar.create(:title => "Download Progress",
77
+ :progress_mark => '=',
78
+ :format => "%b%i| %c Files downloaded",
79
+ :starting_at => 0,
80
+ :total => nil,
81
+ :autofinish => true)
82
+ parallel_options = {
83
+ in_threads: ParallelThreads,
84
+ in_processes: Cnvrg::CLI::ParallelProcesses,
85
+ isolation: true,
86
+ finish: ->(*args) {pbar.progress += 1}
87
+ }
88
+ while current_batch.size > 0
89
+ Parallel.map(current_batch, parallel_options) do |file|
90
+ #current_batch.map do |file|
91
+ next if file.end_with? "/"
92
+ cutted_key = Cnvrg::Downloader::Clients::S3Client.cut_prefix(prefix, file)
93
+ dest_path = File.join(@dataset.local_path, cutted_key)
94
+ @downloader.download(file, dest_path, decrypt: false)
95
+ file
96
+ end
97
+ marker = current_batch.last
98
+ current_batch = @downloader.fetch_files(prefix: prefix, marker: marker, limit: 500)
99
+ end
100
+ end
101
+
73
102
 
74
103
  def put_commit(commit_sha1)
75
104
  response = Cnvrg::API.request("#{@base_resource}/commit/latest", 'PUT', {commit_sha1: commit_sha1})
@@ -63,21 +63,6 @@ module Cnvrg
63
63
  end
64
64
 
65
65
 
66
- def download_softlink
67
- @storage = self.get_storage_client
68
- @progressbar = ProgressBar.create(:title => "Download Progress",
69
- :progress_mark => '=',
70
- :format => "%b%i| %c Files downloaded",
71
- :starting_at => 0,
72
- :total => nil,
73
- :autofinish => true)
74
- @storage.cp(get_dataset["bucket_prefix"], @local_path, progress: @progressbar)
75
- @progressbar.finish
76
- Cnvrg::CLI.log_message("Clone finished successfully", Thor::Shell::Color::GREEN)
77
- write_success
78
- end
79
-
80
-
81
66
  def get_storage_client
82
67
  response = Cnvrg::API.request("users/#{@owner}/datasets/#{@slug}/client", 'GET')
83
68
  if Cnvrg::CLI.is_response_success(response, false)
@@ -262,6 +247,9 @@ module Cnvrg
262
247
  end
263
248
 
264
249
  ignore_list = []
250
+ if not File.exists? "#{self.local_path}/.cnvrgignore"
251
+ return ignore_list
252
+ end
265
253
  File.open(self.local_path + "/.cnvrgignore", "r").each_line do |line|
266
254
  line = line.strip
267
255
  if line.start_with? "#" or ignore_list.include? line or line.empty?
@@ -26,8 +26,10 @@ module Cnvrg
26
26
  })
27
27
  end
28
28
 
29
- @client = Aws::S3::Client.new(options)
30
- @bucket = Aws::S3::Resource.new(client: @client).bucket(@bucket_name)
29
+ @options = options
30
+
31
+ #@client = Aws::S3::Client.new(options)
32
+ #@bucket = Aws::S3::Resource.new(client: @client).bucket(@bucket_name)
31
33
  @upload_options = {:use_accelerate_endpoint => storage == 's3'}
32
34
  if encryption.present?
33
35
  @upload_options[:server_side_encryption] = encryption
@@ -39,54 +41,39 @@ module Cnvrg
39
41
  storage_path = Cnvrg::Helpers.decrypt(@key, @iv, storage_path) if decrypt
40
42
  resp = nil
41
43
  File.open(local_path, 'w+') do |file|
42
- resp = @client.get_object({bucket: @bucket_name, key: storage_path}, target: file)
44
+ resp = aws_client.get_object({bucket: @bucket_name, key: storage_path}, target: file)
43
45
  end
44
46
  resp
45
47
  rescue => e
46
- p e.message
47
- p e.backtrace
48
+ Cnvrg::Logger.log_error(e)
49
+ raise e
48
50
  end
49
51
 
50
52
  def upload(storage_path, local_path)
51
53
  ### storage path is the path inside s3 (after the bucket)
52
54
  # local path is fullpath for the file /home/ubuntu/user.../hazilim.py
53
- o = @bucket.object(storage_path)
55
+ o = aws_bucket.object(storage_path)
54
56
  o.upload_file(local_path, @upload_options)
55
57
  end
56
58
 
57
-
58
- def cp(prefix, local_path, progress: nil)
59
- files = []
60
- files_thread = Thread.new do
61
- current_marker = nil
62
- while true
63
- batch_files = @bucket.objects(prefix: prefix, marker: current_marker).first(500)
64
- batch_files = batch_files.to_a
65
- break if batch_files.size === 0
66
- files += batch_files
67
- current_marker = batch_files.last.key
68
- end
69
- end
70
- thread_pool = Thread.pool(Cnvrg::Helpers.parallel_threads)
71
- while true
72
- while files.present?
73
- Thread.future thread_pool do
74
- f = files.pop
75
- cutted_key = cut_prefix(prefix, f.key)
76
- dest_path = File.join(local_path, cutted_key)
77
- download(f.key, dest_path, decrypt: false)
78
- progress.increment
79
- end
80
- end
81
- break if files.size == 0 and files_thread.status == false
82
- sleep(1)
83
- end
84
- thread_pool.wait(:done)
59
+ def fetch_files(prefix: nil, marker: nil, limit: 1000)
60
+ batch_files = aws_bucket.objects(prefix: prefix, marker: marker).first(limit)
61
+ batch_files.to_a.map(&:key)
85
62
  end
86
63
 
87
- def cut_prefix(prefix, file)
64
+ def self.cut_prefix(prefix, file)
88
65
  file.gsub(prefix, '').gsub(/^\/*/, '')
89
66
  end
67
+
68
+
69
+ private
70
+ def aws_client
71
+ Aws::S3::Client.new(@options)
72
+ end
73
+
74
+ def aws_bucket
75
+ Aws::S3::Resource.new(client: aws_client).bucket(@bucket_name)
76
+ end
90
77
  end
91
78
  end
92
79
  end
@@ -12,6 +12,14 @@ module Cnvrg
12
12
  ### set max threads to be 100k
13
13
  [threads, 100000].min
14
14
  end
15
+
16
+ def self.parallel_options
17
+ {
18
+ in_processes: Cnvrg::CLI::ParallelProcesses,
19
+ in_thread: Cnvrg::CLI::ParallelThreads,
20
+ isolation: true
21
+ }
22
+ end
15
23
  def checkmark
16
24
  checkmark = "\u2713"
17
25
  return checkmark.encode('utf-8')
@@ -1,4 +1,4 @@
1
1
  module Cnvrg
2
- VERSION = '1.4.9.4'
2
+ VERSION = '1.5.0'
3
3
  end
4
4
 
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.4.9.4
4
+ version: 1.5.0
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: 2019-06-25 00:00:00.000000000 Z
13
+ date: 2019-07-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -372,20 +372,6 @@ dependencies:
372
372
  - - ">="
373
373
  - !ruby/object:Gem::Version
374
374
  version: '0'
375
- - !ruby/object:Gem::Dependency
376
- name: thread
377
- requirement: !ruby/object:Gem::Requirement
378
- requirements:
379
- - - ">="
380
- - !ruby/object:Gem::Version
381
- version: '0'
382
- type: :runtime
383
- prerelease: false
384
- version_requirements: !ruby/object:Gem::Requirement
385
- requirements:
386
- - - ">="
387
- - !ruby/object:Gem::Version
388
- version: '0'
389
375
  description: A CLI tool for interacting with cnvrg.io.
390
376
  email:
391
377
  - info@cnvrg.io
@@ -446,7 +432,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
446
432
  - !ruby/object:Gem::Version
447
433
  version: '0'
448
434
  requirements: []
449
- rubygems_version: 3.0.3
435
+ rubyforge_project:
436
+ rubygems_version: 2.7.9
450
437
  signing_key:
451
438
  specification_version: 4
452
439
  summary: A CLI tool for interacting with cnvrg.io.