cnvrg 0.5.0 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cnvrg.gemspec +2 -3
- data/lib/cnvrg/api.rb +4 -4
- data/lib/cnvrg/cli.rb +430 -117
- data/lib/cnvrg/data.rb +42 -5
- data/lib/cnvrg/datafiles.rb +118 -4
- data/lib/cnvrg/dataset.rb +100 -4
- data/lib/cnvrg/experiment.rb +26 -8
- data/lib/cnvrg/helpers.rb +1 -1
- data/lib/cnvrg/project.rb +37 -18
- data/lib/cnvrg/version.rb +1 -1
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be48abaee7b44f00673ed8e4fe95fdc32044cdbf
|
4
|
+
data.tar.gz: fdc1bb3df689ea6524f268f910915559ba62ddfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a35b1ac372e78feffd115d7426338dced272bd351b7e76277f3dc2ead315d2632b9f28a07c4f7fd27f93c9668678addb4d91b106cb3c26b5e75d94832c752b
|
7
|
+
data.tar.gz: 96a10e4bd81552ea5b1ce22468fd102f9ec21a29e64152b83106a743e2e6278de0d68cb504fc78dcfb64098f30b60d5ecb051a224685dcdb5f9eea876ce12cc2
|
data/cnvrg.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'pry'
|
27
27
|
|
28
28
|
spec.add_runtime_dependency 'mimemagic', '~> 0.3.1','>=0.3.2'
|
29
|
-
spec.add_runtime_dependency 'faraday', '~> 0.
|
29
|
+
spec.add_runtime_dependency 'faraday', '~> 0.15.2'
|
30
30
|
spec.add_runtime_dependency 'netrc', '~> 0.11.0'
|
31
31
|
spec.add_runtime_dependency 'open4', '~> 1.3', '>= 1.3.4'
|
32
32
|
spec.add_runtime_dependency 'highline', '~> 1.7', '>= 1.7.8'
|
@@ -41,11 +41,10 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_runtime_dependency 'launchy', '~> 2.4'
|
42
42
|
spec.add_runtime_dependency 'docker-api', '~> 1.33'
|
43
43
|
spec.add_runtime_dependency 'rubyzip', '~> 1.2'
|
44
|
-
spec.add_runtime_dependency 'activesupport', '~> 5.0'
|
44
|
+
spec.add_runtime_dependency 'activesupport', '~> 5.2.0'
|
45
45
|
spec.add_runtime_dependency 'ruby-progressbar'
|
46
46
|
spec.add_runtime_dependency 'net-ssh'
|
47
47
|
spec.add_runtime_dependency 'down'
|
48
|
-
spec.add_runtime_dependency 'faraday_middleware-request-retry'
|
49
48
|
|
50
49
|
|
51
50
|
|
data/lib/cnvrg/api.rb
CHANGED
@@ -81,8 +81,8 @@ module Cnvrg
|
|
81
81
|
response
|
82
82
|
end
|
83
83
|
when 'POST'
|
84
|
-
conn.options.timeout =
|
85
|
-
conn.options.open_timeout =
|
84
|
+
conn.options.timeout = 4200
|
85
|
+
conn.options.open_timeout =4200
|
86
86
|
retries = 0
|
87
87
|
success = false
|
88
88
|
while !success and retries < 20
|
@@ -121,8 +121,8 @@ module Cnvrg
|
|
121
121
|
fr.request :retry, max: 2, interval: 0.05,interval_randomness: 0.5, backoff_factor: 2
|
122
122
|
fr.adapter :net_http
|
123
123
|
end
|
124
|
-
conn.options.timeout =
|
125
|
-
conn.options.open_timeout =
|
124
|
+
conn.options.timeout = 4200
|
125
|
+
conn.options.open_timeout =4200
|
126
126
|
|
127
127
|
|
128
128
|
# what if windows?
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -147,7 +147,7 @@ module Cnvrg
|
|
147
147
|
IP = "localhost"
|
148
148
|
PORT = 7654
|
149
149
|
|
150
|
-
ParallelThreads ||=
|
150
|
+
ParallelThreads ||= 15
|
151
151
|
ParallelProcesses ||= Parallel.processor_count
|
152
152
|
|
153
153
|
class << self
|
@@ -647,6 +647,7 @@ module Cnvrg
|
|
647
647
|
desc 'link', 'Link current directory to a new cnvrg project'
|
648
648
|
method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
|
649
649
|
method_option :docker_image, :type => :string, :aliases => ["-d"], :default => ""
|
650
|
+
method_option :git, :type => :boolean, :aliases => ["-g","--git"], :default => false
|
650
651
|
|
651
652
|
def link
|
652
653
|
begin
|
@@ -660,6 +661,8 @@ module Cnvrg
|
|
660
661
|
end
|
661
662
|
|
662
663
|
sync = options["sync"]
|
664
|
+
git = options["git"] || false
|
665
|
+
|
663
666
|
project_name = File.basename(Dir.getwd)
|
664
667
|
log_message("Linking #{project_name}", Thor::Shell::Color::BLUE)
|
665
668
|
if File.directory?(Dir.getwd + "/.cnvrg")
|
@@ -669,7 +672,7 @@ module Cnvrg
|
|
669
672
|
end
|
670
673
|
working_dir = Dir.getwd
|
671
674
|
owner = CLI.get_owner
|
672
|
-
if Project.link(owner, project_name, docker)
|
675
|
+
if Project.link(owner, project_name, docker = docker,git = git)
|
673
676
|
path = Dir.pwd
|
674
677
|
@project = Project.new(path)
|
675
678
|
@project.generate_idx()
|
@@ -793,7 +796,9 @@ module Cnvrg
|
|
793
796
|
desc 'data clone', 'Clone dataset'
|
794
797
|
method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ""
|
795
798
|
method_option :only_tree, :type => :boolean, :aliases => ["-t", "--tree"], :default => false
|
796
|
-
|
799
|
+
method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => nil
|
800
|
+
|
801
|
+
def clone_data(dataset_url,only_tree=false,commit=nil,query=nil)
|
797
802
|
begin
|
798
803
|
verify_logged_in(false)
|
799
804
|
log_start(__method__, args, options)
|
@@ -805,7 +810,8 @@ module Cnvrg
|
|
805
810
|
project_index = Cnvrg::Helpers.look_for_in_path(dataset_url, "datasets")
|
806
811
|
slug = url_parts[project_index + 1]
|
807
812
|
owner = url_parts[project_index - 1]
|
808
|
-
|
813
|
+
|
814
|
+
response = Cnvrg::API.request("users/#{owner}/datasets/#{slug}/clone", 'POST',{ commit: commit, query:query})
|
809
815
|
Cnvrg::CLI.is_response_success(response,true)
|
810
816
|
dataset_name = response["result"]["name"]
|
811
817
|
dataset_home = Dir.pwd+"/"+dataset_name
|
@@ -819,12 +825,21 @@ module Cnvrg
|
|
819
825
|
end
|
820
826
|
|
821
827
|
end
|
828
|
+
check = Helpers.checkmark
|
829
|
+
|
822
830
|
if Dataset.clone(owner, dataset_name, slug)
|
823
831
|
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
824
832
|
@files = Cnvrg::Datafiles.new(owner, slug)
|
825
833
|
|
826
834
|
successful_changes = []
|
827
835
|
log_message("Downloading files", Thor::Shell::Color::BLUE)
|
836
|
+
if not(query.nil? or query.empty?)
|
837
|
+
@files.download_list_files_in_query(response["result"]["list_files"],dataset_home)
|
838
|
+
|
839
|
+
log_message("#{check} Clone finished successfully", Thor::Shell::Color::GREEN)
|
840
|
+
return
|
841
|
+
|
842
|
+
end
|
828
843
|
commit = response["result"]["commit"]
|
829
844
|
idx = {commit: response["result"]["commit"], tree: response["result"]["tree"]}
|
830
845
|
File.open(dataset_home + "/.cnvrg/idx.yml", "w+") {|f| f.write idx.to_yaml}
|
@@ -878,8 +893,6 @@ module Cnvrg
|
|
878
893
|
|
879
894
|
|
880
895
|
end
|
881
|
-
check = Helpers.checkmark
|
882
|
-
|
883
896
|
successful_changes = response["result"]["tree"]
|
884
897
|
if !successful_changes.nil? and is_success
|
885
898
|
Dataset.verify_cnvrgignore_exist(dataset_name, false)
|
@@ -899,10 +912,84 @@ module Cnvrg
|
|
899
912
|
say "\nAborting"
|
900
913
|
exit(1)
|
901
914
|
end
|
915
|
+
end
|
902
916
|
|
917
|
+
desc 'data clone_query', 'Clone dataset _query'
|
918
|
+
method_option :query, :type => :string, :aliases => ["-q", "--query"], :default => ""
|
919
|
+
def clone_data_query(dataset_url,query=nil)
|
920
|
+
begin
|
921
|
+
verify_logged_in(false)
|
922
|
+
log_start(__method__, args, options)
|
923
|
+
query = options["query"] || query
|
924
|
+
if !query.present?
|
925
|
+
log_message("Argument missing : query", Thor::Shell::Color::RED)
|
926
|
+
exit(1)
|
927
|
+
end
|
903
928
|
|
929
|
+
url_parts = dataset_url.split("/")
|
930
|
+
project_index = Cnvrg::Helpers.look_for_in_path(dataset_url, "datasets")
|
931
|
+
slug = url_parts[project_index + 1]
|
932
|
+
owner = url_parts[project_index - 1]
|
904
933
|
|
934
|
+
response = Cnvrg::API.request("users/#{owner}/datasets/#{slug}/search/#{query}", 'GET')
|
935
|
+
Cnvrg::CLI.is_response_success(response,true)
|
936
|
+
dataset_name = response["results"]["name"]
|
937
|
+
dataset_slug = response["results"]["slug"]
|
938
|
+
# dataset_home = Dir.pwd+"/"+dataset_name
|
939
|
+
dataset_home = Dir.pwd
|
905
940
|
|
941
|
+
if Dataset.blank_clone(owner, dataset_name, dataset_slug)
|
942
|
+
dataset = Dataset.new(dataset_home)
|
943
|
+
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
944
|
+
parallel_options = {
|
945
|
+
:progress => {
|
946
|
+
:title => "Download Progress",
|
947
|
+
:progress_mark => '=',
|
948
|
+
:format => "%b>>%i| %p%% %t",
|
949
|
+
:starting_at => 0,
|
950
|
+
:total => response["results"]["query_files"].size,
|
951
|
+
:autofinish => true
|
952
|
+
},
|
953
|
+
in_threads: ParallelThreads
|
954
|
+
}
|
955
|
+
begin
|
956
|
+
log_message("Downloading files", Thor::Shell::Color::BLUE)
|
957
|
+
Parallel.map((response["results"]["query_files"]), parallel_options) do |f|
|
958
|
+
relative_path = f["fullpath"].gsub(/^#{dataset_home}/, "")
|
959
|
+
relative_path_dir = relative_path.split("/")
|
960
|
+
file_name = relative_path_dir.pop()
|
961
|
+
relative_path_dir = relative_path_dir.join("/")
|
962
|
+
abs_path = dataset_home + "/" + relative_path_dir
|
963
|
+
begin
|
964
|
+
FileUtils.mkdir_p(abs_path) unless File.exist? (abs_path + "/" + file_name)
|
965
|
+
rescue
|
966
|
+
log_message("Could not create directory: #{abs_path}", Thor::Shell::Color::RED)
|
967
|
+
exit(1)
|
968
|
+
end
|
969
|
+
begin
|
970
|
+
File.write "#{abs_path}/#{file_name}", open(f["s3_url"]).read unless File.exist? (abs_path + "/" + file_name)
|
971
|
+
rescue
|
972
|
+
log_message("Could not download file: #{f["fullpath"]}", Thor::Shell::Color::RED)
|
973
|
+
exit(1)
|
974
|
+
end
|
975
|
+
|
976
|
+
end
|
977
|
+
rescue Interrupt
|
978
|
+
log_message("Couldn't download", Thor::Shell::Color::RED)
|
979
|
+
exit(1)
|
980
|
+
end
|
981
|
+
begin
|
982
|
+
dataset.generate_idx()
|
983
|
+
check = Helpers.checkmark
|
984
|
+
log_message("#{check} Clone finished successfully", Thor::Shell::Color::GREEN)
|
985
|
+
rescue
|
986
|
+
exit(1)
|
987
|
+
end
|
988
|
+
end
|
989
|
+
rescue SignalException
|
990
|
+
say "\nAborting"
|
991
|
+
exit(1)
|
992
|
+
end
|
906
993
|
end
|
907
994
|
|
908
995
|
desc 'init_data_container', 'Init dataset directory', :hide => true
|
@@ -1210,7 +1297,11 @@ module Cnvrg
|
|
1210
1297
|
if (Cnvrg::CLI.is_response_success(res, false))
|
1211
1298
|
# save idx
|
1212
1299
|
begin
|
1213
|
-
|
1300
|
+
list_files = []
|
1301
|
+
list_files.concat successful_deletions
|
1302
|
+
list_files.concat successful_updates
|
1303
|
+
|
1304
|
+
@dataset.update_idx_with_files_commits!(list_files, res["result"]["commit_time"])
|
1214
1305
|
|
1215
1306
|
@dataset.update_idx_with_commit!(commit_sha1)
|
1216
1307
|
rescue => e
|
@@ -1490,7 +1581,44 @@ module Cnvrg
|
|
1490
1581
|
print_table(list)
|
1491
1582
|
|
1492
1583
|
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
desc 'data queries', 'List all data search queries you currently have'
|
1587
|
+
|
1588
|
+
def queries
|
1589
|
+
verify_logged_in(false)
|
1590
|
+
log_start(__method__, args, options)
|
1591
|
+
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
1592
|
+
@dataset = Dataset.new(dataset_dir)
|
1593
|
+
result = @dataset.search_queries()
|
1594
|
+
print_table(result)
|
1595
|
+
end
|
1596
|
+
|
1597
|
+
desc 'data download_tags_yaml', 'Download dataset tags yml file in current directory'
|
1598
|
+
|
1599
|
+
def download_tags_yaml
|
1600
|
+
verify_logged_in(false)
|
1601
|
+
log_start(__method__, args, options)
|
1602
|
+
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
1603
|
+
@dataset = Dataset.new(dataset_dir)
|
1604
|
+
status = @dataset.download_tags_yaml()
|
1605
|
+
if status
|
1606
|
+
log_message("Downloaded tags yaml successfully", Thor::Shell::Color::GREEN)
|
1607
|
+
else
|
1608
|
+
log_message("Unable to download", Thor::Shell::Color::RED)
|
1493
1609
|
end
|
1610
|
+
end
|
1611
|
+
|
1612
|
+
desc 'data query_files', 'List all data search queries you currently have'
|
1613
|
+
def query_files(query)
|
1614
|
+
verify_logged_in(false)
|
1615
|
+
log_start(__method__, args, options)
|
1616
|
+
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
1617
|
+
@dataset = Dataset.new(dataset_dir)
|
1618
|
+
query = options["query"] || query
|
1619
|
+
result = @dataset.get_query_file(query)
|
1620
|
+
print_table(result)
|
1621
|
+
end
|
1494
1622
|
|
1495
1623
|
desc 'data commits', 'List all commits for a specific dataset'
|
1496
1624
|
|
@@ -1532,6 +1660,51 @@ module Cnvrg
|
|
1532
1660
|
FileUtils.rm_rf list_to_del
|
1533
1661
|
end
|
1534
1662
|
|
1663
|
+
|
1664
|
+
|
1665
|
+
desc 'git_clone', 'Clone project'
|
1666
|
+
def git_clone(slug, owner)
|
1667
|
+
verify_logged_in(false)
|
1668
|
+
log_start(__method__, args, options)
|
1669
|
+
|
1670
|
+
clone_resp = Project.clone_dir_remote(slug, owner, slug,true)
|
1671
|
+
idx_status = Project.new(get_project_home).generate_idx
|
1672
|
+
end
|
1673
|
+
|
1674
|
+
|
1675
|
+
desc 'link git project', 'link git project'
|
1676
|
+
method_option :git, :type => :boolean, :aliases => ["-g", "--git"], :default => false
|
1677
|
+
def link_git(project_url)
|
1678
|
+
begin
|
1679
|
+
verify_logged_in(false)
|
1680
|
+
log_start(__method__, args, options)
|
1681
|
+
url_parts = project_url.split("/")
|
1682
|
+
project_index = Cnvrg::Helpers.look_for_in_path(project_url, "projects")
|
1683
|
+
slug = url_parts[project_index + 1]
|
1684
|
+
owner = url_parts[project_index - 1]
|
1685
|
+
response = Cnvrg::API.request("users/#{owner}/projects/#{slug}/get_project", 'GET')
|
1686
|
+
Cnvrg::CLI.is_response_success(response)
|
1687
|
+
response = JSON.parse response["result"]
|
1688
|
+
project_name = response["title"]
|
1689
|
+
|
1690
|
+
log_message("Linking #{project_name}", Thor::Shell::Color::BLUE)
|
1691
|
+
clone_resp = Project.clone_dir_remote(slug, owner, project_name, true)
|
1692
|
+
idx_status = Project.new(get_project_home).generate_idx
|
1693
|
+
log_message("Linking project #{project_name} successfully", Thor::Shell::Color::GREEN)
|
1694
|
+
|
1695
|
+
return
|
1696
|
+
rescue => e
|
1697
|
+
log_message("Error occurred, \nAborting", Thor::Shell::Color::RED)
|
1698
|
+
log_error(e)
|
1699
|
+
return
|
1700
|
+
rescue SignalException
|
1701
|
+
|
1702
|
+
say "\nAborting", Thor::Shell::Color::BLUE
|
1703
|
+
return
|
1704
|
+
end
|
1705
|
+
|
1706
|
+
end
|
1707
|
+
|
1535
1708
|
desc 'clone', 'Clone project'
|
1536
1709
|
method_option :remote, :type => :boolean, :aliases => ["-r", "--r"], :default => false
|
1537
1710
|
method_option :commit, :type => :string, :aliases => ["-c", "--c"], :default => nil
|
@@ -1545,17 +1718,34 @@ module Cnvrg
|
|
1545
1718
|
slug = url_parts[project_index + 1]
|
1546
1719
|
owner = url_parts[project_index - 1]
|
1547
1720
|
remote = options["remote"] || false
|
1721
|
+
|
1548
1722
|
response = Cnvrg::API.request("users/#{owner}/projects/#{slug}/get_project", 'GET')
|
1549
1723
|
Cnvrg::CLI.is_response_success(response)
|
1550
1724
|
response = JSON.parse response["result"]
|
1551
1725
|
project_name = response["title"]
|
1726
|
+
git = response["git"] || false
|
1727
|
+
|
1552
1728
|
commit_to_clone = options["commit"] || nil
|
1553
1729
|
|
1554
1730
|
log_message("Cloning #{project_name}", Thor::Shell::Color::BLUE)
|
1555
1731
|
clone_resp = false
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1732
|
+
project_home = Dir.pwd
|
1733
|
+
|
1734
|
+
if remote and !git
|
1735
|
+
clone_resp = Project.clone_dir_remote(slug, owner, project_name,git)
|
1736
|
+
elsif git
|
1737
|
+
if remote
|
1738
|
+
clone_resp = Project.clone_dir_remote(slug, owner, project_name,git)
|
1739
|
+
else
|
1740
|
+
project_home += "/#{project_name}"
|
1741
|
+
clone_resp = Project.clone_dir(slug, owner, project_name,git)
|
1742
|
+
|
1743
|
+
end
|
1744
|
+
|
1745
|
+
idx_status = Project.new(project_home).generate_idx
|
1746
|
+
log_message("Cloned project #{project_name} successfully", Thor::Shell::Color::GREEN)
|
1747
|
+
|
1748
|
+
return
|
1559
1749
|
else
|
1560
1750
|
if (Dir.exists? project_name)
|
1561
1751
|
# project_name = "#{project_name}_#{rand(1 .. 5000000000)}"
|
@@ -1567,7 +1757,7 @@ module Cnvrg
|
|
1567
1757
|
end
|
1568
1758
|
|
1569
1759
|
end
|
1570
|
-
clone_resp = Project.clone_dir(slug, owner, project_name)
|
1760
|
+
clone_resp = Project.clone_dir(slug, owner, project_name,git)
|
1571
1761
|
project_home = Dir.pwd + "/" + project_name
|
1572
1762
|
|
1573
1763
|
|
@@ -1766,21 +1956,25 @@ module Cnvrg
|
|
1766
1956
|
exit(1)
|
1767
1957
|
end
|
1768
1958
|
end
|
1769
|
-
desc 'sync_data_new', 'sync_data_new'
|
1959
|
+
desc 'sync_data_new', 'sync_data_new', :hide=> true
|
1770
1960
|
method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
|
1771
1961
|
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
1772
1962
|
method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
|
1963
|
+
method_option :sync, :type => :boolean, :aliases => ["-s","--sync"], :default => false
|
1964
|
+
method_option :tags, :type => :string, :aliases => ["--tags"], :desc => "upload file tags", :default => ""
|
1773
1965
|
method_option :commit, :type => :string, :aliases => ["-c"], :desc => "download specified commit", :default => nil
|
1774
1966
|
method_option :all_files, :type => :boolean, :aliases => ["--all"], :desc => "download specified commit", :default => true
|
1967
|
+
method_option :parallel, :type => :numeric, :aliases => ["-p", "--parallel"], :desc => "uparallel upload at the same time", :default => 15
|
1775
1968
|
|
1776
|
-
def sync_data_new(new_branch, force, verbose, commit, all_files)
|
1969
|
+
def sync_data_new(new_branch, force, verbose, commit, all_files, tags,parallel)
|
1777
1970
|
verify_logged_in(true)
|
1778
1971
|
log_start(__method__, args, options)
|
1779
1972
|
log_message('Syncing dataset', Thor::Shell::Color::BLUE, !options["verbose"])
|
1780
1973
|
if !options[:force]
|
1781
1974
|
invoke :download_data_new,[verbose,true, commit, all_files], :new_branch=>new_branch, :direct=>false, :force =>force
|
1782
1975
|
end
|
1783
|
-
invoke :upload_data_new,[new_branch, verbose,true,force], :new_branch=>new_branch,
|
1976
|
+
invoke :upload_data_new,[new_branch, verbose,true,force, tags], :new_branch=>new_branch,
|
1977
|
+
:direct=>false, :force =>force, :sync =>true, :tags =>tags, :parallel => parallel
|
1784
1978
|
|
1785
1979
|
end
|
1786
1980
|
desc 'upload_data_new', 'upload_data_new'
|
@@ -1788,10 +1982,34 @@ module Cnvrg
|
|
1788
1982
|
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
1789
1983
|
method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
|
1790
1984
|
method_option :sync, :type => :boolean, :aliases => ["-s","--sync"], :default => false
|
1791
|
-
|
1792
|
-
|
1985
|
+
method_option :tags, :type => :boolean, :aliases => ["--tags"], :desc => "upload file tags", :default => false
|
1986
|
+
method_option :parallel, :type => :numeric, :aliases => ["-p", "--parallel"], :desc => "uparallel upload at the same time", :default => 15
|
1987
|
+
|
1988
|
+
def upload_data_new(new_branch, verbose,sync,force, tags)
|
1989
|
+
commit = invoke :start_commit_data,[], :new_branch=> new_branch, :direct=>false, :force =>force
|
1990
|
+
upload_res = invoke :upload_data_files,[commit],:new_branch=>new_branch, :verbose =>verbose,
|
1991
|
+
:force =>force, :sync =>sync,:parallel => options[:parallel]
|
1992
|
+
if upload_res
|
1993
|
+
invoke :end_commit_data,[commit] , :new_branch=>new_branch, :force =>force
|
1994
|
+
end
|
1995
|
+
if tags
|
1996
|
+
log_message('Uploading Tags', Thor::Shell::Color::BLUE)
|
1997
|
+
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
1998
|
+
@dataset = Dataset.new(dataset_dir)
|
1999
|
+
begin
|
2000
|
+
tag_file = File.open(options[:tags], "r+")
|
2001
|
+
status = @dataset.upload_tags_via_yml(tag_file)
|
2002
|
+
rescue
|
2003
|
+
log_message('Tags file not found', Thor::Shell::Color::RED)
|
2004
|
+
return
|
2005
|
+
end
|
2006
|
+
if status
|
2007
|
+
log_message('Tags are successfully uploaded', Thor::Shell::Color::GREEN)
|
2008
|
+
else
|
2009
|
+
log_message('There was some error in uploading Tags', Thor::Shell::Color::RED)
|
2010
|
+
end
|
2011
|
+
end
|
1793
2012
|
|
1794
|
-
upload_res = invoke :upload_data_files,[commit],:new_branch=>new_branch, :verbose =>verbose, :force =>force, :sync =>sync
|
1795
2013
|
if upload_res
|
1796
2014
|
invoke :end_commit_data,[commit] , :new_branch=>new_branch, :force =>force
|
1797
2015
|
end
|
@@ -1925,6 +2143,9 @@ module Cnvrg
|
|
1925
2143
|
method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
|
1926
2144
|
method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
|
1927
2145
|
method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
|
2146
|
+
method_option :tags, :type => :string, :aliases => ["--tags"], :desc => "upload file tags", :default => ""
|
2147
|
+
# method_option :tags_yml, :type => :boolean, :aliases => ["--file_tag_yml"], :default => false
|
2148
|
+
method_option :parallel, :type => :numeric, :aliases => ["-p", "--parallel"], :desc => "uparallel upload at the same time", :default => 15
|
1928
2149
|
|
1929
2150
|
def upload_data_files(new_commit, *files)
|
1930
2151
|
|
@@ -1944,10 +2165,10 @@ module Cnvrg
|
|
1944
2165
|
end
|
1945
2166
|
|
1946
2167
|
force = options[:force] || false
|
1947
|
-
|
2168
|
+
parallel_threads = options["parallel"] || ParallelThreads
|
1948
2169
|
new_branch = options["new_branch"] || false
|
1949
2170
|
log_message("Checking dataset", Thor::Shell::Color::BLUE) unless options[:sync]
|
1950
|
-
local_idx = @dataset.generate_idx
|
2171
|
+
local_idx = @dataset.generate_idx(true)
|
1951
2172
|
result = @dataset.compare_idx(new_branch, commit=@dataset.last_local_commit, local_idx= local_idx, force=force, next_commit= next_commit)
|
1952
2173
|
|
1953
2174
|
commit_sha1 = result["result"]["commit"]
|
@@ -1987,7 +2208,6 @@ module Cnvrg
|
|
1987
2208
|
|
1988
2209
|
# upload / update
|
1989
2210
|
begin
|
1990
|
-
|
1991
2211
|
parallel_options = {
|
1992
2212
|
:progress => {
|
1993
2213
|
:title => "Upload Progress",
|
@@ -1997,7 +2217,7 @@ module Cnvrg
|
|
1997
2217
|
:total => (result["added"] + result["updated_on_local"]).size,
|
1998
2218
|
:autofinish => true
|
1999
2219
|
},
|
2000
|
-
in_threads:
|
2220
|
+
in_threads: parallel_threads.to_i,
|
2001
2221
|
isolation: true
|
2002
2222
|
}
|
2003
2223
|
successful_updates = []
|
@@ -2152,10 +2372,10 @@ module Cnvrg
|
|
2152
2372
|
method_option :message, :type => :string, :aliases => ["-m", "--message"], :default => ""
|
2153
2373
|
method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
|
2154
2374
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
2155
|
-
method_option :files, :type => :string, :aliases => ["
|
2156
|
-
|
2157
|
-
def upload(link = false, sync = false, direct = false, ignore_list = "", in_exp = false)
|
2375
|
+
method_option :files, :type => :string, :aliases => ["--files"], :default => nil
|
2376
|
+
method_option :output_dir, :type => :string, :aliases => ["--output_dir"], :default => nil
|
2158
2377
|
|
2378
|
+
def upload(link = false, sync = false, direct = false, ignore_list = "", in_exp = false, force = false)
|
2159
2379
|
begin
|
2160
2380
|
verify_logged_in(true)
|
2161
2381
|
log_start(__method__, args, options)
|
@@ -2173,6 +2393,11 @@ module Cnvrg
|
|
2173
2393
|
if !spec_files_to_upload.blank?
|
2174
2394
|
spec_files_to_upload = spec_files_to_upload.split(",")
|
2175
2395
|
end
|
2396
|
+
git_output_dir = options["output_dir"]
|
2397
|
+
if !git_output_dir.blank?
|
2398
|
+
spec_files_to_upload = Dir.glob("#{git_output_dir}/**/*", File::FNM_DOTMATCH).flatten
|
2399
|
+
force = true
|
2400
|
+
end
|
2176
2401
|
|
2177
2402
|
if ignore.nil? or ignore.empty?
|
2178
2403
|
ignore = ignore_list
|
@@ -2201,6 +2426,7 @@ module Cnvrg
|
|
2201
2426
|
log_message("Comparing local changes with remote version:", Thor::Shell::Color::BLUE, (options["verbose"]))
|
2202
2427
|
end
|
2203
2428
|
result = result["result"]["tree"]
|
2429
|
+
|
2204
2430
|
check = Helpers.checkmark()
|
2205
2431
|
if result["added"].empty? and result["updated_on_local"].empty? and result["deleted"].empty?
|
2206
2432
|
log_message("#{check} Project is up to date", Thor::Shell::Color::GREEN, (((options["sync"] or sync) and !direct) ? false : true))
|
@@ -2685,8 +2911,42 @@ module Cnvrg
|
|
2685
2911
|
say "\nAborting", Thor::Shell::Color::BLUE
|
2686
2912
|
exit(1)
|
2687
2913
|
end
|
2914
|
+
end
|
2915
|
+
desc 'download in git project', 'Download other files', :hide =>true
|
2916
|
+
def download_in_git(commit_sha1)
|
2917
|
+
begin
|
2918
|
+
verify_logged_in(true)
|
2919
|
+
log_start(__method__, args, options)
|
2920
|
+
project_home = get_project_home
|
2921
|
+
@project = Project.new(project_home)
|
2922
|
+
@files = Cnvrg::Files.new(@project.owner, @project.slug)
|
2923
|
+
res = @project.git_download_commit(commit_sha1)
|
2924
|
+
files = res.try(:fetch, "result").try(:fetch, "files")
|
2925
|
+
if files.blank?
|
2926
|
+
log_message("No files to download", Thor::Shell::Color::RED)
|
2927
|
+
return
|
2928
|
+
end
|
2929
|
+
|
2930
|
+
begin
|
2931
|
+
download_result = @files.download_multiple_files_s3(files, project_home)
|
2932
|
+
if download_result
|
2933
|
+
log_message("Done.\nDownloaded finished successfully", Thor::Shell::Color::GREEN)
|
2934
|
+
else
|
2935
|
+
log_message("Error while trying to download\n", Thor::Shell::Color::RED)
|
2936
|
+
|
2937
|
+
end
|
2938
|
+
|
2939
|
+
rescue => e
|
2940
|
+
log_error(e)
|
2941
|
+
puts e.backtrace
|
2942
|
+
log_message("Error while trying to download ", Thor::Shell::Color::RED)
|
2943
|
+
return
|
2944
|
+
end
|
2945
|
+
|
2946
|
+
end
|
2688
2947
|
end
|
2689
2948
|
|
2949
|
+
|
2690
2950
|
desc 'download', 'Download updated files'
|
2691
2951
|
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
2692
2952
|
method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
|
@@ -2727,19 +2987,6 @@ module Cnvrg
|
|
2727
2987
|
log_message("Project is up to date", Thor::Shell::Color::GREEN, ((options["sync"] or sync) ? false : true))
|
2728
2988
|
return true
|
2729
2989
|
end
|
2730
|
-
# if result["added"].any? {|x| x.include? ".conflict"} or !result["conflicts"].empty?
|
2731
|
-
# all = result["added"].select {|x| x.include? ".conflict"} +result["conflicts"].flatten
|
2732
|
-
# if all.size == 1
|
2733
|
-
# num = "1 conflict"
|
2734
|
-
# else
|
2735
|
-
# num = "#{result["conflicts"].size} conflicts"
|
2736
|
-
# end
|
2737
|
-
# say "Project contains #{num}:", Thor::Shell::Color::RED
|
2738
|
-
# say "#{all.join("\n")}"
|
2739
|
-
# say "Please fix them, and retry", Thor::Shell::Color::RED
|
2740
|
-
# exit(1)
|
2741
|
-
# end
|
2742
|
-
update_count = 0
|
2743
2990
|
update_total = result["updated_on_server"].size + result["conflicts"].size + result["deleted"].size
|
2744
2991
|
|
2745
2992
|
|
@@ -2906,7 +3153,6 @@ module Cnvrg
|
|
2906
3153
|
|
2907
3154
|
desc 'jump', 'jump to specific commit'
|
2908
3155
|
method_option :remote, :type => :boolean, :aliases => ["-r", "--r"], :default => false
|
2909
|
-
|
2910
3156
|
def jump(commit_sha1)
|
2911
3157
|
begin
|
2912
3158
|
verify_logged_in()
|
@@ -3073,18 +3319,21 @@ module Cnvrg
|
|
3073
3319
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
3074
3320
|
method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
|
3075
3321
|
method_option :in_exp, :type => :boolean, :aliases => ["-e", "--in_exp"], :default => false
|
3076
|
-
method_option :files, :type => :string, :aliases => ["
|
3322
|
+
method_option :files, :type => :string, :aliases => ["--files"], :default => nil
|
3323
|
+
method_option :output_dir, :type => :string, :aliases => ["--output_dir"], :default => nil
|
3324
|
+
|
3077
3325
|
|
3078
3326
|
def sync(direct = true)
|
3079
3327
|
verify_logged_in(true) if direct
|
3080
3328
|
log_start(__method__, args, options)
|
3081
3329
|
log_message('Checking for new updates from remote version', Thor::Shell::Color::BLUE, options["verbose"])
|
3082
3330
|
log_message('Syncing project', Thor::Shell::Color::BLUE, !options["verbose"])
|
3083
|
-
if !options[:force] and options[:files].blank?
|
3331
|
+
if !options[:force] and (options[:files].blank? or options[:output_dir].blank?)
|
3084
3332
|
invoke :download, [true, "", options["in_exp"] ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true
|
3085
3333
|
end
|
3086
3334
|
invoke :upload, [false, true, direct, "",options["in_exp"] ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true,
|
3087
|
-
:ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"], :return_id => options["return_id"],
|
3335
|
+
:ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"], :return_id => options["return_id"],
|
3336
|
+
:files => options["files"], :output_dir => options["output_dir"]
|
3088
3337
|
|
3089
3338
|
|
3090
3339
|
end
|
@@ -3107,7 +3356,7 @@ module Cnvrg
|
|
3107
3356
|
method_option :upload_output, :type => :string, :aliases => ["-uo", "--upload_output"], :default => ""
|
3108
3357
|
method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ""
|
3109
3358
|
method_option :schedule, :type => :string, :aliases => ["-s", "--schedule"], :default => ""
|
3110
|
-
method_option :image, :type => :string, :aliases => ["
|
3359
|
+
method_option :image, :type => :string, :aliases => ["--image"], :default => ""
|
3111
3360
|
method_option :grid, :type => :string, :aliases => ["-g", "--grid"], :default => ""
|
3112
3361
|
method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
|
3113
3362
|
method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
|
@@ -3117,6 +3366,11 @@ module Cnvrg
|
|
3117
3366
|
method_option :periodic_sync, :type => :string, :aliases => ["-ps", "--periodic_sync"], :default => nil #//15,30,45,60
|
3118
3367
|
method_option :max_time, :type => :string, :aliases => [ "--max_time"], :default => nil
|
3119
3368
|
method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
|
3369
|
+
method_option :output_dir, :type => :string, :aliases => ["-o", "--output_dir"], :default => nil
|
3370
|
+
method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => nil
|
3371
|
+
method_option :git_commit, :type => :string, :aliases => [ "--git_commit"], :default => nil
|
3372
|
+
method_option :git_branch, :type => :string, :aliases => [ "--git_branch"], :default => nil
|
3373
|
+
|
3120
3374
|
|
3121
3375
|
def run(*cmd)
|
3122
3376
|
verify_logged_in(true)
|
@@ -3141,12 +3395,26 @@ module Cnvrg
|
|
3141
3395
|
max_time = options["max_time"]
|
3142
3396
|
dataset_only_tree = options["dataset_only_tree"]
|
3143
3397
|
custom_machine = options["machine"]
|
3398
|
+
output_dir = options["output_dir"]
|
3399
|
+
data_query = options["data_query"]
|
3400
|
+
if !data.present? and data_query.present?
|
3401
|
+
log_message("Please provide data with data_query", Thor::Shell::Color::RED)
|
3402
|
+
exit(1)
|
3403
|
+
end
|
3404
|
+
if data_query.present? and (data_commit.present? or dataset_only_tree.present?)
|
3405
|
+
log_message("Please use only one option: --query(-q) or #{data_commit.present? ? '--data_commit' : '--dataset_only_tree'} ", Thor::Shell::Color::RED)
|
3406
|
+
exit(1)
|
3407
|
+
end
|
3408
|
+
git_commit = options["git_commit"]
|
3409
|
+
git_branch = options["git_branch"]
|
3410
|
+
|
3144
3411
|
|
3145
3412
|
options_hash = Hash[options]
|
3413
|
+
|
3146
3414
|
if local
|
3147
3415
|
invoke :exec, [cmd], :sync_before => sync_before, :sync_after => sync_after, :title => title,
|
3148
3416
|
:log => log, :email_notification => email_notification, :upload_output => upload_output,
|
3149
|
-
:commit => commit, :image => image, :data => data, :data_commit => data_commit, :ignore => ignore, :force => force
|
3417
|
+
:commit => commit, :image => image, :data => data, :data_commit => data_commit, :ignore => ignore, :force => force, :output_dir=>output_dir, :data_query=>data_query
|
3150
3418
|
return
|
3151
3419
|
else
|
3152
3420
|
if !periodic_sync.nil? and !periodic_sync.empty?
|
@@ -3161,15 +3429,16 @@ module Cnvrg
|
|
3161
3429
|
|
3162
3430
|
end
|
3163
3431
|
end
|
3164
|
-
instances = {"small" => options["small"], "medium" => options["medium"], "large" => options["large"],
|
3432
|
+
instances = { "small" => options["small"], "medium" => options["medium"], "large" => options["large"],
|
3165
3433
|
"gpu" => options["gpu"], "gpuxl" => options["gpuxl"], "gpuxxl" => options["gpuxxl"],
|
3166
|
-
options["machine"] => !options["machine"].blank?}
|
3434
|
+
options["machine"] => !options["machine"].blank? }
|
3167
3435
|
instance_type = get_instance_type(instances)
|
3168
3436
|
invoke :exec_remote, [cmd], :sync_before => sync_before, :sync_after => sync_after, :title => title, :machine_type => instance_type,
|
3169
3437
|
:schedule => schedule, :log => log, :email_notification => email_notification, :upload_output => upload_output, :commit => commit,
|
3170
3438
|
:image => image, :grid => grid, :data => data, :data_commit => data_commit, :ignore => ignore, :force => force, :sync_before_terminate => sync_before_terminate,
|
3171
3439
|
:max_time => max_time,
|
3172
|
-
:periodic_sync => periodic_sync, :dataset_only_tree=> dataset_only_tree
|
3440
|
+
:periodic_sync => periodic_sync, :dataset_only_tree=> dataset_only_tree,
|
3441
|
+
:output_dir=>output_dir, :data_query=>data_query, :git_commit =>git_commit, :git_branch=> git_branch
|
3173
3442
|
return
|
3174
3443
|
end
|
3175
3444
|
|
@@ -3193,6 +3462,9 @@ module Cnvrg
|
|
3193
3462
|
method_option :force, :type => :boolean, :aliases => ["-f", "--force"], :default => false
|
3194
3463
|
method_option :sync_before_terminate, :type => :boolean, :aliases => ["-sbt", "--sync_before_terminate"], :default => false
|
3195
3464
|
method_option :periodic_sync, :type => :string, :aliases => ["-ps", "--periodic_sync"], :default => ""
|
3465
|
+
method_option :output_dir, :type => :string, :aliases => ["-o", "--output_dir"], :default => nil
|
3466
|
+
method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => nil
|
3467
|
+
|
3196
3468
|
def exec(*cmd)
|
3197
3469
|
log = []
|
3198
3470
|
verify_logged_in(true)
|
@@ -3215,12 +3487,14 @@ module Cnvrg
|
|
3215
3487
|
|
3216
3488
|
|
3217
3489
|
email_notification = options["email_notification"]
|
3218
|
-
upload_output = options["upload_output"]
|
3219
|
-
upload_output = "1m" if upload_output.nil? or upload_output.empty?
|
3220
|
-
time_to_upload = calc_output_time(upload_output)
|
3221
3490
|
project_home = get_project_home
|
3491
|
+
data_query = options["data_query"]
|
3222
3492
|
@project = Project.new(project_home)
|
3223
|
-
|
3493
|
+
if @project.is_git
|
3494
|
+
sync_before = false
|
3495
|
+
end
|
3496
|
+
# is_new_branch = @project.compare_commit(commit)
|
3497
|
+
is_new_branch = false
|
3224
3498
|
begin
|
3225
3499
|
if !commit.nil? and !commit.empty?
|
3226
3500
|
invoke :jump, [commit], []
|
@@ -3287,13 +3561,30 @@ module Cnvrg
|
|
3287
3561
|
spot_status_thread = Thread.new do
|
3288
3562
|
begin
|
3289
3563
|
loop do
|
3564
|
+
puts "Checking Spot Instance Status"
|
3565
|
+
log_message('Checking Spot Instance Status', Thor::Shell::Color::YELLOW)
|
3290
3566
|
restart = @exp.restart_spot_instance()
|
3567
|
+
|
3291
3568
|
if restart
|
3292
3569
|
log_message('Spot instance is going to be terminated', Thor::Shell::Color::YELLOW)
|
3293
3570
|
# sync
|
3294
|
-
|
3295
|
-
|
3296
|
-
|
3571
|
+
if @project.is_git
|
3572
|
+
output_dir = @exp.output_dir
|
3573
|
+
|
3574
|
+
if output_dir.blank?
|
3575
|
+
output_dir = "output"
|
3576
|
+
end
|
3577
|
+
invoke :upload, [false, true, false, ignore, true, true], :output_dir => output_dir, :force=>true
|
3578
|
+
else
|
3579
|
+
upload_res = upload(false, true, false, ignore, true, true)
|
3580
|
+
|
3581
|
+
end
|
3582
|
+
res = @exp.send_restart_request(@project.get_idx.try(:fetch, :commit))
|
3583
|
+
while !Cnvrg::CLI.is_response_success(res, false) do
|
3584
|
+
sleep(5)
|
3585
|
+
res = @exp.send_restart_request(@project.get_idx.try(:fetch, :commit))
|
3586
|
+
end
|
3587
|
+
exit(0)
|
3297
3588
|
end
|
3298
3589
|
sleep(10)
|
3299
3590
|
end
|
@@ -3321,23 +3612,7 @@ module Cnvrg
|
|
3321
3612
|
end
|
3322
3613
|
end
|
3323
3614
|
end
|
3324
|
-
|
3325
|
-
while process_running or !log.empty? do
|
3326
|
-
begin
|
3327
|
-
temp_log = log
|
3328
|
-
if !temp_log.empty?
|
3329
|
-
@exp.upload_temp_log(temp_log) unless temp_log.empty?
|
3330
|
-
|
3331
|
-
end
|
3332
|
-
log -= temp_log
|
3333
|
-
rescue => e
|
3334
|
-
log_message("Failed to upload ongoing results, continuing with experiment", Thor::Shell::Color::YELLOW)
|
3335
|
-
log_error(e)
|
3336
|
-
ensure
|
3337
|
-
sleep 10
|
3338
|
-
end
|
3339
|
-
end
|
3340
|
-
end
|
3615
|
+
start_time = Time.now
|
3341
3616
|
PTY.spawn(cmd) do |stdout, stdin, pid, stderr|
|
3342
3617
|
begin
|
3343
3618
|
stdout.each do |line|
|
@@ -3348,15 +3623,18 @@ module Cnvrg
|
|
3348
3623
|
type: "stdout",
|
3349
3624
|
real: real_time
|
3350
3625
|
}
|
3351
|
-
$LOG.info(cur_log)
|
3352
3626
|
if print_log
|
3353
3627
|
puts cur_log
|
3354
3628
|
end
|
3355
3629
|
log << cur_log
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3630
|
+
if log.size >= 15
|
3631
|
+
@exp.upload_temp_log(log) unless log.empty?
|
3632
|
+
log = []
|
3633
|
+
elsif (start_time + 30.seconds) <= Time.now
|
3634
|
+
@exp.upload_temp_log(log) unless log.empty?
|
3635
|
+
log = []
|
3636
|
+
start_time = Time.now
|
3637
|
+
end
|
3360
3638
|
end
|
3361
3639
|
if stderr
|
3362
3640
|
stderr.each do |err|
|
@@ -3366,10 +3644,8 @@ module Cnvrg
|
|
3366
3644
|
rescue Errno::EIO => e
|
3367
3645
|
log_error(e)
|
3368
3646
|
if !log.empty?
|
3369
|
-
|
3370
3647
|
temp_log = log
|
3371
3648
|
@exp.upload_temp_log(temp_log) unless temp_log.empty?
|
3372
|
-
|
3373
3649
|
log -= temp_log
|
3374
3650
|
end
|
3375
3651
|
rescue Errno::ENOENT => e
|
@@ -3380,7 +3656,6 @@ module Cnvrg
|
|
3380
3656
|
# exp_success = false
|
3381
3657
|
# log_message("The process exited!", Thor::Shell::Color::RED)
|
3382
3658
|
rescue => e
|
3383
|
-
sleep(20) # end cycle
|
3384
3659
|
res = @exp.end(log, 1, start_commit, 0, 0)
|
3385
3660
|
log_message("Error occurred,aborting", Thor::Shell::Color::RED)
|
3386
3661
|
log_error(e)
|
@@ -3394,7 +3669,6 @@ module Cnvrg
|
|
3394
3669
|
|
3395
3670
|
temp_log = log
|
3396
3671
|
@exp.upload_temp_log(temp_log) unless temp_log.empty?
|
3397
|
-
|
3398
3672
|
log -= temp_log
|
3399
3673
|
end
|
3400
3674
|
|
@@ -3410,8 +3684,17 @@ module Cnvrg
|
|
3410
3684
|
upload_res_count = 0
|
3411
3685
|
upload_res = false
|
3412
3686
|
while !upload_res and upload_res_count <5
|
3687
|
+
if @project.is_git
|
3688
|
+
if !upload_output.blank?
|
3689
|
+
upload_output = upload_output.join(",")
|
3690
|
+
invoke :upload, [false, true, false, ignore, true, true], :output_dir => upload_output, :force=>true
|
3691
|
+
end
|
3692
|
+
|
3693
|
+
else
|
3694
|
+
upload_res = upload(false, true, false, ignore, true, false)
|
3695
|
+
|
3413
3696
|
|
3414
|
-
|
3697
|
+
end
|
3415
3698
|
upload_res_count +=1
|
3416
3699
|
end
|
3417
3700
|
# download(sync = true, ignore_list = ignore)
|
@@ -3420,7 +3703,7 @@ module Cnvrg
|
|
3420
3703
|
end
|
3421
3704
|
end_commit = @project.last_local_commit
|
3422
3705
|
|
3423
|
-
log_thread.join
|
3706
|
+
# log_thread.join
|
3424
3707
|
stats_thread.join
|
3425
3708
|
|
3426
3709
|
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
@@ -3440,19 +3723,13 @@ module Cnvrg
|
|
3440
3723
|
end
|
3441
3724
|
log_message("Couldn't run #{cmd}, check your input parameters", Thor::Shell::Color::RED)
|
3442
3725
|
if @exp
|
3443
|
-
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3448
|
-
|
3449
|
-
|
3450
|
-
}
|
3451
|
-
log << cur_log
|
3452
|
-
process_running = false
|
3453
|
-
log_thread.join
|
3454
|
-
stats_thread.join
|
3455
|
-
res = @exp.end(log, "-1", end_commit, cpu_average, memory_average)
|
3726
|
+
# log_thread.join
|
3727
|
+
Thread.kill(stats_thread)
|
3728
|
+
exit_status = $?.exitstatus
|
3729
|
+
if exit_status.blank?
|
3730
|
+
exit_status = "-1"
|
3731
|
+
end
|
3732
|
+
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3456
3733
|
|
3457
3734
|
end
|
3458
3735
|
log_error(e)
|
@@ -3470,7 +3747,7 @@ module Cnvrg
|
|
3470
3747
|
exit_status = -1
|
3471
3748
|
end_commit = @project.last_local_commit
|
3472
3749
|
process_running = false
|
3473
|
-
log_thread.join
|
3750
|
+
# log_thread.join
|
3474
3751
|
stats_thread.join
|
3475
3752
|
|
3476
3753
|
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
@@ -3502,6 +3779,10 @@ module Cnvrg
|
|
3502
3779
|
method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
|
3503
3780
|
method_option :periodic_sync, :type => :string, :aliases => ["-ps", "--periodic_sync"], :default => nil
|
3504
3781
|
method_option :sync_before_terminate, :type => :boolean, :aliases => ["-sbt", "--sync_before_terminate"], :default => false
|
3782
|
+
method_option :output_dir, :type => :string, :aliases => ["-o", "--output_dir"], :default => nil
|
3783
|
+
method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => nil
|
3784
|
+
method_option :git_commit, :type => :string, :aliases => [ "--git_commit"], :default => nil
|
3785
|
+
method_option :git_branch, :type => :string, :aliases => [ "--git_branch"], :default => nil
|
3505
3786
|
|
3506
3787
|
def exec_remote(*cmd)
|
3507
3788
|
verify_logged_in(true)
|
@@ -3513,6 +3794,7 @@ module Cnvrg
|
|
3513
3794
|
grid = options["grid"] || nil
|
3514
3795
|
data = options["data"] || nil
|
3515
3796
|
data_commit = options["data_commit"] || nil
|
3797
|
+
data_query = options["data_query"] || nil
|
3516
3798
|
sync_before = options["sync_before"]
|
3517
3799
|
force = options["force"]
|
3518
3800
|
max_time = options["max_time"]
|
@@ -3530,7 +3812,6 @@ module Cnvrg
|
|
3530
3812
|
if dataset_only_tree
|
3531
3813
|
ds_sync_options = 1
|
3532
3814
|
end
|
3533
|
-
|
3534
3815
|
instance_type = options["machine_type"] || nil
|
3535
3816
|
schedule = options["schedule"] || ""
|
3536
3817
|
if schedule.start_with? 'in'
|
@@ -3562,9 +3843,14 @@ module Cnvrg
|
|
3562
3843
|
if !instance_type.nil? and instance_type.include? "gpu"
|
3563
3844
|
remote = "#{remote} --gpu=true"
|
3564
3845
|
end
|
3846
|
+
output_dir = options["output_dir"] || nil
|
3847
|
+
git_commit = options["git_commit"]
|
3848
|
+
git_branch = options["git_branch"]
|
3565
3849
|
|
3566
3850
|
options_hash = Hash[options]
|
3567
|
-
options_hash.except!("schedule", "machine_type", "image", "upload_output", "grid", "data", "data_commit",
|
3851
|
+
options_hash.except!("schedule", "machine_type", "image", "upload_output", "grid", "data", "data_commit",
|
3852
|
+
"local", "small", "medium", "large", "gpu", "gpuxl", "gpuxxl","max_time","dataset_only_tree",
|
3853
|
+
"data_query", "git_commit","git_branch" )
|
3568
3854
|
exec_options = options_hash.map {|x| "--#{x[0]}=#{x[1]}"}.flatten.join(" ")
|
3569
3855
|
command = "#{exec_options} #{remote} #{upload_output_option} #{cmd.flatten.join(" ")}"
|
3570
3856
|
commit_to_run = options["commit"] || nil
|
@@ -3574,7 +3860,9 @@ module Cnvrg
|
|
3574
3860
|
|
3575
3861
|
end
|
3576
3862
|
project = Project.new(working_dir)
|
3577
|
-
|
3863
|
+
if project.is_git and output_dir.blank?
|
3864
|
+
output_dir = "output"
|
3865
|
+
end
|
3578
3866
|
choose_image = options["image"]
|
3579
3867
|
|
3580
3868
|
if !choose_image.nil? and !choose_image.empty?
|
@@ -3592,7 +3880,7 @@ module Cnvrg
|
|
3592
3880
|
image_slug = image.image_slug
|
3593
3881
|
end
|
3594
3882
|
forced_commit = nil
|
3595
|
-
if sync_before
|
3883
|
+
if sync_before and !project.is_git
|
3596
3884
|
if force
|
3597
3885
|
sync_result = invoke :sync, [false], :force => force, :return_id=> true
|
3598
3886
|
begin
|
@@ -3606,6 +3894,7 @@ module Cnvrg
|
|
3606
3894
|
|
3607
3895
|
|
3608
3896
|
|
3897
|
+
|
3609
3898
|
end
|
3610
3899
|
|
3611
3900
|
|
@@ -3629,7 +3918,7 @@ module Cnvrg
|
|
3629
3918
|
commit_to_run = forced_commit
|
3630
3919
|
end
|
3631
3920
|
res = exp.exec_remote(command, commit_to_run, instance_type, image_slug, schedule, local_timestamp, grid, path_to_cmd, data, data_commit,
|
3632
|
-
periodic_sync, sync_before_terminate, max_time, ds_sync_options)
|
3921
|
+
periodic_sync, sync_before_terminate, max_time, ds_sync_options,output_dir,data_query, git_commit, git_branch)
|
3633
3922
|
if Cnvrg::CLI.is_response_success(res)
|
3634
3923
|
check = Helpers.checkmark()
|
3635
3924
|
str = "#{check} Experiment's is on: #{Cnvrg::Helpers.remote_url}/#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}"
|
@@ -3750,11 +4039,13 @@ module Cnvrg
|
|
3750
4039
|
method_option :data, :type => :string, :aliases => ["-d", "--data"], :default => ""
|
3751
4040
|
method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
|
3752
4041
|
method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
|
3753
|
-
|
4042
|
+
method_option :data_query, :type => :string, :aliases => ["-q", "--query"], :default => ""
|
3754
4043
|
|
3755
4044
|
desc 'notebook', 'starts a notebook session remotely or locally'
|
3756
4045
|
|
3757
4046
|
def notebook
|
4047
|
+
verify_logged_in(true)
|
4048
|
+
log_start(__method__, args, options)
|
3758
4049
|
local = options["local"]
|
3759
4050
|
notebook_dir = options["notebook_dir"]
|
3760
4051
|
kernel = options["kernel"]
|
@@ -3762,6 +4053,16 @@ module Cnvrg
|
|
3762
4053
|
data = options["data"]
|
3763
4054
|
data_commit = options["data_commit"]
|
3764
4055
|
dataset_only_tree = options["dataset_only_tree"]
|
4056
|
+
data_query = options["data_query"]
|
4057
|
+
if !data.present? and data_query.present?
|
4058
|
+
log_message("Please provide data with data_query", Thor::Shell::Color::RED)
|
4059
|
+
exit(1)
|
4060
|
+
end
|
4061
|
+
if data_query.present? and (data_commit.present? or dataset_only_tree.present?)
|
4062
|
+
log_message("Please use only one option: --query(-q) or #{data_commit.present? ? '--data_commit' : '--dataset_only_tree'} ", Thor::Shell::Color::RED)
|
4063
|
+
exit(1)
|
4064
|
+
end
|
4065
|
+
|
3765
4066
|
if local
|
3766
4067
|
invoke :run_notebook, [], :notebook_dir => notebook_dir, :remote => false, :kernel => kernel, :image => image
|
3767
4068
|
return
|
@@ -3771,7 +4072,7 @@ module Cnvrg
|
|
3771
4072
|
instance_type = get_instance_type(instances)
|
3772
4073
|
|
3773
4074
|
invoke :remote_notebook, [], :notebook_dir => notebook_dir, :kernel => kernel, :machine_type => instance_type, :image => image,
|
3774
|
-
:data => data, :data_commit => data_commit , :dataset_only_tree => dataset_only_tree
|
4075
|
+
:data => data, :data_commit => data_commit , :dataset_only_tree => dataset_only_tree, :data_query => data_query
|
3775
4076
|
return
|
3776
4077
|
|
3777
4078
|
end
|
@@ -3891,7 +4192,7 @@ module Cnvrg
|
|
3891
4192
|
method_option :data_commit, :type => :string, :aliases => ["--data_commit"], :default => ""
|
3892
4193
|
method_option :commit, :type => :string, :aliases => ["--commit"], :default => ""
|
3893
4194
|
method_option :dataset_only_tree, :type => :boolean, :aliases => [ "--dataset_only_tree"], :default => false
|
3894
|
-
|
4195
|
+
method_option :data_query, :type => :string, :aliases => ["-q","--data_query"], :default => ""
|
3895
4196
|
|
3896
4197
|
def remote_notebook()
|
3897
4198
|
verify_logged_in(true)
|
@@ -3909,6 +4210,16 @@ module Cnvrg
|
|
3909
4210
|
ds_sync_options = 1
|
3910
4211
|
end
|
3911
4212
|
|
4213
|
+
data_query = nil
|
4214
|
+
if data.present?
|
4215
|
+
data_query = options["data_query"]
|
4216
|
+
end
|
4217
|
+
|
4218
|
+
if data_commit.present? and data_query.present?
|
4219
|
+
log_message("Please use only one option: --query(-q) or --data_commit ", Thor::Shell::Color::RED)
|
4220
|
+
exit(1)
|
4221
|
+
end
|
4222
|
+
|
3912
4223
|
begin
|
3913
4224
|
project = Project.new(working_dir)
|
3914
4225
|
exp = Experiment.new(project.owner, project.slug)
|
@@ -3918,7 +4229,7 @@ module Cnvrg
|
|
3918
4229
|
end
|
3919
4230
|
invoke :sync, [false], []
|
3920
4231
|
slug = ""
|
3921
|
-
res = exp.remote_notebook(instance_type, commit, data, data_commit, notebook_type,ds_sync_options)
|
4232
|
+
res = exp.remote_notebook(instance_type, commit, data, data_commit, notebook_type,ds_sync_options,data_query)
|
3922
4233
|
if Cnvrg::CLI.is_response_success(res)
|
3923
4234
|
slug = res["result"]["notebook_url"]
|
3924
4235
|
log_message("#{Helpers.checkmark} Notebook is ready: #{Cnvrg::Helpers.remote_url}/#{project.owner}/projects/#{project.slug}/notebook_sessions/show/#{slug}", Thor::Shell::Color::GREEN)
|
@@ -5593,7 +5904,7 @@ module Cnvrg
|
|
5593
5904
|
begin
|
5594
5905
|
$LOG.error message: e.message, type: "error"
|
5595
5906
|
size = e.backtrace.size
|
5596
|
-
min =
|
5907
|
+
min = 10
|
5597
5908
|
if min >= size
|
5598
5909
|
min = size
|
5599
5910
|
end
|
@@ -5702,7 +6013,7 @@ module Cnvrg
|
|
5702
6013
|
end
|
5703
6014
|
|
5704
6015
|
def should_update_version
|
5705
|
-
res = Cnvrg::API.request("
|
6016
|
+
res = Cnvrg::API.request("cli/version", 'GET')
|
5706
6017
|
if Cnvrg::CLI.is_response_success(res, false)
|
5707
6018
|
updated_version = res["result"]["version"]
|
5708
6019
|
if updated_version != Cnvrg::VERSION
|
@@ -5796,17 +6107,19 @@ module Cnvrg
|
|
5796
6107
|
# end
|
5797
6108
|
# end
|
5798
6109
|
|
5799
|
-
config = YAML.load_file(File.expand_path('~') + "/.cnvrg/config.yml")
|
5800
|
-
version_date = config.to_h[:version_last_check]
|
5801
|
-
if version_date.nil?
|
5802
|
-
|
5803
|
-
end
|
5804
|
-
next_day = get_start_day + 86399
|
5805
|
-
|
5806
|
-
|
5807
|
-
|
5808
|
-
|
5809
|
-
|
6110
|
+
# config = YAML.load_file(File.expand_path('~') + "/.cnvrg/config.yml")
|
6111
|
+
# version_date = config.to_h[:version_last_check]
|
6112
|
+
# if version_date.nil?
|
6113
|
+
# version_date = get_start_day()
|
6114
|
+
# end
|
6115
|
+
# next_day = get_start_day + 86399
|
6116
|
+
# version_date = version_date.to_i
|
6117
|
+
# next_day = next_day.to_i
|
6118
|
+
# if not (version_date..next_day).cover?(Time.now)
|
6119
|
+
# if should_update_version()
|
6120
|
+
# say "There is a new version, run gem update cnvrg", Thor::Shell::Color::BLUE
|
6121
|
+
# end
|
6122
|
+
# end
|
5810
6123
|
if in_dir
|
5811
6124
|
is_cnvrg = is_cnvrg_dir
|
5812
6125
|
if !is_cnvrg
|