miga-base 0.7.16.3 → 0.7.16.8

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: 51173aea1659d14d35f485b22b4371bdf8cf9d16ae81c673d09c25cf3e36d1ac
4
- data.tar.gz: 4c6cbaed4bc9f0ea2f71d75ccfd22e3b0ac38e62c138166b768feb91c9a804b3
3
+ metadata.gz: ede9e4d8b2ae673b55e0b28f9e78292c42791c4ad400a02ef2c9f60065c1fc26
4
+ data.tar.gz: ff42e5a4f220774b7863f528fd334fa73a1acca0afcbb1a7f5e32dedd15bd1c7
5
5
  SHA512:
6
- metadata.gz: 6e00443678373cb3125e1d73d111ff909cfaa092c92ffd00089e2d122bad0f298133e4c4b2da00370d4ff56e3d1281b8e3ebe316e23fa675b73b217b6045e4e8
7
- data.tar.gz: f5d5f2981f86e0a79a1c96b81cdb76853eeacd11a14c23d630bcf067d390074d40273159b2b95c3ea33d88d1ca1c66bce19338809af410e48a0db2138d4974d3
6
+ metadata.gz: d02bc826d5dee9c84705d2f0fb30e1902cb5014385efe350fa2593347cd74f10007475cd3b5610a92fa9a93cf00378c508af7bcd36fb6ed3e60faad96b35eb49
7
+ data.tar.gz: c094b4bb67eddc15345cf53866b03154a85b39de09c10d8ba025a1c2411fb84c74d19f81f859b9004ecd6c9417a4ce9d3fd1cb07da24cb92de2164537faf8cb6
data/bin/miga CHANGED
@@ -7,4 +7,5 @@ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
7
7
  require 'miga'
8
8
  require 'miga/cli'
9
9
 
10
- MiGA::Cli.new(ARGV).launch
10
+ MiGA::Cli.new(ARGV).launch(true)
11
+
@@ -165,7 +165,7 @@ class MiGA::Cli::Action::GetDb < MiGA::Cli::Action
165
165
  def check_target
166
166
  return false if cli[:overwrite]
167
167
 
168
- file = File.expand_path(cli[:database], cli[:local])
168
+ file = File.expand_path(cli[:database].to_s, cli[:local])
169
169
  if Dir.exist? file
170
170
  warn "The target directory already exists: #{file}"
171
171
  true
@@ -8,7 +8,7 @@ class MiGA::Cli::Action::Run < MiGA::Cli::Action
8
8
  def parse_cli
9
9
  cli.defaults = { try_load: false, thr: 1, env: false }
10
10
  cli.parse do |opt|
11
- cli.opt_object(opt, [:project, :dataset_opt, :result])
11
+ cli.opt_object(opt, [:project, :dataset_opt, :result_opt])
12
12
  opt.on(
13
13
  '-t', '--threads INT', Integer,
14
14
  "Threads to use in the local run (by default: #{cli[:thr]})"
@@ -37,12 +37,18 @@ class MiGA::Cli::Action::Run < MiGA::Cli::Action
37
37
  cli[:thr] ||= ENV['CORES'].to_i unless ENV['CORES'].nil?
38
38
  cli[:result] = File.basename(cli[:result].to_s, '.bash').to_sym
39
39
  end
40
+ %i[project dataset result].each do |i|
41
+ cli[i] = nil if cli[i].nil? || cli[i].empty?
42
+ end
40
43
 
41
44
  # Unset dataset if the requested result is for projects
42
45
  if (MiGA::Project.RESULT_DIRS.keys + [:p]).include? cli[:result]
43
46
  cli[:dataset] = nil
44
47
  end
45
48
 
49
+ # Use virtual result if not explicitly passed
50
+ cli[:result] ||= cli[:dataset] ? :d : :p
51
+
46
52
  # Load project
47
53
  p = cli.load_project
48
54
 
@@ -56,10 +56,11 @@ module MiGA::Cli::OptHelper
56
56
  # - :project_type To allow (optionally) a type of project
57
57
  # - :project_type_req To require a type of project
58
58
  # - :result To require a type of project or dataset result
59
+ # - :result_opt To allow (optionally) a type of result
59
60
  # - :result_dataset To require a type of dataset result
60
61
  # - :result_project To require a type of project result
61
- # The options :result, :result_dataset, and :result_project are mutually
62
- # exclusive
62
+ # The options :result, :result_opt, :result_dataset, and :result_project
63
+ # are mutually exclusive
63
64
  def opt_object(opt, what = [:project, :dataset])
64
65
  what.each do |w|
65
66
  case w
@@ -82,10 +83,10 @@ module MiGA::Cli::OptHelper
82
83
  "#{req}Type of #{obj}. Recognized types include:",
83
84
  *klass.KNOWN_TYPES.map { |k, v| "~ #{k}: #{v[:description]}" }
84
85
  ) { |v| self[:type] = v.downcase.to_sym }
85
- when :result
86
+ when :result, :result_opt
86
87
  opt.on(
87
88
  '-r', '--result STRING',
88
- '(Mandatory) Name of the result',
89
+ "#{"(Mandatory) " if w == :result}Name of the result",
89
90
  'Recognized names for dataset-specific results include:',
90
91
  *MiGA::Dataset.RESULT_DIRS.keys.map { |n| " ~ #{n}" },
91
92
  'Recognized names for project-wide results include:',
@@ -61,10 +61,14 @@ class MiGA::MiGA
61
61
  end
62
62
 
63
63
  # Estimate timing
64
- unless total.nil? || @_advance_time[:last].nil? || @_advance_time[:n] == n
65
- this_time = Time.now - @_advance_time[:last]
66
- @_advance_time[:avg] ||= this_time / (n - @_advance_time[:n])
67
- @_advance_time[:avg] = 0.99 * @_advance_time[:avg] + 0.01 * this_time
64
+ adv_n = n - @_advance_time[:n]
65
+ unless total.nil? || @_advance_time[:last].nil? || adv_n <= 0
66
+ if adv_n.to_f/n > 0.001
67
+ this_time = Time.now - @_advance_time[:last]
68
+ this_avg = this_time / adv_n
69
+ @_advance_time[:avg] ||= this_avg
70
+ @_advance_time[:avg] = 0.9 * @_advance_time[:avg] + 0.1 * this_avg
71
+ end
68
72
  end
69
73
  @_advance_time[:last] = Time.now
70
74
  @_advance_time[:n] = n
@@ -78,9 +82,10 @@ class MiGA::MiGA
78
82
  if @_advance_time[:avg].nil?
79
83
  ''
80
84
  else
81
- left_time = @_advance_time[:avg] * (total - n) / 60
85
+ left_time = @_advance_time[:avg] * (total - n) / 60 # <- in minutes
82
86
  left_time < 0.01 ? ' ' :
83
87
  left_time < 1 ? ('%.0fs left' % (left_time * 60)) :
88
+ left_time > 1440 ? ('%.1fd left' % (left_time / 1440)) :
84
89
  left_time > 60 ? ('%.1fh left' % (left_time / 60)) :
85
90
  ('%.1fm left' % left_time)
86
91
  end
@@ -8,7 +8,7 @@ module MiGA
8
8
  # - Float representing the major.minor version.
9
9
  # - Integer representing gem releases of the current version.
10
10
  # - Integer representing minor changes that require new version number.
11
- VERSION = [0.7, 16, 3]
11
+ VERSION = [0.7, 16, 8]
12
12
 
13
13
  ##
14
14
  # Nickname for the current major.minor version.
@@ -16,7 +16,7 @@ module MiGA
16
16
 
17
17
  ##
18
18
  # Date of the current gem release.
19
- VERSION_DATE = Date.new(2020, 10, 27)
19
+ VERSION_DATE = Date.new(2020, 11, 22)
20
20
 
21
21
  ##
22
22
  # Reference of MiGA.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miga-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16.3
4
+ version: 0.7.16.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis M. Rodriguez-R
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-27 00:00:00.000000000 Z
11
+ date: 2020-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons