cnvrg 1.6.0.6 → 1.6.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cnvrg/cli.rb +14 -29
- data/lib/cnvrg/data.rb +44 -0
- data/lib/cnvrg/dataset.rb +54 -0
- data/lib/cnvrg/experiment.rb +3 -2
- data/lib/cnvrg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e632845d8a6f6ca39492119e8efa15f90aaa76f66737336da95ef24b89b873
|
4
|
+
data.tar.gz: 79a573e7bb4dcb63dadb89dba6c5bba7c16473e8fcc688ad27c64ff1c0b58dcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6308aba4c811a524e84ffa9d1a9519af3fe74561ac1adb20b9ad4db8d78ab91b834549f37a29c258f5775bf59d46328fd956ced36c9877ccf2c678d4641643bd
|
7
|
+
data.tar.gz: a4e5526fa519c995833b52d8ba5147a1cda9373f634dff60aa6435422a6486c7b599f0a27427a68d20166c5dc81f2aa54badc686186baec26483a3fff41f08bc
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -187,31 +187,6 @@ module Cnvrg
|
|
187
187
|
self.log_handler
|
188
188
|
end
|
189
189
|
|
190
|
-
desc "", "", :hide => true
|
191
|
-
|
192
|
-
def test
|
193
|
-
# image_settings = {
|
194
|
-
# 'Image' => "cnvrg:latest",
|
195
|
-
# 'User' => 'ds',
|
196
|
-
# 'Cmd' => '/home/ds/run_ipython.sh',
|
197
|
-
# 'ExposedPorts' => {``
|
198
|
-
# '80/tcp' => {},
|
199
|
-
# },
|
200
|
-
# 'HostConfig' => {
|
201
|
-
# 'PortBindings' => {
|
202
|
-
# '80/tcp' => [
|
203
|
-
# {'HostPort' => "7654", 'HostIp' => 'localhost'}
|
204
|
-
# ],
|
205
|
-
# },
|
206
|
-
# },
|
207
|
-
# }
|
208
|
-
# container = Docker::Container.get('b4d64bf83f41')
|
209
|
-
# s = "/leah/1/2/3/4/5"
|
210
|
-
# command = ["/bin/bash","-lc","sed -i 's#c.NotebookApp.base_url = .*#c.NotebookApp.base_url = \"#{s}\"#' /home/ds/.jupyter/jupyter_notebook_config.py"]
|
211
|
-
# puts container.exec(command, tty: true)
|
212
|
-
end
|
213
|
-
|
214
|
-
|
215
190
|
desc 'version', 'Prints cnvrg current version'
|
216
191
|
|
217
192
|
def version
|
@@ -810,6 +785,7 @@ module Cnvrg
|
|
810
785
|
exit(1)
|
811
786
|
end
|
812
787
|
end
|
788
|
+
|
813
789
|
desc 'data delete', 'delete dataset', :hide => true
|
814
790
|
def delete_data(dataset_slug)
|
815
791
|
begin
|
@@ -1740,7 +1716,7 @@ module Cnvrg
|
|
1740
1716
|
verify_logged_in(false)
|
1741
1717
|
log_start(__method__, args, options)
|
1742
1718
|
working_dir = is_cnvrg_dir()
|
1743
|
-
list_to_del = [working_dir + "/.
|
1719
|
+
list_to_del = [working_dir + "/.cnvrg"]
|
1744
1720
|
FileUtils.rm_rf list_to_del
|
1745
1721
|
end
|
1746
1722
|
|
@@ -1753,6 +1729,7 @@ module Cnvrg
|
|
1753
1729
|
|
1754
1730
|
clone_resp = Project.clone_dir_remote(slug, owner, slug,true)
|
1755
1731
|
idx_status = Project.new(get_project_home).generate_idx
|
1732
|
+
FileUtils.mkdir_p File.join(get_project_home, ENV['CNVRG_OUTPUT_DIR']) if ENV['CNVRG_OUTPUT_DIR'].present?
|
1756
1733
|
@executer = Cnvrg::Helpers::Executer.get_executer
|
1757
1734
|
if @executer.present?
|
1758
1735
|
@executer.update_git_commit
|
@@ -2929,6 +2906,8 @@ module Cnvrg
|
|
2929
2906
|
method_option :git_branch, :type => :string, :aliases => [ "--git_branch"], :default => nil
|
2930
2907
|
method_option :restart_if_stuck, :type => :boolean, :aliases => ["--restart","--restart_if_stuck"], :default => nil
|
2931
2908
|
method_option :local_folders, :type => :string, :aliases => ["--local_folders"], :default => nil
|
2909
|
+
method_option :prerun, :type => :boolean, :aliases => ["-p", "--prerun"], :default => true
|
2910
|
+
method_option :requirements, :type => :boolean, :aliases => ["-r", "--requirements"], :default => true
|
2932
2911
|
|
2933
2912
|
def run(*cmd)
|
2934
2913
|
verify_logged_in(true)
|
@@ -2957,6 +2936,8 @@ module Cnvrg
|
|
2957
2936
|
output_dir = options["output_dir"]
|
2958
2937
|
data_query = options["data_query"]
|
2959
2938
|
local_folders = options["local_folders"]
|
2939
|
+
prerun = options["prerun"]
|
2940
|
+
requirements = options["requirements"]
|
2960
2941
|
|
2961
2942
|
if !data.present? and data_query.present?
|
2962
2943
|
log_message("Please provide data with data_query", Thor::Shell::Color::RED)
|
@@ -3006,7 +2987,7 @@ module Cnvrg
|
|
3006
2987
|
:max_time => max_time,
|
3007
2988
|
:periodic_sync => periodic_sync, :dataset_only_tree=> dataset_only_tree,
|
3008
2989
|
:output_dir=>output_dir, :data_query=>data_query, :git_commit =>git_commit, :git_branch=> git_branch,
|
3009
|
-
:restart_if_stuck =>restart_if_stuck, :local_folders => local_folders, :datasets => datasets
|
2990
|
+
:restart_if_stuck =>restart_if_stuck, :local_folders => local_folders, :datasets => datasets, :prerun => prerun, :requirements => requirements
|
3010
2991
|
return
|
3011
2992
|
end
|
3012
2993
|
|
@@ -3309,6 +3290,8 @@ module Cnvrg
|
|
3309
3290
|
method_option :restart_if_stuck, :type => :boolean, :aliases => ["--restart"], :default => nil
|
3310
3291
|
method_option :local_folders, :type => :string, :aliases => ["--local_folders"], :default => nil
|
3311
3292
|
method_option :datasets, :type => :string, :aliases => ["--datasets"], :default => nil
|
3293
|
+
method_option :prerun, :type => :boolean, :aliases => ["-p", "--prerun"], :default => true
|
3294
|
+
method_option :requirements, :type => :boolean, :aliases => ["-r", "--requirements"], :default => true
|
3312
3295
|
|
3313
3296
|
def exec_remote(*cmd)
|
3314
3297
|
|
@@ -3326,6 +3309,8 @@ module Cnvrg
|
|
3326
3309
|
data_query = options["data_query"] || nil
|
3327
3310
|
sync_before = options["sync_before"]
|
3328
3311
|
force = options["force"]
|
3312
|
+
prerun = options["prerun"]
|
3313
|
+
requirements = options["requirements"]
|
3329
3314
|
max_time = options["max_time"]
|
3330
3315
|
if !max_time.nil? and !max_time.empty?
|
3331
3316
|
max_time = max_time.to_i
|
@@ -3381,7 +3366,7 @@ module Cnvrg
|
|
3381
3366
|
local_folders_options = options["local_folders"]
|
3382
3367
|
options_hash.except!("schedule", "machine_type", "image", "upload_output", "grid", "data", "data_commit", "title",
|
3383
3368
|
"local", "small", "medium", "large", "gpu", "gpuxl", "gpuxxl","max_time","dataset_only_tree",
|
3384
|
-
"data_query", "git_commit","git_branch", "restart_if_stuck","local_folders","output_dir", "commit", "datasets" )
|
3369
|
+
"data_query", "git_commit","git_branch", "restart_if_stuck","local_folders","output_dir", "commit", "datasets", "requirements", "prerun" )
|
3385
3370
|
exec_options = options_hash.map {|x| "--#{x[0]}=#{x[1]}"}.flatten.join(" ")
|
3386
3371
|
command = "#{exec_options} #{remote} #{upload_output_option} #{cmd.flatten.join(" ")}"
|
3387
3372
|
commit_to_run = options["commit"] || nil
|
@@ -3452,7 +3437,7 @@ module Cnvrg
|
|
3452
3437
|
|
3453
3438
|
res = exp.exec_remote(command, commit_to_run, instance_type, image, schedule, local_timestamp, grid, path_to_cmd, data, data_commit,
|
3454
3439
|
periodic_sync, sync_before_terminate, max_time, ds_sync_options,output_dir,
|
3455
|
-
data_query, git_commit, git_branch, restart_if_stuck,local_folders_options, title, datasets)
|
3440
|
+
data_query, git_commit, git_branch, restart_if_stuck,local_folders_options, title, datasets, prerun: prerun, requirements: requirements)
|
3456
3441
|
if Cnvrg::CLI.is_response_success(res)
|
3457
3442
|
check = Helpers.checkmark()
|
3458
3443
|
str = "#{check} Experiment's is on: #{Cnvrg::Helpers.remote_url}/#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}"
|
data/lib/cnvrg/data.rb
CHANGED
@@ -13,6 +13,12 @@ end
|
|
13
13
|
module Cnvrg
|
14
14
|
class Data < SubCommandBase
|
15
15
|
class_option :no_compression, :type => :boolean, :aliases => ["-nc", "--no_compression"], :default => false
|
16
|
+
|
17
|
+
module ConfigValidation
|
18
|
+
SUCCESS = "success"
|
19
|
+
FAILED = "failed"
|
20
|
+
end
|
21
|
+
|
16
22
|
desc "data init", "Set current directory as dataset directory"
|
17
23
|
method_option :public, :type => :boolean, :aliases => ["-p", "--public"], :default => false
|
18
24
|
method_option :bucket, :type => :string, :aliases => ["-b", "--bucket"], :default => ""
|
@@ -22,6 +28,44 @@ module Cnvrg
|
|
22
28
|
bucket = options["bucket"]
|
23
29
|
cli.init_data(public, bucket: bucket)
|
24
30
|
end
|
31
|
+
|
32
|
+
desc "data link", "Set current directory as dataset directory"
|
33
|
+
def link(dataset_slug=nil)
|
34
|
+
begin
|
35
|
+
raise Exception.new("Please enter dataset name") if dataset_slug.blank?
|
36
|
+
cli = Cnvrg::CLI.new()
|
37
|
+
cli.verify_logged_in(false)
|
38
|
+
cli.log_start(__method__, args, options)
|
39
|
+
|
40
|
+
config_validation = Dataset.validate_config
|
41
|
+
if config_validation[:validation] == Data::ConfigValidation::SUCCESS
|
42
|
+
cli.log_message(config_validation[:message])
|
43
|
+
return
|
44
|
+
else
|
45
|
+
Cnvrg::Logger.log_error_message(config_validation)
|
46
|
+
FileUtils.rmtree(".cnvrg")
|
47
|
+
end
|
48
|
+
|
49
|
+
cli.log_message("Linking dataset: #{dataset_slug} to the current directory", Thor::Shell::Color::BLUE)
|
50
|
+
owner = CLI.get_owner
|
51
|
+
success = Dataset.link_dataset(owner: owner, slug: dataset_slug)
|
52
|
+
if success
|
53
|
+
cli.log_message("Dataset: #{dataset_slug} linked successfully to the current directory")
|
54
|
+
else
|
55
|
+
cli.log_message("Linking failed\nAborting", Thor::Shell::Color::RED)
|
56
|
+
end
|
57
|
+
rescue => e
|
58
|
+
Cnvrg::Logger.log_error(e)
|
59
|
+
cli.log_message("Aborting\n#{e.message}", Thor::Shell::Color::RED)
|
60
|
+
exit(1)
|
61
|
+
rescue Exception => e
|
62
|
+
Cnvrg::Logger.log_error(e)
|
63
|
+
cli.log_message("Aborting\n#{e.message}", Thor::Shell::Color::RED)
|
64
|
+
exit(1)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
25
69
|
desc "data upload", "Upload files from local dataset directory to remote server"
|
26
70
|
method_option :verbose, :type => :boolean, :aliases => ["-v"], :default => false
|
27
71
|
method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
|
data/lib/cnvrg/dataset.rb
CHANGED
@@ -311,6 +311,37 @@ module Cnvrg
|
|
311
311
|
return true
|
312
312
|
end
|
313
313
|
|
314
|
+
def self.link_dataset(owner: nil, slug: nil)
|
315
|
+
begin
|
316
|
+
return false if owner.blank? or slug.blank?
|
317
|
+
|
318
|
+
response = Cnvrg::API.request("users/#{owner}/datasets/#{slug}", 'GET')
|
319
|
+
success = Cnvrg::CLI.is_response_success(response, false)
|
320
|
+
return unless success
|
321
|
+
result = response["result"]
|
322
|
+
|
323
|
+
config = {dataset_name: result["title"],
|
324
|
+
dataset_slug: result["slug"],
|
325
|
+
owner: owner}
|
326
|
+
|
327
|
+
list_dirs = [".cnvrg"]
|
328
|
+
list_files = [".cnvrg/config.yml"]
|
329
|
+
|
330
|
+
|
331
|
+
FileUtils.mkdir_p list_dirs
|
332
|
+
FileUtils.touch list_files
|
333
|
+
File.open(".cnvrg/config.yml", "w+") {|f| f.write config.to_yaml}
|
334
|
+
|
335
|
+
# Write init IDX that contain init commit sha1 so the user will be able to doing actions on the dataset
|
336
|
+
# Relevant only for new server
|
337
|
+
dataset = Dataset.new(Dir.pwd)
|
338
|
+
sha1 = result["init_commit_sha1"]
|
339
|
+
dataset.write_idx({}, sha1)
|
340
|
+
true
|
341
|
+
rescue => e
|
342
|
+
raise Exception.new(e)
|
343
|
+
end
|
344
|
+
end
|
314
345
|
|
315
346
|
def self.blank_clone(owner, dataset_name, dataset_slug)
|
316
347
|
list_dirs = [".cnvrg"
|
@@ -796,5 +827,28 @@ module Cnvrg
|
|
796
827
|
# CLI.is_response_success(response)
|
797
828
|
end
|
798
829
|
|
830
|
+
def self.validate_config
|
831
|
+
## check that the .cnvrg folder exists:
|
832
|
+
dot_cnvrg_exists = Dir[".cnvrg"].present?
|
833
|
+
return {validation: Data::ConfigValidation::FAILED, message: ".cnvrg folder does not exists"} if not dot_cnvrg_exists
|
834
|
+
|
835
|
+
## check that the config.yml exists:
|
836
|
+
config_file_exists = Dir[".cnvrg/*"].include? ".cnvrg/config.yml"
|
837
|
+
return {validation: Data::ConfigValidation::FAILED, message: "config.yml exists"} if not config_file_exists
|
838
|
+
|
839
|
+
## check that the config.yml file not empty:
|
840
|
+
config = YAML.load_file("#{Dir.getwd}/.cnvrg/config.yml")
|
841
|
+
return {validation: Data::ConfigValidation::FAILED, message: "config.yml is empty"} if not config
|
842
|
+
|
843
|
+
## check that config.yml is valid:
|
844
|
+
title = config[:dataset_name]
|
845
|
+
slug = config[:dataset_slug]
|
846
|
+
owner = config[:owner]
|
847
|
+
return {validation: Data::ConfigValidation::FAILED, message: "config.yml is not valid or some keys are missing"} if title.blank? or slug.blank? or owner.blank?
|
848
|
+
|
849
|
+
## everything OK:
|
850
|
+
return {validation: Data::ConfigValidation::SUCCESS, message: "Directory is already linked to #{slug}"}
|
851
|
+
end
|
852
|
+
|
799
853
|
end
|
800
854
|
end
|
data/lib/cnvrg/experiment.rb
CHANGED
@@ -90,7 +90,7 @@ module Cnvrg
|
|
90
90
|
|
91
91
|
def exec_remote(command, commit_to_run, instance_type, image_slug,scheduling_query,local_timestamp, grid,path_to_cmd,data, data_commit,periodic_sync,
|
92
92
|
sync_before_terminate, max_time, ds_sync_options=0,output_dir=nil,data_query=nil,
|
93
|
-
git_commit=nil, git_branch=nil, restart_if_stuck=nil, local_folders=nil,title=nil, datasets=nil)
|
93
|
+
git_commit=nil, git_branch=nil, restart_if_stuck=nil, local_folders=nil,title=nil, datasets=nil, prerun: true, requirements: true)
|
94
94
|
response = Cnvrg::API.request("users/#{@owner}/projects/#{@project_slug}/experiment/remote", 'POST', {command: command, image_slug: image_slug,
|
95
95
|
commit_sha1: commit_to_run,
|
96
96
|
instance_type: instance_type,
|
@@ -103,7 +103,8 @@ module Cnvrg
|
|
103
103
|
periodic_sync:periodic_sync, sync_before_terminate:sync_before_terminate,
|
104
104
|
dataset_sync_options:ds_sync_options,output_dir:output_dir,
|
105
105
|
dataset_query:data_query,git_commit:git_commit,git_branch:git_branch,
|
106
|
-
restart_if_stuck:restart_if_stuck, local_folders: local_folders, title:title
|
106
|
+
restart_if_stuck:restart_if_stuck, local_folders: local_folders, title:title,
|
107
|
+
prerun: prerun, requirements: requirements})
|
107
108
|
|
108
109
|
return response
|
109
110
|
end
|
data/lib/cnvrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.0.
|
4
|
+
version: 1.6.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
@@ -476,7 +476,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
476
476
|
- !ruby/object:Gem::Version
|
477
477
|
version: '0'
|
478
478
|
requirements: []
|
479
|
-
rubygems_version: 3.0.
|
479
|
+
rubygems_version: 3.0.3
|
480
480
|
signing_key:
|
481
481
|
specification_version: 4
|
482
482
|
summary: A CLI tool for interacting with cnvrg.io.
|