miga-base 0.5.7.3 → 0.5.10.0

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: fb263d4c4556c44c22d5a5819f629bfc55a6cd041082a30b6d468ed6b5c8acb2
4
- data.tar.gz: 145db67bc03d30a4d868a7684d682ac5c43463eeed0ea06bb4c8f0889ad3b752
3
+ metadata.gz: a3fc33951911397d8c6305f0bf893cbc373c7ca09f55531c95adf15439e9a938
4
+ data.tar.gz: e1fd8f3d96c50770d2dc029fd9285ff79e536df888097d89705087d3a2c9a5d0
5
5
  SHA512:
6
- metadata.gz: 677b3f0cbf9cc5432cff0468f9707a08e81a84867f244bb7960c971e1472c045ec5372a7f8d572844460d087a4a7941b8601139669d5bcf21093950305abf9c7
7
- data.tar.gz: d96f0de11e4790793098fb9f5709e5f2c51df5c5789b14951b8764b2d4ceb9be278f045738f21d0ce5e771b1c01e563c6802f0eec6f30e9cdf20f28162d19fba
6
+ metadata.gz: be1241558fc879d2c6e5e6c2cb36432c004b7b4264116d3a2ff9ddc1cf5354efdfe001362a23145a6cc341ee9133d00e181184624a6adf4e40199e0d22b6ffb9
7
+ data.tar.gz: f2f14e380a596510f7d2803cac7c41069bbe0a9e2b5d1fd565d57daebbaebfdcd9bf71d1065fb92dfca63e278ff9647cc032abeaea3302ef79c790f481b90bfd
@@ -18,11 +18,19 @@ class MiGA::Cli::Action::Ls < MiGA::Cli::Action
18
18
  '-p', '--processing',
19
19
  'Print information on processing advance'
20
20
  ) { |v| cli[:processing] = v }
21
+ opt.on(
22
+ '-t', '--task-status',
23
+ 'Print the status of each processing step'
24
+ ) { |v| cli[:taskstatus] = v }
21
25
  opt.on(
22
26
  '-m', '--metadata STRING',
23
27
  'Print name and metadata field only',
24
- 'If set, ignores -i and assumes --tab'
28
+ 'If set, ignores --info and forces --tab (without header)'
25
29
  ) { |v| cli[:datum] = v }
30
+ opt.on(
31
+ '-f', '--fields STR1,STR2,STR3', Array,
32
+ 'Comma-delimited metadata fields to print'
33
+ ) { |v| cli[:fields] = v }
26
34
  opt.on(
27
35
  '--tab',
28
36
  'Return a tab-delimited table'
@@ -41,24 +49,45 @@ class MiGA::Cli::Action::Ls < MiGA::Cli::Action
41
49
  def perform
42
50
  ds = cli.load_and_filter_datasets(cli[:silent])
43
51
  exit(ds.empty? ? 1 : 0) if cli[:silent]
44
- io = cli[:output].nil? ? $stdout : File.open(cli[:output], 'w')
45
52
  if !cli[:datum].nil?
46
- ds.each do |d|
47
- v = d.metadata[cli[:datum]]
48
- cli.puts(io, "#{d.name}\t#{v.nil? ? '?' : v}")
53
+ cli[:tabular] = true
54
+ format_table(ds, [nil,nil]) { |d| [d.name, d.metadata[cli[:datum]]] }
55
+ elsif !cli[:fields].nil?
56
+ format_table(ds, [:name] + cli[:fields]) do |d|
57
+ [d.name] + cli[:fields].map { |f| d.metadata[f] }
49
58
  end
50
59
  elsif cli[:info]
51
- cli.table(Dataset.INFO_FIELDS, ds.map { |d| d.info }, io)
60
+ format_table(ds, Dataset.INFO_FIELDS) { |d| d.info }
52
61
  elsif cli[:processing]
53
62
  comp = %w[- done queued]
54
- cli.table(
55
- [:name] + MiGA::Dataset.PREPROCESSING_TASKS,
56
- ds.map { |d| [d.name] + d.profile_advance.map { |i| comp[i] } },
57
- io
58
- )
63
+ format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d|
64
+ [d.name] + d.profile_advance.map { |i| comp[i] }
65
+ end
66
+ elsif cli[:taskstatus]
67
+ format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d|
68
+ [d.name] + d.results_status.values
69
+ end
59
70
  else
60
- ds.each { |d| cli.puts(io, d.name) }
71
+ cli[:tabular] = true
72
+ format_table(ds, [nil]) { |d| [d.name] }
61
73
  end
74
+ end
75
+
76
+ private
77
+
78
+ def format_table(ds, header, &blk)
79
+ io = cli[:output].nil? ? $stdout : File.open(cli[:output], 'w')
80
+ cli.say 'Collecting metadata'
81
+ k = 0
82
+ cli.table(
83
+ header,
84
+ ds.map do |d|
85
+ cli.advance('Datasets:', k += 1, ds.size, false)
86
+ blk[d]
87
+ end,
88
+ io
89
+ )
90
+ cli.say ''
62
91
  io.close unless cli[:output].nil?
63
92
  end
64
93
  end
@@ -16,14 +16,14 @@ module MiGA::Cli::ObjectsHelper
16
16
  ##
17
17
  # Load the dataset defined in the CLI
18
18
  # If +silent=true+, it allows failures silently
19
- def load_dataset(silent = false)
20
- return @objects[:dataset] unless @objects[:dataset].nil?
21
- ensure_par(dataset: '-D')
22
- @objects[:dataset] = load_project.dataset(self[:dataset])
23
- if !silent && @objects[:dataset].nil?
24
- raise "Cannot load dataset: #{self[:dataset]}"
19
+ def load_dataset(silent = false, name = nil)
20
+ if name.nil?
21
+ ensure_par(dataset: '-D')
22
+ name = self[:dataset]
25
23
  end
26
- return @objects[:dataset]
24
+ d = load_project.dataset(name)
25
+ raise "Cannot load dataset: #{self[:dataset]}" if !silent && d.nil?
26
+ return d
27
27
  end
28
28
 
29
29
  ##
@@ -38,8 +38,15 @@ module MiGA::Cli::ObjectsHelper
38
38
  def load_and_filter_datasets(silent = false)
39
39
  return @objects[:filtered_datasets] unless @objects[:filtered_datasets].nil?
40
40
  say 'Listing datasets'
41
- ds = self[:dataset].nil? ?
42
- load_project.datasets : [load_dataset(silent)].compact
41
+ ds = if ! self[:dataset].nil?
42
+ [load_dataset(silent)].compact
43
+ elsif ! self[:ds_list].nil?
44
+ File.readlines(self[:ds_list]).map do |i|
45
+ load_dataset(silent, i.chomp)
46
+ end.compact
47
+ else
48
+ load_project.datasets
49
+ end
43
50
  k = 0
44
51
  n = ds.size
45
52
  ds.select! do |d|
@@ -143,6 +143,10 @@ module MiGA::Cli::OptHelper
143
143
  raise "Internal error: Unrecognized option: #{w}"
144
144
  end
145
145
  end
146
+ opt.on(
147
+ '--ds-list FILE',
148
+ 'File containing a list of dataset names, one per line'
149
+ ) { |v| self[:ds_list] = v }
146
150
  opt.on(
147
151
  '--dataset-k INTEGER', Integer,
148
152
  'Use only the k-th dataset in the list'
@@ -9,7 +9,8 @@ module MiGA::Common::Format
9
9
  # Tabulates an +values+, and Array of Arrays, all with the same number of
10
10
  # entries as +header+. Returns an Array of String, one per line.
11
11
  def tabulate(header, values, tabular = false)
12
- fields = [header.map(&:to_s)]
12
+ fields = []
13
+ fields << header.map(&:to_s) unless tabular && header.all?(&:nil?)
13
14
  fields << fields.first.map { |h| h.gsub(/\S/, '-') } unless tabular
14
15
  fields += values.map { |r| r.map { |cell| cell.nil? ? '?' : cell.to_s } }
15
16
  clen = tabular ? Array.new(header.size, 0) :
@@ -64,7 +64,7 @@ module MiGA::Dataset::Result
64
64
  # execution order). This typically corresponds to the result used as the
65
65
  # initial input. Passes +save+ to #add_result.
66
66
  def first_preprocessing(save = false)
67
- @@PREPROCESSING_TASKS.find do |t|
67
+ @first_processing ||= @@PREPROCESSING_TASKS.find do |t|
68
68
  not ignore_task?(t) and not add_result(t, save).nil?
69
69
  end
70
70
  end
@@ -126,6 +126,8 @@ module MiGA::Dataset::Result
126
126
 
127
127
  ##
128
128
  # Returns the status of +task+. The status values are symbols:
129
+ # - -: the task is upstream from the initial input
130
+ # - ignore_empty: the dataset has no data
129
131
  # - ignore_inactive: the dataset is inactive
130
132
  # - ignore_force: forced to ignore by metadata
131
133
  # - ignore_project: incompatible project
@@ -136,8 +138,13 @@ module MiGA::Dataset::Result
136
138
  # - complete: a task with registered results
137
139
  # - pending: a task queued to be performed
138
140
  def result_status(task)
139
- if not get_result(task).nil?
141
+ if first_preprocessing.nil?
142
+ :ignore_empty
143
+ elsif not get_result(task).nil?
140
144
  :complete
145
+ elsif @@PREPROCESSING_TASKS.index(task) <
146
+ @@PREPROCESSING_TASKS.index(first_preprocessing)
147
+ :-
141
148
  elsif ignore_task?(task)
142
149
  if not is_active?
143
150
  :ignore_inactive
data/lib/miga/version.rb CHANGED
@@ -10,7 +10,7 @@ module MiGA
10
10
  # - Float representing the major.minor version.
11
11
  # - Integer representing gem releases of the current version.
12
12
  # - Integer representing minor changes that require new version number.
13
- VERSION = [0.5, 7, 3]
13
+ VERSION = [0.5, 10, 0]
14
14
 
15
15
  ##
16
16
  # Nickname for the current major.minor version.
@@ -18,7 +18,7 @@ module MiGA
18
18
 
19
19
  ##
20
20
  # Date of the current gem release.
21
- VERSION_DATE = Date.new(2020, 2, 8)
21
+ VERSION_DATE = Date.new(2020, 2, 25)
22
22
 
23
23
  ##
24
24
  # 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.5.7.3
4
+ version: 0.5.10.0
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-02-08 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons