cnvrg 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cnvrg/cli.rb +278 -399
- data/lib/cnvrg/data.rb +9 -9
- data/lib/cnvrg/datafiles.rb +151 -6
- data/lib/cnvrg/dataset.rb +36 -7
- data/lib/cnvrg/files.rb +10 -55
- data/lib/cnvrg/helpers.rb +56 -0
- data/lib/cnvrg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e3a5bae5049d633360023ea911ceeb97ed85696
|
4
|
+
data.tar.gz: 1f3b1959efd5784162d3d715b2b671188907297f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85643c72891b74c4282ce4991f8c7e572c1f21af287cb8883707ce1fbd34368a935e2508ac83610148f1caff3e86d1febd351dd0e129625da1a66e5ecf183414
|
7
|
+
data.tar.gz: ac285e4ddc22e20f4c7a811b59e82757e82f8686eaaae5d029a0aa2997bcb987283b1655a46dc7e87d1a44682cee4b504dcba99337064834ade2d80a60c8de04
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -815,96 +815,49 @@ module Cnvrg
|
|
815
815
|
Cnvrg::CLI.is_response_success(response,true)
|
816
816
|
dataset_name = response["result"]["name"]
|
817
817
|
dataset_home = Dir.pwd+"/"+dataset_name
|
818
|
-
|
819
|
-
|
820
818
|
if (Dir.exists? dataset_name)
|
821
819
|
log_message("Error: Conflict with dir #{dataset_name}", Thor::Shell::Color::RED)
|
822
820
|
if no? "Sync to repository anyway? (current data might lost)", Thor::Shell::Color::YELLOW
|
823
821
|
log_message("Remove dir in order to clone #{dataset_name}", Thor::Shell::Color::RED)
|
824
822
|
exit(1)
|
825
823
|
end
|
826
|
-
|
827
824
|
end
|
828
825
|
check = Helpers.checkmark
|
829
|
-
|
830
826
|
if Dataset.clone(owner, dataset_name, slug)
|
831
827
|
log_message("Cloning #{dataset_name}", Thor::Shell::Color::BLUE)
|
832
828
|
@files = Cnvrg::Datafiles.new(owner, slug)
|
833
|
-
|
834
|
-
successful_changes = []
|
835
829
|
log_message("Downloading files", Thor::Shell::Color::BLUE)
|
836
|
-
if not(query.nil? or query.empty?)
|
837
|
-
|
830
|
+
# if not(query.nil? or query.empty?)
|
831
|
+
# @files.download_list_files_in_query(response["result"]["list_files"],dataset_home)
|
838
832
|
|
839
|
-
|
840
|
-
|
833
|
+
# log_message("#{check} Clone finished successfully", Thor::Shell::Color::GREEN)
|
834
|
+
# return
|
841
835
|
|
842
|
-
end
|
836
|
+
# end
|
843
837
|
commit = response["result"]["commit"]
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
is_success = true
|
860
|
-
|
861
|
-
Parallel.map((response["result"]["tree"]), parallel_options) do |f|
|
862
|
-
|
863
|
-
relative_path = f[0].gsub(/^#{dataset_home}/, "")
|
864
|
-
if f[0].end_with? "/"
|
865
|
-
# dir
|
866
|
-
if @files.download_dir(dataset_home, relative_path)
|
867
|
-
successful_changes << relative_path
|
868
|
-
else
|
869
|
-
is_success =false
|
870
|
-
log_message("Could not create directory: #{f[0]}", Thor::Shell::Color::RED)
|
871
|
-
raise Parallel::Kill
|
872
|
-
end
|
873
|
-
else
|
874
|
-
# blob
|
875
|
-
if !only_tree
|
876
|
-
|
877
|
-
if @files.download_file_s3(f[0], relative_path, dataset_home, false, commit_sha1=commit)
|
878
|
-
successful_changes << relative_path
|
879
|
-
else
|
880
|
-
is_success =false
|
881
|
-
log_message("Could not download file: #{f[0]}", Thor::Shell::Color::RED)
|
882
|
-
raise Parallel::Kill
|
883
|
-
end
|
884
|
-
end
|
885
|
-
end
|
886
|
-
end
|
887
|
-
rescue Interrupt
|
888
|
-
is_success =false
|
889
|
-
log_message("Couldn't download", Thor::Shell::Color::RED)
|
890
|
-
|
891
|
-
exit(1)
|
892
|
-
end
|
893
|
-
|
894
|
-
|
895
|
-
end
|
896
|
-
successful_changes = response["result"]["tree"]
|
897
|
-
if !successful_changes.nil? and is_success
|
838
|
+
files_count = response["result"]["file_count"]
|
839
|
+
files = @files.get_clone_chunk(commit: commit)
|
840
|
+
downloaded_files = 0
|
841
|
+
progressbar = ProgressBar.create(:title => "Download Progress",
|
842
|
+
:progress_mark => '=',
|
843
|
+
:format => "%b>>%i| %p%% %t",
|
844
|
+
:starting_at => 0,
|
845
|
+
:autofinish => true)
|
846
|
+
while files['keys'].length > 0
|
847
|
+
@files.download_multiple_files_s3(files, dataset_home)
|
848
|
+
downloaded_files += files['keys'].length
|
849
|
+
progressbar.progress = (downloaded_files * 100 / files_count)
|
850
|
+
files = @files.get_clone_chunk(commit: commit, latest_id: files['latest'])
|
851
|
+
end
|
852
|
+
if downloaded_files == files_count
|
898
853
|
Dataset.verify_cnvrgignore_exist(dataset_name, false)
|
899
|
-
|
854
|
+
@dataset = Dataset.new(dataset_home)
|
855
|
+
@dataset.write_idx(nil, commit)
|
900
856
|
log_message("#{check} Clone finished successfully", Thor::Shell::Color::GREEN)
|
901
857
|
else
|
902
|
-
log_message(
|
903
|
-
|
858
|
+
log_message(result.msg, result.msg_color)
|
904
859
|
end
|
905
|
-
|
906
860
|
else
|
907
|
-
|
908
861
|
log_message("Error: Couldn't create directory: #{dataset_name}", Thor::Shell::Color::RED)
|
909
862
|
exit(1)
|
910
863
|
end
|
@@ -1965,15 +1918,16 @@ module Cnvrg
|
|
1965
1918
|
method_option :commit, :type => :string, :aliases => ["-c"], :desc => "download specified commit", :default => nil
|
1966
1919
|
method_option :all_files, :type => :boolean, :aliases => ["--all"], :desc => "download specified commit", :default => true
|
1967
1920
|
method_option :parallel, :type => :numeric, :aliases => ["-p", "--parallel"], :desc => "uparallel upload at the same time", :default => 15
|
1921
|
+
method_option :init, :type => :boolean, :aliases => ["--initial"], :desc => "initial sync", :default => false
|
1968
1922
|
|
1969
|
-
def sync_data_new(new_branch, force, verbose, commit, all_files, tags,parallel)
|
1923
|
+
def sync_data_new(new_branch, force, verbose, commit, all_files, tags ,parallel, chunk_size, init)
|
1970
1924
|
verify_logged_in(true)
|
1971
1925
|
log_start(__method__, args, options)
|
1972
1926
|
log_message('Syncing dataset', Thor::Shell::Color::BLUE, !options["verbose"])
|
1973
|
-
if !
|
1927
|
+
if !force and !init
|
1974
1928
|
invoke :download_data_new,[verbose,true, commit, all_files], :new_branch=>new_branch, :direct=>false, :force =>force
|
1975
1929
|
end
|
1976
|
-
invoke :upload_data_new,[new_branch, verbose,true,force, tags], :new_branch=>new_branch,
|
1930
|
+
invoke :upload_data_new,[new_branch, verbose,true,force, tags, chunk_size], :new_branch=>new_branch,
|
1977
1931
|
:direct=>false, :force =>force, :sync =>true, :tags =>tags, :parallel => parallel
|
1978
1932
|
|
1979
1933
|
end
|
@@ -1984,14 +1938,11 @@ module Cnvrg
|
|
1984
1938
|
method_option :sync, :type => :boolean, :aliases => ["-s","--sync"], :default => false
|
1985
1939
|
method_option :tags, :type => :boolean, :aliases => ["--tags"], :desc => "upload file tags", :default => false
|
1986
1940
|
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)
|
1941
|
+
def upload_data_new(new_branch, verbose,sync,force, tags, chunk_size)
|
1989
1942
|
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
|
-
|
1992
|
-
|
1993
|
-
invoke :end_commit_data,[commit] , :new_branch=>new_branch, :force =>force
|
1994
|
-
end
|
1943
|
+
upload_res = invoke :upload_data_files,[commit],:new_branch=>new_branch, :verbose =>verbose, :force =>force, :sync =>sync, :chunk_size => chunk_size
|
1944
|
+
invoke :end_commit_data,[commit] , :new_branch=>new_branch, :force =>force, :success => upload_res
|
1945
|
+
|
1995
1946
|
if tags
|
1996
1947
|
log_message('Uploading Tags', Thor::Shell::Color::BLUE)
|
1997
1948
|
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
@@ -2032,25 +1983,19 @@ module Cnvrg
|
|
2032
1983
|
commit_sha1 = nil
|
2033
1984
|
@dataset = Dataset.new(dataset_dir)
|
2034
1985
|
@files = Cnvrg::Datafiles.new(@dataset.owner, @dataset.slug)
|
2035
|
-
next_commit = @dataset.get_next_commit()
|
2036
|
-
if
|
1986
|
+
next_commit = @dataset.get_next_commit() #if there was a partial commit..
|
1987
|
+
if next_commit.present? #keep from existing commit.
|
2037
1988
|
resp = @files.get_commit(next_commit)
|
2038
1989
|
if resp["result"]["status"].eql? "new"
|
2039
1990
|
resp = @files.start_commit(new_branch,force)
|
2040
1991
|
commit_sha1 = resp["result"]["commit_sha1"]
|
2041
|
-
|
2042
1992
|
@dataset.set_next_commit(commit_sha1)
|
2043
|
-
|
2044
1993
|
else
|
2045
|
-
|
2046
|
-
commit_sha1 = resp["result"]["commit_sha1"]
|
2047
|
-
|
1994
|
+
commit_sha1 = resp["result"]["commit_sha1"]
|
2048
1995
|
end
|
2049
1996
|
else
|
2050
|
-
|
2051
1997
|
resp = @files.start_commit(new_branch,force)
|
2052
1998
|
commit_sha1 = resp["result"]["commit_sha1"]
|
2053
|
-
|
2054
1999
|
@dataset.set_next_commit(commit_sha1)
|
2055
2000
|
end
|
2056
2001
|
if direct
|
@@ -2059,16 +2004,14 @@ module Cnvrg
|
|
2059
2004
|
return commit_sha1
|
2060
2005
|
rescue => e
|
2061
2006
|
puts e
|
2062
|
-
if
|
2007
|
+
if commit_sha1.present?
|
2063
2008
|
@dataset.set_next_commit(commit_sha1)
|
2064
2009
|
end
|
2065
2010
|
rescue SignalException
|
2066
2011
|
log_message("Aborting..", Thor::Shell::Color::YELLOW)
|
2067
|
-
if
|
2068
|
-
|
2012
|
+
if commit_sha1.present?
|
2069
2013
|
@dataset.set_next_commit(commit_sha1)
|
2070
2014
|
end
|
2071
|
-
|
2072
2015
|
exit(1)
|
2073
2016
|
end
|
2074
2017
|
|
@@ -2076,6 +2019,7 @@ module Cnvrg
|
|
2076
2019
|
desc 'end_commit', 'start data commit'
|
2077
2020
|
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
2078
2021
|
method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
|
2022
|
+
method_option :success, :type => :boolean, :default => true, :hide=>true
|
2079
2023
|
|
2080
2024
|
def end_commit_data(commit)
|
2081
2025
|
begin
|
@@ -2085,12 +2029,18 @@ module Cnvrg
|
|
2085
2029
|
@dataset = Dataset.new(dataset_dir)
|
2086
2030
|
@files = Cnvrg::Datafiles.new(@dataset.owner, @dataset.slug)
|
2087
2031
|
force = options["force"] || false
|
2088
|
-
|
2089
|
-
resp = @files.end_commit(commit, force)
|
2032
|
+
resp = @files.end_commit(commit, force, options[:success])
|
2090
2033
|
if (resp and resp["result"])
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2034
|
+
if !options[:success]
|
2035
|
+
@dataset.set_next_commit(resp["result"]["commit_sha1"])
|
2036
|
+
@dataset.remove_next_commit
|
2037
|
+
else
|
2038
|
+
check = Helpers.checkmark
|
2039
|
+
@dataset.set_next_commit(commit)
|
2040
|
+
@dataset.remove_next_commit
|
2041
|
+
log_message("#{check} Data files were updated successfully", Thor::Shell::Color::GREEN)
|
2042
|
+
end
|
2043
|
+
|
2094
2044
|
end
|
2095
2045
|
|
2096
2046
|
|
@@ -2144,6 +2094,7 @@ module Cnvrg
|
|
2144
2094
|
method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
|
2145
2095
|
method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
|
2146
2096
|
method_option :tags, :type => :string, :aliases => ["--tags"], :desc => "upload file tags", :default => ""
|
2097
|
+
method_option :chunk_size, :type => :numeric, :aliases => ["--chunk"], :desc => "upload file tags", :default => 1000
|
2147
2098
|
# method_option :tags_yml, :type => :boolean, :aliases => ["--file_tag_yml"], :default => false
|
2148
2099
|
method_option :parallel, :type => :numeric, :aliases => ["-p", "--parallel"], :desc => "uparallel upload at the same time", :default => 15
|
2149
2100
|
|
@@ -2153,219 +2104,242 @@ module Cnvrg
|
|
2153
2104
|
verify_logged_in(true)
|
2154
2105
|
log_start(__method__, args, options)
|
2155
2106
|
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
2156
|
-
|
2157
2107
|
@dataset = Dataset.new(dataset_dir)
|
2158
2108
|
@files = Cnvrg::Datafiles.new(@dataset.owner, @dataset.slug)
|
2159
2109
|
next_commit = @dataset.get_next_commit()
|
2160
|
-
|
2161
|
-
|
2162
|
-
if (new_commit.nil? or new_commit.empty?) and next_commit.nil?
|
2110
|
+
if new_commit.blank? and next_commit.blank?
|
2163
2111
|
log_message("You must specify commit, run start_commit to create new commit", Thor::Shell::Color::RED)
|
2164
2112
|
exit(1)
|
2165
2113
|
end
|
2166
2114
|
|
2167
2115
|
force = options[:force] || false
|
2168
|
-
|
2116
|
+
chunk_size = options[:chunk_size]
|
2117
|
+
chunk_size = [chunk_size, 1].max
|
2169
2118
|
new_branch = options["new_branch"] || false
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2119
|
+
force = options["force"] || false
|
2120
|
+
parallel_threads = options["parallel"] || ParallelThreads
|
2121
|
+
new_tree = {}
|
2122
|
+
progressbar = ProgressBar.create(:title => "Upload Progress",
|
2123
|
+
:progress_mark => '=',
|
2124
|
+
:format => "%b>>%i| %p%% %t",
|
2125
|
+
:starting_at => 0,
|
2126
|
+
:autofinish => true)
|
2127
|
+
all_files = @dataset.list_all_files
|
2128
|
+
files_count = all_files.count
|
2129
|
+
finished_chunks = 0
|
2130
|
+
files_uploaded = 0
|
2131
|
+
all_files.each_slice(chunk_size).each do |list_files|
|
2132
|
+
temp_tree = @dataset.generate_chunked_idx(list_files, threads: parallel_threads)
|
2133
|
+
files_uploaded += @files.upload_multiple_files(next_commit, temp_tree, threads: parallel_threads, force: force)
|
2134
|
+
new_tree = new_tree.merge(temp_tree.map{|k,v| [k.gsub('./', ''), {sha1: v[:sha1], commit_time: nil}]}.to_h)
|
2135
|
+
@dataset.write_idx(new_tree, next_commit)
|
2136
|
+
finished_chunks += 1
|
2137
|
+
progressbar.progress = [(finished_chunks * chunk_size*100) / files_count, 100].min
|
2138
|
+
end
|
2139
|
+
return files_uploaded > 0
|
2140
|
+
rescue Exception => e
|
2141
|
+
return false
|
2142
|
+
end
|
2182
2143
|
|
2144
|
+
# local_idx = @dataset.generate_idx
|
2145
|
+
# result = @dataset.compare_idx(new_branch, commit=@dataset.last_local_commit, local_idx= local_idx, force=force, next_commit= next_commit)
|
2183
2146
|
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2147
|
+
# commit_sha1 = result["result"]["commit"]
|
2148
|
+
# if commit_sha1 != @dataset.last_local_commit and !@dataset.last_local_commit.nil? and !result["result"]["tree"]["updated_on_server"].empty?
|
2149
|
+
# @dataset.remove_next_commit()
|
2150
|
+
# @files.delete_commit(next_commit)
|
2151
|
+
# log_message("Remote server has an updated version, please run `cnvrg data download` first or cnvrg data upload --new_branch", Thor::Shell::Color::BLUE)
|
2152
|
+
# exit(1)
|
2153
|
+
# end
|
2154
|
+
# check = Helpers.checkmark()
|
2190
2155
|
|
2191
|
-
dirs_uploaded = already_uploaded["dirs"]
|
2192
|
-
files_uploaded = already_uploaded["blobs"]
|
2193
|
-
if !files_uploaded.nil? and !files_uploaded.empty?
|
2194
|
-
files_uploaded_names = already_uploaded["blobs"].keys
|
2195
|
-
end
|
2196
2156
|
|
2197
|
-
|
2157
|
+
# commit_time = result["result"]["commit_time"]
|
2158
|
+
# already_uploaded = result["result"]["uploaded"]
|
2159
|
+
# dirs_uploaded = []
|
2160
|
+
# files_uploaded = []
|
2161
|
+
# files_uploaded_names = []
|
2162
|
+
# if !already_uploaded.nil? and !already_uploaded.empty?
|
2198
2163
|
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2164
|
+
# dirs_uploaded = already_uploaded["dirs"]
|
2165
|
+
# files_uploaded = already_uploaded["blobs"]
|
2166
|
+
# if !files_uploaded.nil? and !files_uploaded.empty?
|
2167
|
+
# files_uploaded_names = already_uploaded["blobs"].keys
|
2168
|
+
# end
|
2202
2169
|
|
2203
|
-
|
2204
|
-
return false
|
2205
|
-
end
|
2206
|
-
log_message("Creating new commit for dataset: #{@dataset.slug}", Thor::Shell::Color::BLUE) unless options[:sync]
|
2170
|
+
# end
|
2207
2171
|
|
2172
|
+
# result = result["result"]["tree"]
|
2173
|
+
# if result["added"].empty? and result["updated_on_local"].empty? and result["deleted"].empty?
|
2174
|
+
# @files.delete_commit(next_commit)
|
2208
2175
|
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
:title => "Upload Progress",
|
2214
|
-
:progress_mark => '=',
|
2215
|
-
:format => "%b>>%i| %p%% %t",
|
2216
|
-
:starting_at => 0,
|
2217
|
-
:total => (result["added"] + result["updated_on_local"]).size,
|
2218
|
-
:autofinish => true
|
2219
|
-
},
|
2220
|
-
in_threads: parallel_threads.to_i,
|
2221
|
-
isolation: true
|
2222
|
-
}
|
2223
|
-
successful_updates = []
|
2224
|
-
update_count =0
|
2225
|
-
update_total = (result["added"] + result["updated_on_local"] + result["deleted"]).size
|
2176
|
+
# log_message("#{check} Dataset is up to date", Thor::Shell::Color::GREEN, true)
|
2177
|
+
# return false
|
2178
|
+
# end
|
2179
|
+
# log_message("Creating new commit for dataset: #{@dataset.slug}", Thor::Shell::Color::BLUE) unless options[:sync]
|
2226
2180
|
|
2227
|
-
if (result["added"] + result["updated_on_local"]).size > 0
|
2228
|
-
begin
|
2229
|
-
upload_result = Parallel.map((result["added"] + result["updated_on_local"]), parallel_options) do |f|
|
2230
|
-
absolute_path = "#{@dataset.local_path}/#{f}"
|
2231
|
-
relative_path = f.gsub(/^#{@dataset.local_path + "/"}/, "")
|
2232
|
-
if File.directory?(absolute_path)
|
2233
|
-
if dirs_uploaded.include? f
|
2234
|
-
#Already uploaded and didn't finish commit
|
2235
|
-
log_message("Already uploaded dir: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2236
2181
|
|
2237
|
-
|
2238
|
-
|
2239
|
-
log_message("uploading dir: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2182
|
+
# # upload / update
|
2183
|
+
# begin
|
2240
2184
|
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2185
|
+
# parallel_options = {
|
2186
|
+
# :progress => {
|
2187
|
+
# :title => "Upload Progress",
|
2188
|
+
# :progress_mark => '=',
|
2189
|
+
# :format => "%b>>%i| %p%% %t",
|
2190
|
+
# :starting_at => 0,
|
2191
|
+
# :total => (result["added"] + result["updated_on_local"]).size,
|
2192
|
+
# :autofinish => true
|
2193
|
+
# },
|
2194
|
+
# in_threads: ParallelThreads,
|
2195
|
+
# isolation: true
|
2196
|
+
# }
|
2197
|
+
# successful_updates = []
|
2198
|
+
# update_count =0
|
2199
|
+
# update_total = (result["added"] + result["updated_on_local"] + result["deleted"]).size
|
2247
2200
|
|
2248
|
-
|
2249
|
-
|
2201
|
+
# if (result["added"] + result["updated_on_local"]).size > 0
|
2202
|
+
# begin
|
2203
|
+
# upload_result = Parallel.map((result["added"] + result["updated_on_local"]), parallel_options) do |f|
|
2204
|
+
# absolute_path = "#{@dataset.local_path}/#{f}"
|
2205
|
+
# relative_path = f.gsub(/^#{@dataset.local_path + "/"}/, "")
|
2206
|
+
# if File.directory?(absolute_path)
|
2207
|
+
# if dirs_uploaded.include? f
|
2208
|
+
# #Already uploaded and didn't finish commit
|
2209
|
+
# log_message("Already uploaded dir: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2250
2210
|
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2211
|
+
# next
|
2212
|
+
# end
|
2213
|
+
# log_message("uploading dir: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2254
2214
|
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2215
|
+
# resDir = @files.create_dir(absolute_path, relative_path, commit_sha1)
|
2216
|
+
# if resDir
|
2217
|
+
# update_count += 1
|
2218
|
+
# successful_updates<< relative_path
|
2219
|
+
# else
|
2220
|
+
# log_message("Failed to upload directory: #{ relative_path }", Thor::Shell::Color::RED)
|
2258
2221
|
|
2259
|
-
|
2260
|
-
|
2261
|
-
update_count += 1
|
2222
|
+
# raise Parallel::Kill
|
2223
|
+
# end
|
2262
2224
|
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2225
|
+
# else
|
2226
|
+
# if files_uploaded_names.include? f
|
2227
|
+
# log_message("Already uploaded file: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2266
2228
|
|
2267
|
-
|
2229
|
+
# next
|
2230
|
+
# end
|
2231
|
+
# log_message("uploading: #{f}", Thor::Shell::Color::BLUE, options["verbose"])
|
2268
2232
|
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
rescue SignalException
|
2273
|
-
log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2233
|
+
# res = @files.upload_file(absolute_path, relative_path, commit_sha1)
|
2234
|
+
# if res
|
2235
|
+
# update_count += 1
|
2274
2236
|
|
2237
|
+
# successful_updates<< relative_path
|
2238
|
+
# else
|
2239
|
+
# log_message("Failed to upload: #{ File.basename(absolute_path) }", Thor::Shell::Color::RED)
|
2275
2240
|
|
2276
|
-
|
2277
|
-
end
|
2278
|
-
end
|
2241
|
+
# raise Parallel::Kill
|
2279
2242
|
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2243
|
+
# end
|
2244
|
+
# end
|
2245
|
+
# end
|
2246
|
+
# rescue SignalException
|
2247
|
+
# log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2283
2248
|
|
2284
2249
|
|
2285
|
-
|
2250
|
+
# exit(1)
|
2251
|
+
# end
|
2252
|
+
# end
|
2286
2253
|
|
2287
|
-
|
2288
|
-
|
2254
|
+
# end
|
2255
|
+
# successful_updates = upload_result.to_a + dirs_uploaded + files_uploaded_names
|
2256
|
+
# successful_deletions =[]
|
2289
2257
|
|
2290
|
-
deleted_result = Parallel.map(deleted, in_threads: ParallelThreads) do |f|
|
2291
2258
|
|
2292
|
-
|
2293
|
-
if relative_path.end_with?("/")
|
2294
|
-
log_message("deleting dir: #{f}", Thor::Shell::Color::RED, options["verbose"])
|
2259
|
+
# # delete
|
2295
2260
|
|
2296
|
-
|
2297
|
-
|
2298
|
-
else
|
2299
|
-
log_message("Failed to delete directory: #{ f }", Thor::Shell::Color::RED)
|
2300
|
-
raise Parallel::Kill
|
2261
|
+
# deleted = update_deleted(result["deleted"])
|
2262
|
+
# begin
|
2301
2263
|
|
2302
|
-
|
2303
|
-
else
|
2304
|
-
log_message("deleteing file: #{f}", Thor::Shell::Color::RED, options["verbose"])
|
2264
|
+
# deleted_result = Parallel.map(deleted, in_threads: ParallelThreads) do |f|
|
2305
2265
|
|
2306
|
-
|
2307
|
-
|
2266
|
+
# relative_path = f.gsub(/^#{@dataset.local_path + "/"}/, "")
|
2267
|
+
# if relative_path.end_with?("/")
|
2268
|
+
# log_message("deleting dir: #{f}", Thor::Shell::Color::RED, options["verbose"])
|
2308
2269
|
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2270
|
+
# if @files.delete_dir(f, relative_path, commit_sha1)
|
2271
|
+
# successful_deletions << f
|
2272
|
+
# else
|
2273
|
+
# log_message("Failed to delete directory: #{ f }", Thor::Shell::Color::RED)
|
2274
|
+
# raise Parallel::Kill
|
2312
2275
|
|
2276
|
+
# end
|
2277
|
+
# else
|
2278
|
+
# log_message("deleteing file: #{f}", Thor::Shell::Color::RED, options["verbose"])
|
2313
2279
|
|
2314
|
-
|
2315
|
-
|
2316
|
-
end
|
2280
|
+
# if @files.delete_file(f, relative_path, commit_sha1)
|
2281
|
+
# successful_deletions << f
|
2317
2282
|
|
2283
|
+
# else
|
2284
|
+
# log_message("Failed to delete file: #{ f }", Thor::Shell::Color::RED)
|
2285
|
+
# raise Parallel::Kill
|
2318
2286
|
|
2319
|
-
successful_deletions += successful_deletions.select { |x| not x.nil? }
|
2320
2287
|
|
2288
|
+
# end
|
2289
|
+
# end
|
2290
|
+
# end
|
2321
2291
|
|
2322
|
-
successful_updates = successful_updates.select { |x| not x.nil? }
|
2323
2292
|
|
2324
|
-
|
2293
|
+
# successful_deletions += successful_deletions.select { |x| not x.nil? }
|
2325
2294
|
|
2326
|
-
rescue SignalException
|
2327
|
-
say "User aborted", Thor::Shell::Color::RED
|
2328
|
-
exit(0)
|
2329
|
-
rescue => e
|
2330
|
-
log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2331
|
-
log_error(e)
|
2332
|
-
exit(0)
|
2333
|
-
end
|
2334
|
-
if !result["deleted"].nil? and !result["deleted"].empty?
|
2335
|
-
update_count += result["deleted"].size
|
2336
|
-
end
|
2337
2295
|
|
2338
|
-
|
2339
|
-
begin
|
2340
|
-
@dataset.update_idx_with_files_commits!((successful_deletions+successful_updates), commit_time)
|
2296
|
+
# successful_updates = successful_updates.select { |x| not x.nil? }
|
2341
2297
|
|
2342
|
-
|
2343
|
-
rescue => e
|
2344
|
-
log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2298
|
+
# update_count = successful_updates.size
|
2345
2299
|
|
2346
|
-
|
2300
|
+
# rescue SignalException
|
2301
|
+
# say "User aborted", Thor::Shell::Color::RED
|
2302
|
+
# exit(0)
|
2303
|
+
# rescue => e
|
2304
|
+
# log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2305
|
+
# log_error(e)
|
2306
|
+
# exit(0)
|
2307
|
+
# end
|
2308
|
+
# if !result["deleted"].nil? and !result["deleted"].empty?
|
2309
|
+
# update_count += result["deleted"].size
|
2310
|
+
# end
|
2347
2311
|
|
2348
|
-
|
2312
|
+
# if update_count == update_total
|
2313
|
+
# begin
|
2314
|
+
# @dataset.update_idx_with_files_commits!((successful_deletions+successful_updates), commit_time)
|
2349
2315
|
|
2350
|
-
|
2351
|
-
rescue => e
|
2316
|
+
# return true
|
2317
|
+
# rescue => e
|
2318
|
+
# log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2352
2319
|
|
2353
|
-
|
2354
|
-
log_error(e)
|
2320
|
+
# exit(1)
|
2355
2321
|
|
2356
|
-
|
2357
|
-
rescue SignalException
|
2322
|
+
# end
|
2358
2323
|
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2324
|
+
# end
|
2325
|
+
# rescue => e
|
2326
|
+
|
2327
|
+
# log_message("Exception while trying to upload, look at the log for more details", Thor::Shell::Color::RED)
|
2328
|
+
# log_error(e)
|
2329
|
+
|
2330
|
+
# exit(1)
|
2331
|
+
# rescue SignalException
|
2332
|
+
|
2333
|
+
# say "\nAborting", Thor::Shell::Color::BLUE
|
2334
|
+
# exit(1)
|
2335
|
+
# end
|
2362
2336
|
|
2363
2337
|
end
|
2364
2338
|
|
2365
2339
|
|
2366
2340
|
desc 'upload', 'Upload updated files'
|
2367
2341
|
method_option :ignore, :type => :string, :aliases => ["-i"], :desc => "ignore following files", :default => ""
|
2368
|
-
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
2342
|
+
method_option :new_branch, :type => :boolean, :aliases => ["-nb", "--new_branch"], :desc => "create new branch of commits"
|
2369
2343
|
method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
|
2370
2344
|
method_option :sync, :type => :boolean, :aliases => ["-s"], :default => false
|
2371
2345
|
method_option :force, :type => :boolean, :aliases => ["-f", "--force"], :default => false
|
@@ -2374,12 +2348,14 @@ module Cnvrg
|
|
2374
2348
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
2375
2349
|
method_option :files, :type => :string, :aliases => ["--files"], :default => nil
|
2376
2350
|
method_option :output_dir, :type => :string, :aliases => ["--output_dir"], :default => nil
|
2351
|
+
method_option :job_slug, :type => :string, :aliases => ["--job"], :default => nil, :hide=>true
|
2352
|
+
method_option :job_type, :type => :string, :aliases => [ "--job_type"], :default => nil, :hide=>true
|
2377
2353
|
|
2378
|
-
def upload(link = false, sync = false, direct = false, ignore_list = "", in_exp = false, force = false)
|
2354
|
+
def upload(link = false, sync = false, direct = false, ignore_list = "", in_exp = false, force = false,output_dir="output",job_type=nil,job_slug=nil )
|
2379
2355
|
begin
|
2356
|
+
# we are passing "force" twice.. doesnt really make sense :\\
|
2380
2357
|
verify_logged_in(true)
|
2381
2358
|
log_start(__method__, args, options)
|
2382
|
-
|
2383
2359
|
@project = Project.new(get_project_home)
|
2384
2360
|
commit_msg = options["message"]
|
2385
2361
|
if commit_msg.nil? or commit_msg.empty?
|
@@ -2388,18 +2364,24 @@ module Cnvrg
|
|
2388
2364
|
return_id = options["return_id"]
|
2389
2365
|
@files = Cnvrg::Files.new(@project.owner, @project.slug)
|
2390
2366
|
ignore = options[:ignore] || ""
|
2391
|
-
force = options[:force] || false
|
2367
|
+
force = options[:force] || force || false
|
2392
2368
|
spec_files_to_upload = options["files"]
|
2369
|
+
check = Helpers.checkmark()
|
2370
|
+
|
2393
2371
|
if !spec_files_to_upload.blank?
|
2394
2372
|
spec_files_to_upload = spec_files_to_upload.split(",")
|
2395
2373
|
end
|
2396
|
-
git_output_dir = options["output_dir"]
|
2397
|
-
if
|
2374
|
+
git_output_dir = options["output_dir"] || output_dir
|
2375
|
+
if git_output_dir.present?
|
2398
2376
|
if git_output_dir.ends_with? "/"
|
2399
2377
|
git_output_dir = git_output_dir[0..-2]
|
2400
2378
|
end
|
2401
2379
|
spec_files_to_upload = Dir.glob("#{git_output_dir}/**/*", File::FNM_DOTMATCH).flatten
|
2402
2380
|
spec_files_to_upload = spec_files_to_upload.select{|x| !x.ends_with? "/."}
|
2381
|
+
if spec_files_to_upload.blank?
|
2382
|
+
log_message("#{check} Project is up to date", Thor::Shell::Color::GREEN, (((options["sync"] or sync) and !direct) ? false : true))
|
2383
|
+
return true
|
2384
|
+
end
|
2403
2385
|
force = true
|
2404
2386
|
end
|
2405
2387
|
|
@@ -2431,7 +2413,7 @@ module Cnvrg
|
|
2431
2413
|
end
|
2432
2414
|
result = result["result"]["tree"]
|
2433
2415
|
|
2434
|
-
|
2416
|
+
|
2435
2417
|
if result["added"].empty? and result["updated_on_local"].empty? and result["deleted"].empty?
|
2436
2418
|
log_message("#{check} Project is up to date", Thor::Shell::Color::GREEN, (((options["sync"] or sync) and !direct) ? false : true))
|
2437
2419
|
return true
|
@@ -2448,7 +2430,6 @@ module Cnvrg
|
|
2448
2430
|
end
|
2449
2431
|
else
|
2450
2432
|
log_message("Syncing files", Thor::Shell::Color::BLUE, ((options["sync"] or sync)) ? false : true)
|
2451
|
-
|
2452
2433
|
end
|
2453
2434
|
# Start commit
|
2454
2435
|
if in_exp
|
@@ -2456,8 +2437,10 @@ module Cnvrg
|
|
2456
2437
|
else
|
2457
2438
|
exp_start_commit = nil
|
2458
2439
|
end
|
2459
|
-
|
2460
|
-
|
2440
|
+
job_type = options['job_type'] || job_type
|
2441
|
+
job_slug = options['job_slug'] || job_slug
|
2442
|
+
commit_sha1 = @files.start_commit(new_branch, force: force, exp_start_commit:exp_start_commit,
|
2443
|
+
job_type: job_type, job_slug: job_slug)["result"]["commit_sha1"]
|
2461
2444
|
# upload / update
|
2462
2445
|
begin
|
2463
2446
|
|
@@ -2753,8 +2736,8 @@ module Cnvrg
|
|
2753
2736
|
method_option :commit, :type => :string, :aliases => ["-c"], :desc => "download specified commit", :default => ""
|
2754
2737
|
method_option :all_files, :type => :boolean, :aliases => ["--all"], :desc => "download specified commit", :default => false
|
2755
2738
|
|
2739
|
+
def download_data_new(verbose=false, new_branch=false,sync=false, commit=nil,all_files=true)
|
2756
2740
|
begin
|
2757
|
-
def download_data_new(verbose=false,sync=false, commit=nil,all_files=true)
|
2758
2741
|
verify_logged_in(true)
|
2759
2742
|
log_start(__method__, args, options)
|
2760
2743
|
dataset_dir = is_cnvrg_dir(Dir.pwd)
|
@@ -2763,23 +2746,14 @@ module Cnvrg
|
|
2763
2746
|
commit_to_download = commit
|
2764
2747
|
local_idx = @dataset.generate_idx
|
2765
2748
|
all_files = all_files
|
2766
|
-
|
2767
|
-
res = @dataset.compare_idx_download( commit=commit_to_download, local_idx= local_idx,all_files=all_files)
|
2768
|
-
else
|
2769
|
-
res = @dataset.compare_idx_download( commit=nil, local_idx= local_idx,all_files=all_files)
|
2770
|
-
|
2771
|
-
end
|
2772
|
-
|
2749
|
+
res = @dataset.compare_idx_download(commit=commit_to_download.presence, local_idx= local_idx,all_files=all_files)
|
2773
2750
|
result = res["result"]["tree"]
|
2774
|
-
|
2775
2751
|
commit = res["result"]["commit"]
|
2776
2752
|
if result["updated_on_server"].empty? and result["conflicts"].empty? and result["deleted"].empty?
|
2777
2753
|
log_message("Dataset is up to date", Thor::Shell::Color::GREEN, ((options["sync"] or sync) ? false : true))
|
2778
2754
|
return true
|
2779
2755
|
end
|
2780
2756
|
update_total = result["updated_on_server"].size + result["conflicts"].size + result["deleted"].size
|
2781
|
-
|
2782
|
-
|
2783
2757
|
successful_changes = 0
|
2784
2758
|
if update_total ==1
|
2785
2759
|
log_message("Downloading #{update_total} file", Thor::Shell::Color::BLUE, !sync)
|
@@ -2790,112 +2764,20 @@ module Cnvrg
|
|
2790
2764
|
log_message("Downloading #{update_total} files", Thor::Shell::Color::BLUE)
|
2791
2765
|
else
|
2792
2766
|
log_message("Syncing Dataset", Thor::Shell::Color::BLUE, !sync)
|
2793
|
-
|
2794
|
-
end
|
2795
|
-
parallel_options = {
|
2796
|
-
:progress => {
|
2797
|
-
:title => "Download Progress",
|
2798
|
-
:progress_mark => '=',
|
2799
|
-
:format => "%b>>%i| %p%% %t",
|
2800
|
-
:starting_at => 0,
|
2801
|
-
:total => result["updated_on_server"].size,
|
2802
|
-
:autofinish => true
|
2803
|
-
},
|
2804
|
-
in_threads: ParallelThreads
|
2805
|
-
}
|
2806
|
-
conflicts = 0
|
2807
|
-
if !result["conflicts"].empty?
|
2808
|
-
begin
|
2809
|
-
|
2810
|
-
|
2811
|
-
conflicts_result = Parallel.map(result["conflicts"], in_threads: ParallelThreads) do |f|
|
2812
|
-
|
2813
|
-
relative_path = f.gsub(/^#{@dataset.local_path}/, "")
|
2814
|
-
log_message("downloading: #{f}.conflict", Thor::Shell::Color::BLUE, verbose)
|
2815
|
-
|
2816
|
-
if @files.download_file_s3(f, relative_path, dataset_dir, conflict=true, commit_sha1=commit)
|
2817
|
-
conflicts +=1
|
2818
|
-
else
|
2819
|
-
log_message("Couldn't download: #{f}", Thor::Shell::Color::RED)
|
2820
|
-
raise Parallel::Kill
|
2821
|
-
|
2822
|
-
end
|
2823
|
-
end
|
2824
|
-
rescue Interrupt
|
2825
|
-
|
2826
|
-
log_message("Failed to download files", Thor::Shell::Color::RED)
|
2827
|
-
|
2828
|
-
exit(1)
|
2829
|
-
end
|
2830
2767
|
end
|
2831
|
-
|
2832
|
-
|
2833
|
-
successful_changes += conflicts
|
2834
|
-
downloads = 0
|
2835
|
-
if !result["updated_on_server"].empty?
|
2836
|
-
|
2837
|
-
updated_on_server_result = Parallel.map(result["updated_on_server"], parallel_options) do |f|
|
2838
|
-
begin
|
2839
|
-
relative_path = f.gsub(/^#{@dataset.local_path}/, "")
|
2840
|
-
if f.end_with? "/"
|
2841
|
-
# dir
|
2842
|
-
if !all_files
|
2843
|
-
log_message("downloading dir: #{f}", Thor::Shell::Color::BLUE, verbose)
|
2844
|
-
if @files.download_dir(dataset_dir, relative_path)
|
2845
|
-
downloads +=1
|
2846
|
-
else
|
2847
|
-
log_message("Couldn't create directory: #{f}", Thor::Shell::Color::RED)
|
2848
|
-
raise Parallel::Kill
|
2849
|
-
|
2850
|
-
|
2851
|
-
end
|
2852
|
-
end
|
2853
|
-
|
2854
|
-
else
|
2855
|
-
# blob
|
2856
|
-
log_message("downloading file: #{f}", Thor::Shell::Color::BLUE, verbose)
|
2857
|
-
|
2858
|
-
if @files.download_file_s3(f, relative_path, dataset_dir,conflict=false, commit_sha1=commit)
|
2859
|
-
downloads +=1
|
2860
|
-
|
2861
|
-
else
|
2862
|
-
|
2863
|
-
log_message("Couldn't download: #{f}", Thor::Shell::Color::RED)
|
2864
|
-
raise Parallel::Kill
|
2865
|
-
|
2866
|
-
|
2867
|
-
end
|
2868
|
-
end
|
2869
|
-
rescue Interrupt
|
2870
|
-
log_message("Couldn't download", Thor::Shell::Color::RED)
|
2871
|
-
|
2872
|
-
exit(1)
|
2873
|
-
|
2874
|
-
end
|
2875
|
-
|
2876
|
-
end
|
2877
|
-
successful_changes += downloads
|
2878
|
-
|
2879
|
-
end
|
2880
|
-
|
2768
|
+
update_res = @files.download_files_in_chunks(result["updated_on_server"]) if result["updated_on_server"].present?
|
2769
|
+
conflict_res = @files.download_files_in_chunks(result["conflicts"], conflict: true) if result["conflicts"].present?
|
2881
2770
|
deleted = result["deleted"].to_a
|
2882
2771
|
delete_res = @files.delete_commit_files_local(deleted)
|
2883
2772
|
if !delete_res
|
2884
2773
|
log_message("Couldn't delete #{deleted.join(" ")}", Thor::Shell::Color::RED)
|
2885
2774
|
log_message("Couldn't download, Rolling Back all changes.", Thor::Shell::Color::RED)
|
2886
|
-
|
2887
2775
|
exit(1)
|
2888
|
-
|
2889
2776
|
end
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
if update_total == successful_changes
|
2777
|
+
if [update_res.is_success?, delete_res.is_success?, (conflict_res.blank? or conflict_res.is_success?)].all?
|
2895
2778
|
# update idx with latest commit
|
2896
2779
|
@dataset.update_idx_with_commit!(commit)
|
2897
2780
|
check = Helpers.checkmark()
|
2898
|
-
|
2899
2781
|
if options["verbose"]
|
2900
2782
|
log_message("#{check} Done, Downloaded:", Thor::Shell::Color::GREEN)
|
2901
2783
|
log_message(successful_changes.join("\n"), Thor::Shell::Color::GREEN)
|
@@ -2904,10 +2786,8 @@ module Cnvrg
|
|
2904
2786
|
log_message("#{check} Downloaded changes successfully", Thor::Shell::Color::GREEN, ((sync or options["sync"]) ? false : true))
|
2905
2787
|
end
|
2906
2788
|
return true
|
2907
|
-
|
2908
2789
|
end
|
2909
2790
|
rescue => e
|
2910
|
-
|
2911
2791
|
log_message("Error occurred, \nAborting", Thor::Shell::Color::BLUE)
|
2912
2792
|
log_error(e)
|
2913
2793
|
exit(1)
|
@@ -2915,7 +2795,8 @@ module Cnvrg
|
|
2915
2795
|
say "\nAborting", Thor::Shell::Color::BLUE
|
2916
2796
|
exit(1)
|
2917
2797
|
end
|
2918
|
-
|
2798
|
+
end
|
2799
|
+
|
2919
2800
|
desc 'download in git project', 'Download other files', :hide =>true
|
2920
2801
|
def download_in_git(commit_sha1)
|
2921
2802
|
begin
|
@@ -3322,27 +3203,33 @@ module Cnvrg
|
|
3322
3203
|
method_option :message, :type => :string, :aliases => ["-m", "--message"], :default => ""
|
3323
3204
|
method_option :return_id, :type => :boolean, :aliases => ["-r", "--return_id"], :default => false
|
3324
3205
|
method_option :deploy, :type => :boolean, :aliases => ["-d", "--deploy"], :default => false
|
3325
|
-
method_option :in_exp, :type => :boolean, :aliases => ["-e", "--in_exp"], :default => false
|
3206
|
+
method_option :in_exp, :type => :boolean, :aliases => ["-e", "--in_exp"], :default => false #deprecated..
|
3207
|
+
method_option :job_slug, :type => :string, :aliases => ["-j", "--job"], :default => nil
|
3208
|
+
method_option :job_type, :type => :string, :aliases => ["-jt", "--job_type"], :default => nil
|
3326
3209
|
method_option :files, :type => :string, :aliases => ["--files"], :default => nil
|
3327
3210
|
method_option :output_dir, :type => :string, :aliases => ["--output_dir"], :default => nil
|
3328
|
-
|
3329
|
-
|
3330
3211
|
def sync(direct = true)
|
3331
3212
|
verify_logged_in(true) if direct
|
3332
3213
|
log_start(__method__, args, options)
|
3333
3214
|
log_message('Checking for new updates from remote version', Thor::Shell::Color::BLUE, options["verbose"])
|
3334
3215
|
log_message('Syncing project', Thor::Shell::Color::BLUE, !options["verbose"])
|
3335
|
-
|
3336
|
-
|
3216
|
+
job_slug = options['job_slug']
|
3217
|
+
job_type = options['job_type']
|
3218
|
+
in_exp = options["in_exp"] || (job_slug.present? and job_type.present?)
|
3219
|
+
run_download = true
|
3220
|
+
if options[:force] or options[:files].present? or options[:output_dir].present? or in_exp
|
3221
|
+
run_download =false
|
3222
|
+
end
|
3223
|
+
if run_download
|
3224
|
+
invoke :download, [true, "", in_exp ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true
|
3337
3225
|
end
|
3338
|
-
invoke :upload, [false, true, direct, "",options[
|
3226
|
+
invoke :upload, [false, true, direct, "",options['exp_slug'] ], :new_branch => options["new_branch"], :verbose => options["verbose"], :sync => true,
|
3339
3227
|
:ignore => options[:ignore], :force => options[:force], :message => options[:message], :deploy => options["deploy"], :return_id => options["return_id"],
|
3340
|
-
:files => options["files"], :output_dir => options["output_dir"]
|
3228
|
+
:files => options["files"], :output_dir => options["output_dir"], :job_slug => job_slug, :job_type => job_type
|
3341
3229
|
|
3342
3230
|
|
3343
3231
|
end
|
3344
3232
|
|
3345
|
-
|
3346
3233
|
desc 'run cmd', 'Runs an experiment'
|
3347
3234
|
method_option :local, :type => :boolean, :aliases => ["-l", "--local"], :default => false
|
3348
3235
|
method_option :small, :type => :boolean, :aliases => ["-sm", "--small"], :default => false
|
@@ -3487,10 +3374,8 @@ module Cnvrg
|
|
3487
3374
|
force = options[:force]
|
3488
3375
|
sync_before_terminate = options["sync_before_terminate"]
|
3489
3376
|
periodic_sync = options["periodic_sync"]
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
3377
|
email_notification = options["email_notification"]
|
3378
|
+
output_dir = options['output_dir'] || "output"
|
3494
3379
|
project_home = get_project_home
|
3495
3380
|
data_query = options["data_query"]
|
3496
3381
|
@project = Project.new(project_home)
|
@@ -3506,6 +3391,7 @@ module Cnvrg
|
|
3506
3391
|
if sync_before
|
3507
3392
|
# Sync before run
|
3508
3393
|
invoke :sync, [false], :new_branch => is_new_branch, :ignore => ignore, :force => force
|
3394
|
+
|
3509
3395
|
end
|
3510
3396
|
end
|
3511
3397
|
#set image for the project
|
@@ -3578,10 +3464,9 @@ module Cnvrg
|
|
3578
3464
|
if output_dir.blank?
|
3579
3465
|
output_dir = "output"
|
3580
3466
|
end
|
3581
|
-
|
3467
|
+
upload(false, false, true, ignore, true, true,output_dir,"Experiment",@exp.slug )
|
3582
3468
|
else
|
3583
|
-
|
3584
|
-
|
3469
|
+
upload(false, false, true, ignore, true, true,nil,"Experiment",@exp.slug )
|
3585
3470
|
end
|
3586
3471
|
res = @exp.send_restart_request(@project.get_idx.try(:fetch, :commit))
|
3587
3472
|
while !Cnvrg::CLI.is_response_success(res, false) do
|
@@ -3685,24 +3570,17 @@ module Cnvrg
|
|
3685
3570
|
|
3686
3571
|
if sync_after
|
3687
3572
|
# Sync after run
|
3688
|
-
|
3689
|
-
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
upload_output = upload_output.join(",")
|
3694
|
-
invoke :upload, [false, true, false, ignore, true, true], :output_dir => upload_output, :force=>true
|
3695
|
-
end
|
3696
|
-
|
3697
|
-
else
|
3698
|
-
upload_res = upload(false, true, false, ignore, true, false)
|
3699
|
-
|
3700
|
-
|
3573
|
+
if @project.is_git
|
3574
|
+
output_dir = output_dir || @exp.output_dir
|
3575
|
+
if output_dir.present?
|
3576
|
+
upload(false, false, true, ignore, true, true,output_dir,"Experiment",@exp.slug )
|
3577
|
+
# invoke :upload, [false, false, true, ignore, true, true], :output_dir => output_dir, :force=>true, :job_type=>'Experiment', :job_slug=>@exp.slug
|
3701
3578
|
end
|
3702
|
-
|
3579
|
+
else
|
3580
|
+
upload(false, false, true, ignore, true, true,nil,"Experiment",@exp.slug )
|
3581
|
+
|
3582
|
+
# invoke :upload, [false, false, true, ignore,true, true], :job_type=>'Experiment', :job_slug=>@exp.slug, :force=>true
|
3703
3583
|
end
|
3704
|
-
# download(sync = true, ignore_list = ignore)
|
3705
|
-
# upload(link = false, sync = true, direct = false, ignore_list = ignore)
|
3706
3584
|
|
3707
3585
|
end
|
3708
3586
|
end_commit = @project.last_local_commit
|
@@ -3710,7 +3588,7 @@ module Cnvrg
|
|
3710
3588
|
# log_thread.join
|
3711
3589
|
stats_thread.join
|
3712
3590
|
|
3713
|
-
|
3591
|
+
res = @exp.end(log, exit_status, end_commit, cpu_average, memory_average)
|
3714
3592
|
|
3715
3593
|
|
3716
3594
|
if !exp_success
|
@@ -3865,6 +3743,7 @@ module Cnvrg
|
|
3865
3743
|
|
3866
3744
|
end
|
3867
3745
|
project = Project.new(working_dir)
|
3746
|
+
|
3868
3747
|
if project.is_git and output_dir.blank?
|
3869
3748
|
output_dir = "output"
|
3870
3749
|
end
|