cnvrg 1.6.27 → 1.6.36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cd284862886ec5b09fd54d38793623e428fec3dbfac5fc6c46667c2e820a302
4
- data.tar.gz: 7f3cce766ef0935b737ce0e95dcce47bf827bc4ab45579887fa51b9ec4a02b55
3
+ metadata.gz: c5e60c1cc7c0af133390dd106ee666db3787b6c995b54d5ef97edff3d073ff14
4
+ data.tar.gz: 3d37f71642874898b131812fdeb1ca7be3b7eebddc3a8aa521245c31eaa47a0b
5
5
  SHA512:
6
- metadata.gz: 32562f3442ed727ab26ee6de3af75df36bd56d6c1515d653e697936c03624efa03d741610b7e960b67a7179b3f961b7d07efb71af0e3201ff15b08939aca3719
7
- data.tar.gz: 8fbaad6c29f0f7e0ae504912505f36be91825263c3cb72b2ad73df5cc7944115e605eaf3e6711b526c1cbdf9d52572c488728d62a2ce86c5ee40aa9e1a5e99b3
6
+ metadata.gz: dc82247f7d78186aa0b35084d83b0d4ae72608f0c765727ee57bebcec76d6bc9c84fad2795c7c7ed7ba6ac64921df49c9c45cd3536128b11b8a5b8203e8e0040
7
+ data.tar.gz: 896d84a1615dd3a698c5e78ce92d7422fca9e6f21e1c7e9ca6011ab315437b39b2f3f5fb0790d683397e2ba6bdaaad4185156255e615e298471b50949201f9d2
@@ -1184,7 +1184,7 @@ module Cnvrg
1184
1184
  end
1185
1185
 
1186
1186
  desc '', '', :hide => true
1187
- def data_put(dataset_url, files: [], dir: '', commit: '', chunk_size: 1000)
1187
+ def data_put(dataset_url, files: [], dir: '', commit: '', chunk_size: 1000, message: nil)
1188
1188
  begin
1189
1189
  verify_logged_in(false)
1190
1190
  log_start(__method__, args, options)
@@ -1204,7 +1204,7 @@ module Cnvrg
1204
1204
  log_message("Uploading #{@files.size} files", Thor::Shell::Color::GREEN)
1205
1205
  number_of_chunks = (@files.size.to_f / chunk_size).ceil
1206
1206
  if commit.blank?
1207
- response = @datafiles.start_commit(false, true, chunks: number_of_chunks)
1207
+ response = @datafiles.start_commit(false, true, chunks: number_of_chunks, message: message )
1208
1208
  unless response #means we failed in the start commit.
1209
1209
  raise SignalException.new(1, "Cant put files into dataset, check the dataset id")
1210
1210
  end
@@ -1837,8 +1837,6 @@ module Cnvrg
1837
1837
  end
1838
1838
  clone_resp = Project.clone_dir(slug, owner, project_name,git)
1839
1839
  project_home = Dir.pwd + "/" + project_name
1840
-
1841
-
1842
1840
  end
1843
1841
 
1844
1842
  if clone_resp
@@ -1986,31 +1984,7 @@ module Cnvrg
1986
1984
  files_to_upload, upload_errors = invoke :upload_data_files,[commit, files_list: files_list],:new_branch=>new_branch, :verbose =>verbose, :force =>force, :sync =>sync, :chunk_size => chunk_size
1987
1985
 
1988
1986
  upload_size = files_to_upload + upload_errors.try(:size) rescue 0
1989
-
1990
- if files_to_upload <= 0
1991
- check = Helpers.checkmark
1992
- log_message("#{check} Data sync finished", Thor::Shell::Color::GREEN)
1993
- if total_deleted > 0
1994
- log_message("#{total_deleted} files deleted successfully.", Thor::Shell::Color::GREEN)
1995
- end
1996
-
1997
- if total_downloaded > 0
1998
- log_message("#{total_downloaded} files downloaded successfully.", Thor::Shell::Color::GREEN)
1999
- end
2000
-
2001
- if upload_errors.try(:size) > 0
2002
- log_message("#{upload_errors.try(:size)}/#{upload_size} files didn't upload:", Thor::Shell::Color::RED)
2003
- upload_errors.each do |file_hash|
2004
- log_message("#{file_hash[:absolute_path]}", Thor::Shell::Color::RED)
2005
- end
2006
- end
2007
-
2008
- if upload_errors.blank? and total_downloaded == 0 and total_deleted == 0
2009
- Cnvrg::CLI.log_message("You are up to date", Thor::Shell::Color::GREEN)
2010
- end
2011
- return
2012
- end
2013
- invoke :end_commit_data,[commit, success: true, uploaded_files: files_to_upload], :new_branch=>new_branch, :force =>force
1987
+ invoke :end_commit_data,[commit, success: true, uploaded_files: files_to_upload, sync: sync], :new_branch=>new_branch, :force =>force
2014
1988
  if tags
2015
1989
  log_message('Uploading Tags', Thor::Shell::Color::BLUE)
2016
1990
  dataset_dir = is_cnvrg_dir(Dir.pwd)
@@ -2035,8 +2009,10 @@ module Cnvrg
2035
2009
  if total_downloaded > 0
2036
2010
  log_message("#{total_downloaded} files downloaded successfully.", Thor::Shell::Color::GREEN)
2037
2011
  end
2012
+ if upload_size > 0
2013
+ log_message("#{files_to_upload}/#{upload_size} files uploaded successfully.", Thor::Shell::Color::GREEN)
2014
+ end
2038
2015
 
2039
- log_message("#{files_to_upload}/#{upload_size} files uploaded successfully.", Thor::Shell::Color::GREEN)
2040
2016
  if upload_errors.try(:size) > 0
2041
2017
  log_message("#{upload_errors.try(:size)}/#{upload_size} files didn't upload:", Thor::Shell::Color::RED)
2042
2018
  upload_errors.each do |file_hash|
@@ -2100,7 +2076,7 @@ module Cnvrg
2100
2076
  method_option :new_branch, :type => :boolean, :aliases => ["-nb"], :desc => "create new branch of commits"
2101
2077
  method_option :force, :type => :boolean, :aliases => ["-f","--force"], :default => false
2102
2078
 
2103
- def end_commit_data(commit, success: true, uploaded_files: 0)
2079
+ def end_commit_data(commit, success: true, uploaded_files: 0, sync: false)
2104
2080
  begin
2105
2081
  verify_logged_in(true)
2106
2082
  log_start(__method__, args, options)
@@ -2115,7 +2091,12 @@ module Cnvrg
2115
2091
  @dataset.revert_next_commit #removes the next commit
2116
2092
  log_message("#{check} Dataset is up to date", Thor::Shell::Color::GREEN)
2117
2093
  else
2118
- log_message("#{check} Data sync finished", Thor::Shell::Color::GREEN)
2094
+ if sync
2095
+ message = "#{check} Data sync finished"
2096
+ else
2097
+ message = "#{check} Data upload finished"
2098
+ end
2099
+ log_message(message, Thor::Shell::Color::GREEN)
2119
2100
  @dataset.remove_next_commit #takes the next commit and put it as current commit
2120
2101
  @dataset.set_partial_commit(nil)
2121
2102
  @dataset.backup_idx
@@ -2911,7 +2892,7 @@ module Cnvrg
2911
2892
  method_option :job_type, :type => :string, :aliases => ["-jt", "--job_type"], :default => nil
2912
2893
  method_option :files, :type => :string, :aliases => ["--files"], :default => nil
2913
2894
  method_option :output_dir, :type => :string, :aliases => ["--output_dir"], :default => nil
2914
- def sync(direct = true)
2895
+ def sync(direct = true)
2915
2896
  verify_logged_in(true) if direct
2916
2897
  @project = Project.new(get_project_home)
2917
2898
  log_start(__method__, args, options)
@@ -2973,6 +2954,7 @@ module Cnvrg
2973
2954
  method_option :requirements, :type => :boolean, :aliases => ["-r", "--requirements"], :default => true
2974
2955
  method_option :notify_on_error, :type => :boolean, :aliases => ["-noe", "--notify_on_error"], :default => nil
2975
2956
  method_option :notify_on_success, :type => :boolean, :aliases => ["-nos", "--notify_on_success"], :default => nil
2957
+ method_option :emails, :type => :string, :aliases => ["-es", "--emails"], :default => "", :desc => "additional emails to notify on success / or error, comma separated"
2976
2958
 
2977
2959
  def run(*cmd)
2978
2960
  verify_logged_in(true)
@@ -3006,6 +2988,7 @@ module Cnvrg
3006
2988
  requirements = options["requirements"]
3007
2989
  email_notification_error = options["notify_on_error"]
3008
2990
  email_notification_success = options["notify_on_success"]
2991
+ emails = options["emails"]
3009
2992
 
3010
2993
  if !data.present? and data_query.present?
3011
2994
  log_message("Please provide data with data_query", Thor::Shell::Color::RED)
@@ -3020,7 +3003,6 @@ module Cnvrg
3020
3003
  restart_if_stuck = options["restart_if_stuck"]
3021
3004
 
3022
3005
  options_hash = Hash[options]
3023
-
3024
3006
  if local
3025
3007
  if Cnvrg::Helpers.windows?
3026
3008
  say "Windows is currently not supported for running experiments locally"
@@ -3056,7 +3038,7 @@ module Cnvrg
3056
3038
  :periodic_sync => periodic_sync, :dataset_only_tree=> dataset_only_tree,
3057
3039
  :output_dir=>output_dir, :data_query=>data_query, :git_commit =>git_commit, :git_branch=> git_branch,
3058
3040
  :restart_if_stuck =>restart_if_stuck, :local_folders => local_folders, :datasets => datasets, :prerun => prerun, :requirements => requirements,
3059
- :email_notification_error => email_notification_error, :email_notification_success => email_notification_success
3041
+ :email_notification_error => email_notification_error, :email_notification_success => email_notification_success, :emails => emails
3060
3042
  return
3061
3043
  end
3062
3044
 
@@ -3362,8 +3344,9 @@ module Cnvrg
3362
3344
  method_option :datasets, :type => :string, :aliases => ["--datasets"], :default => nil
3363
3345
  method_option :prerun, :type => :boolean, :aliases => ["-p", "--prerun"], :default => true
3364
3346
  method_option :requirements, :type => :boolean, :aliases => ["-r", "--requirements"], :default => true
3365
- method_option :email_notification_error, :type => :boolean, :aliases => ["--email_notification_error"], :default => true
3366
- method_option :email_notification_success, :type => :boolean, :aliases => ["--email_notification_success"], :default => true
3347
+ method_option :email_notification_error, :type => :boolean, :aliases => ["-noe", "--email_notification_error"], :default => true
3348
+ method_option :email_notification_success, :type => :boolean, :aliases => ["-nos", "--email_notification_success"], :default => true
3349
+ method_option :emails, :type => :string, :aliases => ["-es", "--emails"], :default => "", :desc => "additional emails to notify on success / or error"
3367
3350
 
3368
3351
  def exec_remote(*cmd)
3369
3352
 
@@ -3385,6 +3368,7 @@ module Cnvrg
3385
3368
  requirements = options["requirements"]
3386
3369
  email_notification_error = options["email_notification_error"]
3387
3370
  email_notification_success = options["email_notification_success"]
3371
+ emails = options["emails"]
3388
3372
  max_time = options["max_time"]
3389
3373
  if !max_time.nil? and !max_time.empty?
3390
3374
  max_time = max_time.to_i
@@ -3424,7 +3408,7 @@ module Cnvrg
3424
3408
  options_hash.except!("schedule", "recurring", "machine_type", "image", "upload_output", "grid", "data", "data_commit", "title",
3425
3409
  "local", "small", "medium", "large", "gpu", "gpuxl", "gpuxxl","max_time","dataset_only_tree",
3426
3410
  "data_query", "git_commit","git_branch", "restart_if_stuck","local_folders","output_dir", "commit", "datasets", "requirements", "prerun",
3427
- "email_notification_error", "email_notification_success")
3411
+ "email_notification_error", "email_notification_success", "emails")
3428
3412
  exec_options = options_hash.map {|x| "--#{x[0]}=#{x[1]}"}.flatten.join(" ")
3429
3413
  command = "#{exec_options} #{remote} #{upload_output_option} #{cmd.flatten.join(" ")}"
3430
3414
  commit_to_run = options["commit"] || nil
@@ -3492,7 +3476,7 @@ module Cnvrg
3492
3476
  res = exp.exec_remote(command, commit_to_run, instance_type, image, schedule, local_timestamp, grid, path_to_cmd, data, data_commit,
3493
3477
  periodic_sync, sync_before_terminate, max_time, ds_sync_options,output_dir,
3494
3478
  data_query, git_commit, git_branch, restart_if_stuck,local_folders_options, title, datasets, prerun: prerun, requirements: requirements, recurring: recurring,
3495
- email_notification_error: email_notification_error, email_notification_success: email_notification_success)
3479
+ email_notification_error: email_notification_error, email_notification_success: email_notification_success, emails_to_notify: emails)
3496
3480
  if Cnvrg::CLI.is_response_success(res)
3497
3481
  check = Helpers.checkmark()
3498
3482
  str = "#{check} Experiment's is on: #{Cnvrg::Helpers.remote_url}/#{project.owner}/projects/#{project.slug}/experiments/#{res["result"]["exp_url"]}"
@@ -186,11 +186,14 @@ module Cnvrg
186
186
  desc 'data put DATASET_URL FILES_PREFIX', 'Upload selected files from local dataset directory to remote server'
187
187
  method_option :dir, :type => :string, :aliases => ["-d", "--dir"], :default => ''
188
188
  method_option :commit, :type => :string, :aliases => ["-c", "--commit"], :default => ''
189
+ method_option :message, :type => :string, :aliases => ["--message"], :desc => "create commit with message", :default => nil
189
190
  def put(dataset_url, *files)
190
191
  cli = Cnvrg::CLI.new()
191
192
  dir = options[:dir]
192
193
  commit = options[:commit]
193
- cli.data_put(dataset_url, files: files, dir: dir, commit: commit)
194
+ message = options[:message]
195
+
196
+ cli.data_put(dataset_url, files: files, dir: dir, commit: commit, message: message)
194
197
  end
195
198
 
196
199
  desc 'data clone_query --query=QUERY_SLUG DATASET_URL', 'Clone dataset with specific query'
@@ -20,6 +20,15 @@ module Cnvrg
20
20
  @dataset = dataset
21
21
  @base_resource = "users/#{owner}/datasets/#{dataset_slug}/"
22
22
  @downloader = @dataset.get_storage_client
23
+ @token_issue_time = Time.current
24
+ end
25
+
26
+ def refresh_storage_token
27
+ current_time = Time.current
28
+ if current_time - @token_issue_time > 3.hours
29
+ @downloader = @dataset.get_storage_client
30
+ @token_issue_time = Time.current
31
+ end
23
32
  end
24
33
 
25
34
  def check_file_sha1(filename, org_sha1, tag: 'conflict')
@@ -117,6 +126,7 @@ module Cnvrg
117
126
  def upload_multiple_files(commit_sha1, tree, threads: ParallelThreads, force: false, new_branch: false, prefix: '', partial_commit: nil, total: nil)
118
127
  begin
119
128
  Cnvrg::Logger.log_info("Sending Upload Files request")
129
+ refresh_storage_token
120
130
  error = nil
121
131
  upload_resp = nil
122
132
  10.times do
@@ -1007,6 +1017,7 @@ module Cnvrg
1007
1017
 
1008
1018
  def download_multiple_files_s3(files, project_home, conflict: false, progressbar: nil, read_only:false)
1009
1019
  begin
1020
+ refresh_storage_token
1010
1021
  parallel_options = {
1011
1022
  in_threads: ParallelThreads,
1012
1023
  isolation: true
@@ -108,7 +108,7 @@ module Cnvrg
108
108
  def exec_remote(command, commit_to_run, instance_type, image_slug,schedule,local_timestamp, grid,path_to_cmd,data, data_commit,periodic_sync,
109
109
  sync_before_terminate, max_time, ds_sync_options=0,output_dir=nil,data_query=nil,
110
110
  git_commit=nil, git_branch=nil, restart_if_stuck=nil, local_folders=nil,title=nil, datasets=nil, prerun: true, requirements: true, recurring: nil,
111
- email_notification_error: false, email_notification_success: false)
111
+ email_notification_error: false, email_notification_success: false, emails_to_notify: nil)
112
112
  response = Cnvrg::API.request("users/#{@owner}/projects/#{@project_slug}/experiment/remote", 'POST', {command: command, image_slug: image_slug,
113
113
  commit_sha1: commit_to_run,
114
114
  instance_type: instance_type,
@@ -124,7 +124,8 @@ module Cnvrg
124
124
  restart_if_stuck:restart_if_stuck, local_folders: local_folders, title:title,
125
125
  prerun: prerun, requirements: requirements, recurring: recurring,
126
126
  email_notification_error: email_notification_error,
127
- email_notification_success: email_notification_success})
127
+ email_notification_success: email_notification_success,
128
+ emails_to_notify: emails_to_notify})
128
129
 
129
130
  return response
130
131
  end
@@ -7,7 +7,7 @@ require 'cnvrg/result'
7
7
  module Cnvrg
8
8
  class Files
9
9
  ParallelThreads = Cnvrg::Helpers.parallel_threads
10
- VALID_FILE_NAME = /[\x00\\:\*\?\"<>\|]/
10
+ VALID_FILE_NAME = /[\x00\\\*\?\"<>\|]/
11
11
  LARGE_FILE=1024*1024*5
12
12
  MULTIPART_SPLIT=10000000
13
13
 
@@ -27,8 +27,16 @@ module Cnvrg
27
27
  @custom_progess = false
28
28
  @cli = cli
29
29
  @options = options
30
+ @token_issue_time = Time.current
30
31
  end
31
32
 
33
+ def refresh_storage_token
34
+ current_time = Time.current
35
+ if current_time - @token_issue_time > 3.hours
36
+ @client = @project.get_storage_client
37
+ @token_issue_time = Time.current
38
+ end
39
+ end
32
40
 
33
41
  def self.valid_file_name?(fullpath)
34
42
  VALID_FILE_NAME.match(fullpath).blank?
@@ -97,7 +105,13 @@ module Cnvrg
97
105
  files = res['files']
98
106
 
99
107
  #upload files
108
+ token_mutex = Mutex.new
100
109
  blob_ids = Parallel.map(files.keys, in_threads: ParallelThreads) do |file|
110
+
111
+ token_mutex.synchronize {
112
+ refresh_storage_token
113
+ }
114
+
101
115
  begin
102
116
  Cnvrg::Helpers.try_until_success{self.upload_single_file(files[file].merge(files_list[file]))}
103
117
  rescue => e
@@ -721,8 +735,15 @@ module Cnvrg
721
735
  in_threads: Cnvrg::Helpers.parallel_threads,
722
736
  isolation: true
723
737
  }
738
+
739
+ token_mutex = Mutex.new
740
+
724
741
  Parallel.map(files["keys"], parallel_options) do |f|
725
742
 
743
+ token_mutex.synchronize {
744
+ refresh_storage_token
745
+ }
746
+
726
747
  file_path = f["name"]
727
748
  if file_path.end_with? "/"
728
749
  # dir
@@ -1,3 +1,3 @@
1
1
  module Cnvrg
2
- VERSION = '1.6.27'
2
+ VERSION = '1.6.36'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cnvrg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.27
4
+ version: 1.6.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yochay Ettun
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-24 00:00:00.000000000 Z
13
+ date: 2020-06-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler