rbbt-util 5.23.22 → 5.23.23

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
  SHA1:
3
- metadata.gz: f00bbaf07372fc3c72d60b438ce701b6336e21bb
4
- data.tar.gz: f5e9cbffdc19992c1f2d606e7cef8963f84df2b0
3
+ metadata.gz: 9196b9af288157b75110a6bd4126f7a06caffee0
4
+ data.tar.gz: 666c7717915b6684ba727d70110a1ca5dd2cca1b
5
5
  SHA512:
6
- metadata.gz: 8d087babf2c286d041e1585db266cd8abd1a39672eab0a965f772b00b9866eafb0ab27bb36242bb4fe4e344733d4f7a5a26033013a20d4f64524daeae0a493db
7
- data.tar.gz: 28b6c11840f431d28c6e6bd32b75d72ce6eced2cf12d4f53661e5d316ff893c6c1e9e8d19d73cc78a235798ed9faf64dd389300e9be6e12decf743b335e31266
6
+ metadata.gz: 21fefbcb643e6ebde8896422b5003deb348c9a9fffbee2b0935aaafd766853bc234ffe37635eaec130718ba5862951206ffe8e8974b3bfc1498b324421ea355d
7
+ data.tar.gz: '0939898fa00d8b3120e8497abc688aae9832e32a1d276703eca93fd505ab441e2d4284c49658f3d43708d66262034bd479f2b1e7d55f64528c508c834d4d3cad'
@@ -72,6 +72,8 @@ module Misc
72
72
  tokens = {
73
73
  "s" => (1),
74
74
  "min" => (60),
75
+ "''" => (1),
76
+ "'" => (60),
75
77
  "h" => (60 * 60),
76
78
  "d" => (60 * 60 * 24),
77
79
  "w" => (60 * 60 * 24 * 7),
data/lib/rbbt/util/tar.rb CHANGED
@@ -85,14 +85,21 @@ module Misc
85
85
 
86
86
  def self._untar_cmd(io, destination)
87
87
  FileUtils.mkdir_p destination unless File.exist? destination
88
- CMD.cmd("tar xvf - -C '#{destination}'", :in => io)
88
+ CMD.cmd_log("tar xvf - -C '#{destination}'", :in => io)
89
89
  nil
90
90
  end
91
91
 
92
92
  # untars the given IO into the specified
93
93
  # directory
94
94
  def self.untar(io, destination)
95
- return _untar_cmd(io, destination)
95
+ io = io.find if Path === io
96
+ if String === io and File.exists?(io)
97
+ Open.open(io) do |f|
98
+ untar(f, destination)
99
+ end
100
+ else
101
+ return _untar_cmd(io, destination)
102
+ end
96
103
  end
97
104
  end
98
105
 
@@ -1028,6 +1028,7 @@ module Workflow
1028
1028
  end
1029
1029
 
1030
1030
  TAG = ENV["RBBT_INPUT_JOBNAME"] == "true" ? :inputs : :hash
1031
+ DEBUG_JOB_HASH = ENV["RBBT_DEBUG_JOB_HASH"] == 'true'
1031
1032
  def step_path(taskname, jobname, inputs, dependencies, extension = nil)
1032
1033
  raise "Jobname makes an invalid path: #{ jobname }" if jobname.include? '..'
1033
1034
  if inputs.length > 0 or dependencies.any?
@@ -1039,7 +1040,7 @@ module Workflow
1039
1040
  key_obj = {:inputs => clean_inputs, :dependencies => deps_str }
1040
1041
  key_str = Misc.obj2str(key_obj)
1041
1042
  hash_str = Misc.digest(key_str)
1042
- #Log.debug "Hash for '#{[taskname, jobname] * "/"}' #{hash_str} for #{key_str}"
1043
+ Log.debug "Hash for '#{[taskname, jobname] * "/"}' #{hash_str} for #{key_str}" if DEBUG_JOB_HASH
1043
1044
  jobname + '_' << hash_str
1044
1045
  when :inputs
1045
1046
  all_inputs = {}
@@ -27,26 +27,48 @@ module Workflow
27
27
 
28
28
  def self.load_inputs(dir, input_names, input_types)
29
29
  inputs = {}
30
- dir = Path.setup(dir.dup)
31
- input_names.each do |input|
32
- file = dir[input].find
33
- file = dir.glob(input.to_s + ".*").first if file.nil? or not file.exists?
34
- Log.debug "Trying #{ input }: #{file}"
35
- next unless file and file.exists?
36
-
37
- case input_types[input]
38
- when :tsv, :array, :text, :file
39
- Log.debug "Pointing #{ input } to #{file}"
40
- inputs[input.to_sym] = file
41
- when :boolean
42
- inputs[input.to_sym] = (file.read.strip == 'true')
43
- else
44
- Log.debug "Loading #{ input } from #{file}"
45
- inputs[input.to_sym] = file.read.strip
30
+ if File.exists?(dir) && ! File.directory?(dir)
31
+ Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
32
+ tarfile = dir
33
+ digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
34
+ tmpdir = Rbbt.tmp.input_bundle[digest].find
35
+ Misc.untar(tarfile, tmpdir) unless File.exists? tmpdir
36
+ files = tmpdir.glob("*")
37
+ if files.length == 1 && File.directory?(files.first)
38
+ tmpdir = files.first
46
39
  end
40
+ load_inputs(tmpdir, input_names, input_types)
41
+ else
42
+ dir = Path.setup(dir.dup)
43
+ input_names.each do |input|
44
+ file = dir[input].find
45
+ file = dir.glob(input.to_s + ".*").first if file.nil? or not file.exists?
46
+ Log.debug "Trying #{ input }: #{file}"
47
+ next unless file and file.exists?
48
+
49
+ case input_types[input]
50
+ when :file
51
+ Log.debug "Pointing #{ input } to #{file}"
52
+ inputs[input.to_sym] = file
53
+ when :text
54
+ Log.debug "Reading #{ input } from #{file}"
55
+ inputs[input.to_sym] = Open.read(file)
56
+ when :array
57
+ Log.debug "Reading array #{ input } from #{file}"
58
+ inputs[input.to_sym] = Open.read(file).split("\n")
59
+ when :tsv
60
+ Log.debug "Opening tsv #{ input } from #{file}"
61
+ inputs[input.to_sym] = TSV.open(file)
62
+ when :boolean
63
+ inputs[input.to_sym] = (file.read.strip == 'true')
64
+ else
65
+ Log.debug "Loading #{ input } from #{file}"
66
+ inputs[input.to_sym] = file.read.strip
67
+ end
47
68
 
69
+ end
70
+ IndiferentHash.setup(inputs)
48
71
  end
49
- IndiferentHash.setup(inputs)
50
72
  end
51
73
 
52
74
  def example_inputs(task_name, example)
@@ -606,7 +606,7 @@ EOF
606
606
  def test_time_stamp
607
607
  assert_equal 10, Misc.timespan('10')
608
608
  assert_equal 10, Misc.timespan('10s')
609
- assert_equal 60, Misc.timespan('1m')
609
+ assert_equal 60, Misc.timespan('1min')
610
610
  assert_equal 60*60*24, Misc.timespan('1d')
611
611
  assert_equal 60*60*24, Misc.timespan('1d')
612
612
  end
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.23.22
4
+ version: 5.23.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake