rbbt-util 5.26.116 → 5.26.117

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e3981775c0531bd71ddb841401d78b7e84f83c44579347b8da42bb71f9c3a67
4
- data.tar.gz: 791d1a58540888c2a9a338d706f1188cc684a6b2bc50dce8fc4c38169de898f0
3
+ metadata.gz: e59ee0bcb0a764c4bc10206585d0a26c7a59f881cca10dcaf3fbf693b0ed9208
4
+ data.tar.gz: 929459e6de52b9ba2f13b7fa55c2aac38a78ff13c6990f63143c68e2b35a6af8
5
5
  SHA512:
6
- metadata.gz: 44efa5d106893dee737ef79c17c0a655ff1fa63e924045d433fcc769f73fe5470bef22de23d50561559c97361716329429dbb26b8dce366c5cc875fa1dcc67fa
7
- data.tar.gz: 7350980369fd646a5e9992d4683a15c7c944627f4aa5f5753b3691c21783fac6bcf76bf9021cc13192a92a0afeea0b06a7259917563e8fdb7df10411c0279d66
6
+ metadata.gz: c3d7ed4da1ec8ac8b63e1a91bccbb87b60a1d6c60fe3807f4c9f85f8c1dc82a1fd206382175184278dac40bce536a732e3da38383c0828e446b10cfcf647ac3d
7
+ data.tar.gz: fbed1b9e52b78a3f56eda4e5a0c0b39c9f21f8ff8faa66725ebaf2c11d27e3c71d4d630ce5acd7616dd86697d82114859fd46e5b45a256cad6364e800c045934
@@ -1,3 +1,5 @@
1
+ # This is used by rbbt-rest when issuing a new job
2
+
1
3
  $rest_cache_semaphore = "/REST_SEMAPHORE"
2
4
  parallel_rest_jobs = Rbbt::Config.get('parallel_rest_jobs', :parallel_rest_jobs, :rest_jobs, :default => 2)
3
5
  begin
@@ -5,6 +5,13 @@ module Entity
5
5
 
6
6
  UNPERSISTED_PREFIX = "entity_unpersisted_property_"
7
7
 
8
+ class DontPersist < Exception
9
+ attr_accessor :payload
10
+ def self.initialize(payload)
11
+ @payload = payload
12
+ end
13
+ end
14
+
8
15
  class << self
9
16
  attr_accessor :formats, :entity_property_cache
10
17
  end
@@ -203,8 +210,12 @@ module Entity
203
210
  persist_options = options
204
211
  persist_options = persist_options.merge(:other => {:args => args}) if args and args.any?
205
212
 
206
- Persist.persist(persist_name, type, persist_options.merge(:persist => true)) do
207
- self.send(orig_name, *args)
213
+ begin
214
+ Persist.persist(persist_name, type, persist_options.merge(:persist => true)) do
215
+ self.send(orig_name, *args)
216
+ end
217
+ rescue DontPersist
218
+ $!.payload
208
219
  end
209
220
  end
210
221
  end
@@ -295,6 +295,8 @@ EOF
295
295
 
296
296
  target = File.expand_path(sync)
297
297
  coda +=<<-EOF
298
+
299
+ # Sync data to target location
298
300
  mkdir -p "$(dirname '#{target}')"
299
301
  rsync -avztAXHP --copy-unsafe-links "#{source}/" "#{target}/" &>> #{fsync}
300
302
  sync_es="$?"
@@ -310,6 +312,9 @@ fi
310
312
  if singularity
311
313
  coda +=<<-EOF
312
314
  singularity exec -e -C -H "$CONTAINER_DIR" "$SINGULARITY_IMG" rm -v /dev/shm/sem.*.{in,out,process} /dev/shm/sem.Session-PID.*.sem 2> /dev/null >> #{fsync}
315
+
316
+
317
+ # Clean container directory
313
318
  if [ $exit_status == '0' -a $sync_es == '0' ]; then
314
319
  singularity exec -e -C -H "$CONTAINER_DIR" "$SINGULARITY_IMG" rbbt system clean -f &>> #{fsync}
315
320
  singularity exec -e -C -H "$CONTAINER_DIR" "$SINGULARITY_IMG" rm -Rfv .rbbt/var/jobs &>> #{fsync}
@@ -41,12 +41,19 @@ module Persist
41
41
  return false if not Open.exists? path
42
42
  return false if TrueClass === persist_options[:update]
43
43
 
44
+ expiration = persist_options[:expiration]
45
+ if expiration
46
+ seconds = Misc.timespan(expiration)
47
+ patht = Open.mtime(path)
48
+ return false if Time.now > patht + seconds
49
+ end
50
+
44
51
  check = persist_options[:check]
45
52
  return true if check.nil?
46
53
 
47
54
  missing = check.reject{|file| Open.exists?(file) }
48
55
  return false if missing.any?
49
-
56
+
50
57
  return true unless ENV["RBBT_UPDATE"]
51
58
 
52
59
  if Array === check
@@ -497,7 +504,7 @@ module LocalPersist
497
504
  attr_accessor :local_persist_dir
498
505
 
499
506
  def local_persist_dir
500
- @local_persist_dir ||= Rbbt.var.cache.persistence if defined? Rbbt
507
+ @local_persist_dir ||= Rbbt.var.cache.persistence.find(:lib) if defined? Rbbt
501
508
  @local_persist_dir
502
509
  end
503
510
 
@@ -505,13 +512,19 @@ module LocalPersist
505
512
  @local_persist_dir = value
506
513
  end
507
514
 
508
- def local_persist(name, type = nil, options= {}, persist_options = nil, &block)
515
+ def self.local_persist(name, type = nil, options= {}, persist_options = nil, &block)
509
516
  persist_options ||= {}
510
- persist_options = {:dir => local_persist_dir}.merge persist_options
517
+ persist_options = {:dir => Rbbt.var.cache.persistence.find(:lib)}.merge persist_options
511
518
  persist_options[:other] = options
512
519
  Persist.persist(name, type, persist_options, &block)
513
520
  end
514
521
 
522
+ def local_persist(name, type = nil, options= {}, persist_options = nil, &block)
523
+ persist_options ||= {}
524
+ persist_options = {:dir => local_persist_dir}.merge persist_options
525
+ self.local_persist(name, type, options, persist_options, &block)
526
+ end
527
+
515
528
  def local_persist_tsv(source, name, opt = {}, options= {}, &block)
516
529
  Persist.persist_tsv(source, name, opt, options.merge({:dir => local_persist_dir, :persist => true}), &block)
517
530
  end
@@ -86,29 +86,36 @@ module Resource
86
86
  lock_filename = nil # it seems like this was locked already.
87
87
 
88
88
  Misc.lock lock_filename do
89
- Net::HTTP.get_response URI(url) do |response|
90
- case response
91
- when Net::HTTPSuccess, Net::HTTPOK
92
- Misc.sensiblewrite(final_path) do |file|
93
- response.read_body do |chunk|
94
- file.write chunk
89
+ uri = URI(url)
90
+
91
+ http = Net::HTTP.new(uri.host, uri.port)
92
+ request = Net::HTTP::Get.new(uri.request_uri)
93
+ timeout = 60 * 10
94
+ Net::HTTP.start(uri.host, uri.port, :timeout => timeout, :read_timeout => timeout, :open_timeout => timeout) do |http|
95
+ http.request request do |response|
96
+ case response
97
+ when Net::HTTPSuccess, Net::HTTPOK
98
+ Misc.sensiblewrite(final_path) do |file|
99
+ response.read_body do |chunk|
100
+ file.write chunk
101
+ end
95
102
  end
96
- end
97
- when Net::HTTPRedirection, Net::HTTPFound
98
- location = response['location']
99
- Log.debug("Feching directory from: #{location}. Into: #{final_path}")
100
- FileUtils.mkdir_p final_path unless File.exist? final_path
101
- TmpFile.with_file do |tmp_dir|
102
- Misc.in_dir tmp_dir do
103
- CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
103
+ when Net::HTTPRedirection, Net::HTTPFound
104
+ location = response['location']
105
+ Log.debug("Feching directory from: #{location}. Into: #{final_path}")
106
+ FileUtils.mkdir_p final_path unless File.exist? final_path
107
+ TmpFile.with_file do |tmp_dir|
108
+ Misc.in_dir tmp_dir do
109
+ CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
110
+ end
111
+ FileUtils.mv tmp_dir, final_path
104
112
  end
105
- FileUtils.mv tmp_dir, final_path
113
+ when Net::HTTPInternalServerError
114
+ @server_missing_resource_cache << url
115
+ raise "Resource Not Found"
116
+ else
117
+ raise "Response not understood: #{response.inspect}"
106
118
  end
107
- when Net::HTTPInternalServerError
108
- @server_missing_resource_cache << url
109
- raise "Resource Not Found"
110
- else
111
- raise "Response not understood: #{response.inspect}"
112
119
  end
113
120
  end
114
121
  end
@@ -4,6 +4,7 @@ module Path
4
4
  file = caller.reject{|l|
5
5
  l =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
6
6
  l =~ /rbbt\/resource\/path\.rb/ or
7
+ l =~ /rbbt\/persist.rb/ or
7
8
  l =~ /rbbt\/util\/misc\.rb/ or
8
9
  l =~ /progress-monitor\.rb/
9
10
  }.first.sub(/\.rb[^\w].*/,'.rb') if file.nil?
@@ -67,7 +67,7 @@ module TSV
67
67
  end
68
68
 
69
69
  first_line = parser.first_line
70
- first_line = nil if first_line.empty?
70
+ first_line = nil if first_line == ""
71
71
 
72
72
  lines << first_line
73
73
  key_fields << parser.key_field
@@ -46,8 +46,8 @@ module Workflow
46
46
  end
47
47
 
48
48
  def self.require_remote_workflow(wf_name, url)
49
- require 'rbbt/rest/client'
50
- eval "Object::#{wf_name} = WorkflowRESTClient.new '#{ url }', '#{wf_name}'"
49
+ require 'rbbt/workflow/remote/client'
50
+ eval "Object::#{wf_name} = WorkflowRemoteClient.new '#{ url }', '#{wf_name}'"
51
51
  end
52
52
 
53
53
  def self.require_remote_workflow(wf_name, url)
@@ -682,14 +682,15 @@ module Workflow
682
682
  end
683
683
 
684
684
  def self.process_remote_tasks(remote_tasks)
685
- require 'rbbt/rest/client'
685
+ require 'rbbt/workflow/remote/client'
686
686
  remote_tasks.each do |workflow, info|
687
687
  wf = Workflow.require_workflow workflow
688
688
  wf.remote_tasks ||= {}
689
689
  IndiferentHash.setup wf.remote_tasks
690
690
  info.each do |remote, tasks|
691
- remote_wf = WorkflowRESTClient.new remote, workflow
691
+ remote_wf = WorkflowRemoteClient.new remote, workflow
692
692
  tasks.each do |task|
693
+ Log.debug "Add remote task #{task} in #{wf} using #{remote_wf.url}"
693
694
  wf.remote_tasks[task.to_sym] = remote_wf
694
695
  end
695
696
  end
@@ -191,8 +191,10 @@ class WorkflowRemoteClient
191
191
  def path
192
192
  if @url
193
193
  Misc.add_GET_param(@url, "_format", "raw")
194
- else
194
+ elsif @base_name
195
195
  [base_url, task, @base_name + '-' + Misc.fingerprint(inputs)] * "/"
196
+ else
197
+ nil
196
198
  end
197
199
  end
198
200
 
@@ -34,6 +34,8 @@ force = options.delete :force
34
34
  dirty = options.delete :dirty
35
35
  time = options.delete :older
36
36
 
37
+ ENV["RBBT_UPDATE"] = 'true' if dirty
38
+
37
39
  time = Misc.timespan time, 'd' if time
38
40
 
39
41
  puts Log.color(:magenta, "# System clean")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.26.116
4
+ version: 5.26.117
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-16 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake