batch_experiment 0.1.0 → 1.0.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
  SHA1:
3
- metadata.gz: 4d594a77b4909c00eb2c07a05dbc6c4f0cc68c9a
4
- data.tar.gz: 979f0d1800486061aff5d9a1728e55790e675e34
3
+ metadata.gz: e6db331d43fbfee1847a2385bc1c90616433451b
4
+ data.tar.gz: 0b5b00e526fe8ff5d78d32991ee79e2655d24c5c
5
5
  SHA512:
6
- metadata.gz: cc0d896402fc7820e7c1f2741ae9e07ffdea6ab14edc3156e9bdcd5d3f4c24b71e753087e1980fdb97c8b85006cc2c7ef1bbb3bdad3a181b0853a7c94f76ea82
7
- data.tar.gz: bfde027e77f78360a9728eacca5075a00a2b59e47cd0224e692c2e44bc6118e942c93c4913a0bd65a5861612191f92deb4402052440037e416391c9433d2629c
6
+ metadata.gz: 41b4f4c3866c68c86677630466e88eb574ca0ccd417a55c94eaa378d55c368673f07c5bd6dfb4018ac69d1519c730e8d6b41cc8d0c9e6ac58e51e12684435322
7
+ data.tar.gz: babb03ca7415332843d231e21e30a9ecea32f3da5792fc48ccc5023c4c31eaf374c48091869e9a42c45e83b01f8d6647ea70e384d14fdecd511cdac9fc580be3
@@ -0,0 +1,8 @@
1
+ IN THE beginning [before all time] was the Word (Christ), and the Word was with God, and the Word was God Himself.
2
+ He was present originally with God.
3
+ All things were made and came into existence through Him, and without Him was not even one thing made that has come into being.
4
+ In Him was Life, and the Life was the Light of men.
5
+ And the Light shines on in the darkness, for the darkness has never overpowered it [put it out or absorbed it or appropriated it, and is unreceptive to it].
6
+ There came a man sent from God, whose name was John.
7
+ This man came to witness, that he might testify of the Light, that all men might believe in it [adhere to it, trust it, and rely upon it] through him.
8
+ He was not the Light himself, but came that he might bear witness regarding the Light.
@@ -0,0 +1,42 @@
1
+ #!/bin/ruby
2
+
3
+ require 'batch_experiment'
4
+ require 'batch_experiment/sample_extractors'
5
+
6
+ comms_info = [{
7
+ command: 'cat X',
8
+ pattern: 'X',
9
+ extractor: BatchExperiment::FirstLineExtractor,
10
+ prefix: 'cat',
11
+ }, {
12
+ command: 'echo y',
13
+ pattern: 'y',
14
+ extractor: BatchExperiment::FirstLineExtractor,
15
+ prefix: 'echo',
16
+ }, {
17
+ command: 'wc FILE',
18
+ pattern: 'FILE',
19
+ extractor: BatchExperiment::WcExtractor,
20
+ prefix: 'wc',
21
+ }]
22
+
23
+ execution_info = {
24
+ # IDs of the CPU cores that can be used for executing tests.
25
+ cpus_available: [1, 2, 3],
26
+ # Maximum number of seconds that a command can run. After this a kill command
27
+ # (TERM signal) will be issued.
28
+ timeout: 5,
29
+ }
30
+
31
+ conf = {
32
+ # The name of the file where will be written the CSV data.
33
+ csvfname: 'example.csv',
34
+ # The columns will be ordered by command. All the columns of the first
35
+ # command before the one from the second and so on.
36
+ ic_columns: false,
37
+ }
38
+
39
+ files = ['bible.txt', 'taoteching.txt']
40
+
41
+ BatchExperiment::experiment(comms_info, execution_info, conf, files)
42
+
@@ -1,34 +1,16 @@
1
1
  #!/bin/ruby
2
2
 
3
3
  require 'batch_experiment'
4
- require 'batch_experiment/sample_extractors'
5
4
 
6
- comms_info = [{
7
- # String with command to be executed. Must have 'pattern' as substring.
8
- command: 'sleep 1 && echo X X',
9
- # Substring present in 'command'. Often replaced by the instance filename.
10
- pattern: 'X',
11
- # Extractor object. Receives the output of the command and return
12
- # the most important fields.
13
- extractor: SampleExtractor.new,
14
- # String used to identify the command. Will be used to prefix the return of
15
- # extractor.names.
16
- prefix: 'doubled',
17
- }, {
18
- command: 'sleep 3 && echo "banana X"',
19
- pattern: 'X',
20
- extractor: SampleExtractor.new,
21
- prefix: 'banana',
22
- }, {
23
- command: 'sleep 100 && echo "never gonna happen X"',
24
- pattern: 'X',
25
- extractor: SampleExtractor.new,
26
- prefix: 'timeout',
27
- }]
5
+ commands = [
6
+ 'sleep 2 && echo orange',
7
+ 'sleep 4 && echo banana',
8
+ 'sleep 100 && echo "never gonna happen"',
9
+ ]
28
10
 
29
- execution_info = {
11
+ conf = {
30
12
  # IDs of the CPU cores that can be used for executing tests.
31
- cpus_available: [1, 2, 3],
13
+ cpus_available: [0, 1],
32
14
  # Maximum number of seconds that a command can run. After this a kill command
33
15
  # (TERM signal) will be issued.
34
16
  timeout: 5,
@@ -37,12 +19,5 @@ execution_info = {
37
19
  post_timeout: 1,
38
20
  }
39
21
 
40
- conf = {
41
- # The name of the file where will be written the CSV data.
42
- csvfname: 'sample.csv',
43
- }
44
-
45
- files = ['apple', 'orange'] # Applejack would be proud
46
-
47
- BatchExperiment::experiment(comms_info, execution_info, conf, files)
22
+ BatchExperiment::batch(commands, conf)
48
23
 
@@ -0,0 +1,10 @@
1
+ The tao that can be told is not the eternal Tao.
2
+ The name that can be named is not the eternal Name.
3
+ The unnamable is the eternally real.
4
+ Naming is the origin of all particular things.
5
+ Free from desire, you realize the mystery.
6
+ Caught in desire, you see only the manifestations.
7
+ Yet mystery and manifestations arise from the same source.
8
+ This source is called darkness.
9
+ Darkness within darkness.
10
+ The gateway to all understanding.
@@ -12,12 +12,12 @@ require_relative 'batch_experiment/sample_extractors'
12
12
  comms_info = [{
13
13
  command: 'pyasukpt -src INST_FILE',
14
14
  pattern: 'INST_FILE',
15
- extractor: PyaExtractor.new,
15
+ extractor: BatchExperiment::PyaExtractor,
16
16
  prefix: 'PYAsUKP',
17
17
  }, {
18
18
  command: 'run_ukp5.out INST_FILE',
19
19
  pattern: 'INST_FILE',
20
- extractor: UKP5Extractor.new,
20
+ extractor: BatchExperiment::UKP5Extractor,
21
21
  prefix: 'UKP5',
22
22
  }]
23
23
 
@@ -1,11 +1,13 @@
1
1
  require 'childprocess'
2
2
  require 'pathname'
3
3
 
4
+ # The main module, the two main utility methods offered are ::batch and
5
+ # ::experiment.
4
6
  module BatchExperiment
5
- # The default callable class used by batch to convert a command into a
7
+ # The default callable object used by #batch to convert a command into a
6
8
  # filename.
7
- class FilenameSanitizer
8
- def call(command)
9
+ module FilenameSanitizer
10
+ def self.call(command)
9
11
  fname = command.strip
10
12
  fname.gsub!(/[^[:alnum:]]/, '_')
11
13
  fname.gsub!(/_+/, '_')
@@ -32,55 +34,53 @@ module BatchExperiment
32
34
 
33
35
  # Takes a list of commands, execute them only on the designed core/cpus, and
34
36
  # kill them if the timeout expires, never lets a core/cpu rest for more than
35
- # conf[:busy_loop_sleep] seconds between a command and another. The
36
- # conf[:fname_sanitizer] is called over the commands to generate partial
37
- # filenames. Appending '.out' to one of the partial filenames will give the
38
- # filename were the command stdout was redirected. The analogue is valid for
39
- # '.err' and stderr. The first partial filename corresponds to the first
40
- # command in commands, and so on. Right before a command begans to run, a
41
- # "partial_filename.#{conf[:unfinished_ext]}" file is created. After the
42
- # command ends its execution this file is removed. If the command ends its
43
- # execution by means of a timeout the file is also removed. The file only
44
- # remains if the batch procedure is interrupted (not a specific command).
37
+ # a predetermined amount of seconds between a command and another. Partial
38
+ # filenames are derived from the commands. Appending '.out' to one of the
39
+ # partial filenames will give the filename were the command stdout was
40
+ # redirected. The analogue is valid for '.err' and stderr. Right before a
41
+ # command begans to run, a "partial_filename.unfinished file is created.
42
+ # After the command ends its execution this file is removed. If the command
43
+ # ends its execution by means of a timeout the file is also removed. The file
44
+ # only remains if the batch procedure is interrupted (script was killed,
45
+ # or system crashed).
45
46
  #
46
47
  # @param commands [Array<String>] The shell commands.
47
48
  # @param conf [Hash] The configurations, as follows:
48
- # :cpus_available [Array<Fixnum>] Cpu cores that can be used to run the
49
+ # -- cpus_available [Array<Fixnum>] Cpu cores that can be used to run the
49
50
  # commands. Required parameter. The cpu numbers begin at 0, despite what
50
- # htop tells you;
51
- # :timeout [Number] Number of seconds before killing a command. Required
52
- # parameter. Is the same for all the commands;
53
- # :time_fmt [String] A string in the time (external command) format. See
51
+ # htop tells you.
52
+ # -- timeout [Number] Number of seconds before killing a command. Required
53
+ # parameter. Is the same for all the commands.
54
+ # -- time_fmt [String] A string in the time (external command) format. See
54
55
  # http://linux.die.net/man/1/time. Default: 'ext_time: %e\next_mem: %M\n'.
55
- # :busy_loop_sleep [Number] How many seconds to wait before checking if a
56
+ # busy_loop_sleep [Number] How many seconds to wait before checking if a
56
57
  # command ended execution. This is max time a cpu will be vacant between
57
- # two commands. Default: 0.1;
58
- # :post_timeout [Number] A command isn't guaranteed to end after receiving
59
- # a TERM signal. If the command hasn't stopped, waits post_timeout seconds
60
- # before sending a KILL signal (give it a chance to end gracefully).
61
- # Default: 5;
62
- # :fname_sanitizer [Callable Object] The call method of this object
58
+ # two commands. Default: 0.1.
59
+ # -- post_timeout [Number] A command isn't guaranteed to end after
60
+ # receiving a TERM signal. If the command hasn't stopped, waits
61
+ # post_timeout seconds before sending a KILL signal (give it a chance to
62
+ # end gracefully). Default: 5.
63
+ # -- fname_sanitizer [#call] The call method of this object
63
64
  # should take a String and convert it (possibly losing information), to a
64
65
  # valid filename. Used over the commands to define the output files of
65
- # commands.
66
- # Default: BatchExperiment::FilenameSanitizer.new;
67
- # :skip_done_comms [FalseClass,TrueClass] Skip any command for what a
66
+ # commands. Default: BatchExperiment::FilenameSanitizer
67
+ # -- skip_done_comms [FalseClass,TrueClass] Skip any command for what a
68
68
  # corresponding '.out' file exists, except if both a '.out' and a
69
69
  # '.unfinished' file exist, in the last case the command is executed.
70
- # Default: true;
71
- # :unfinished_ext [String] Extension to be used in place of '.unfinished'.
72
- # Default: '.unfinished';
73
- # :out_ext [String] Extension to be used in place of '.out'.
74
- # Default: '.out';
75
- # :err_ext [String] Extension to be used in place of '.err'.
76
- # Default: '.err';
70
+ # Default: true.
71
+ # -- unfinished_ext [String] Extension to be used in place of
72
+ # '.unfinished'. Default: '.unfinished'.
73
+ # -- out_ext [String] Extension to be used in place of '.out'.
74
+ # Default: '.out'.
75
+ # -- err_ext [String] Extension to be used in place of '.err'.
76
+ # Default: '.err'.
77
77
  # @return [String] Which commands were executed. Can be different from
78
78
  # the 'commands' argument if commands are skipped (see :skip_done_comms).
79
79
  #
80
- # @note This procedure was not designed to support equal commands (the last
81
- # equal command executed will subscribe the '.out', '.err' and '.unfinished'
82
- # files used by any previous equal command). But the parameter
83
- # conf[:fname_sanitizer] can be used to circumvent the restriction over
80
+ # @note If the same command is executed over the same file more than one
81
+ # time, then only the last execution will be saved (because the '.out',
82
+ # '.err' and '.unfinished' files will be overwritten). But the parameter
83
+ # conf\[:fname_sanitizer\] can be used to circumvent the restriction over
84
84
  # equal commands (if the object has state it can return a different
85
85
  # filename for every time it's called with the same argument).
86
86
  # @note This procedure makes use of the following linux commands: time (not
@@ -91,13 +91,13 @@ module BatchExperiment
91
91
  # shell).
92
92
  # @note The command is executed inside a call to "sh -c command", so it has
93
93
  # to be a valid sh command.
94
- # @note The output of the command "time -f #{conf[:time_fmt]}" will be
95
- # appended to the '.out' file of every command. If you set conf[:time_fmt]
96
- # to a empty string only a newline will be appended.
94
+ # @note The output of the command "time -f conf\[:time_fmt\]" will be
95
+ # appended to the '.out' file of every command. If you set
96
+ # conf\[:time_fmt\] to a empty string only a newline will be appended.
97
97
  def self.batch(commands, conf)
98
98
  # Throw exceptions if required configurations aren't provided.
99
- fail "conf[:cpus_available] not set" unless conf[:cpus_available]
100
- fail "conf[:timeout] not set" unless conf[:timeout]
99
+ fail 'conf[:cpus_available] not set' unless conf[:cpus_available]
100
+ fail 'conf[:timeout] not set' unless conf[:timeout]
101
101
 
102
102
  # Initialize optional configurations with default values if they weren't
103
103
  # provided. Don't change the conf argument, only our version of conf.
@@ -108,7 +108,7 @@ module BatchExperiment
108
108
  conf[:err_ext] ||= '.err'
109
109
  conf[:busy_loop_sleep] ||= 0.1
110
110
  conf[:post_timeout] ||= 5
111
- conf[:fname_sanitizer] ||= BatchExperiment::FilenameSanitizer.new
111
+ conf[:fname_sanitizer] ||= BatchExperiment::FilenameSanitizer
112
112
  conf[:skip_done_comms] = true if conf[:skip_done_comms].nil?
113
113
 
114
114
  # Initialize main variables
@@ -227,7 +227,7 @@ module BatchExperiment
227
227
  # command [String] A string with a sh shell command.
228
228
  # pattern [String] A substring of command, will be replace by the strings
229
229
  # in the paramenter 'files'.
230
- # extractor [Extractor] An object that implements the Extractor interface.
230
+ # extractor [#extract,#names] Object implementing the Extractor interface.
231
231
  # prefix [String] A string that will be used to prefix the extractor.names
232
232
  # when they are used as column names. Improves Extractor reusability.
233
233
  # @param batch_conf [Hash] Configuration used to call batch. See the
@@ -266,7 +266,8 @@ module BatchExperiment
266
266
  # @return [NilClass,Array<String>] The return of the internal #batch
267
267
  # call. Returns nil if conf[:skip_commands] was set to true.
268
268
  #
269
- # @see BatchExperiment.batch
269
+ # @see BatchExperiment::batch
270
+ # @note This command call ::batch internally.
270
271
  def self.experiment(comms_info, batch_conf, conf, files)
271
272
  # Throw exceptions if required configurations aren't provided.
272
273
  fail 'conf[:csvfname] is not defined' unless conf[:csvfname]
@@ -283,7 +284,7 @@ module BatchExperiment
283
284
  out_ext = batch_conf[:out_ext] || '.out'
284
285
  unfinished_ext = batch_conf[:unfinished_ext] || '.unfinished'
285
286
  fname_sanitizer = batch_conf[:fname_sanitizer]
286
- fname_sanitizer ||= BatchExperiment::FilenameSanitizer.new
287
+ fname_sanitizer ||= BatchExperiment::FilenameSanitizer
287
288
 
288
289
  # Create commands the templates and the file list.
289
290
  comms_sets = []
@@ -291,7 +292,7 @@ module BatchExperiment
291
292
  comms_sets << gencommff(comm_info[:command], comm_info[:pattern], files)
292
293
  end
293
294
 
294
- comm_list = conf[:ic_comm] ? intercalate(comms_sets) : comms_sets.flatten
295
+ comm_list = conf[:ic_comms] ? intercalate(comms_sets) : comms_sets.flatten
295
296
 
296
297
  # Execute the commands (or not).
297
298
  ret = batch(comm_list, batch_conf) unless conf[:skip_commands]
@@ -313,7 +314,7 @@ module BatchExperiment
313
314
  line = []
314
315
  comms_info.each_with_index do | comm_info, i |
315
316
  command =
316
- if conf[:ic_comm]
317
+ if conf[:ic_comms]
317
318
  comm_list[(j * comms_info.size) + i]
318
319
  else
319
320
  comm_list[(i * files.size) + j]
@@ -1,29 +1,69 @@
1
- module Extractor
2
- # For when there's a field whose value is after '<field>: '.
3
- def self.get_field(lines, field)
4
- lines.grep(/^#{field}: .*/).each { | l | return l.match(/:[\t ]+(.*)/)[1] }
5
- ''
6
- end
1
+ module BatchExperiment
2
+ # Module that defines the interface used for extracting info from other
3
+ # programs output. You don't need to include it in your object, will suffice
4
+ # that the object (that you will use to extract info from the output) has the
5
+ # ::names and ::extract methods defined.
6
+ module Extractor
7
+ # Find a line in the following format: "field: value", return value.
8
+ #
9
+ # @param lines [Array<String>] Program output, broken in lines.
10
+ # @param field [String] String to be found at the lines in the following
11
+ # pattern: 'field: value'.
12
+ #
13
+ # @return [String] The 'value' as a string or, if 'field' isn't found, an
14
+ # empty string.
15
+ def self.get_field(lines, field)
16
+ lines.grep(/^#{field}: .*/).each { | l | return l.match(/:[\t ]+(.*)/)[1] }
17
+ ''
18
+ end
7
19
 
8
- # For when there's a field whose value is in the next line.
9
- def self.get_hfield(lines, field)
10
- if ix = lines.find_index(field) then lines[ix + 1] else '' end
11
- end
20
+ # Find a line in the following format: "field<linebreak>value", return
21
+ # value.
22
+ #
23
+ # @param lines [Array<String>] Program output, broken in lines.
24
+ # @param field [String] String to be found at the lines in the following
25
+ # pattern: 'field<lineabreak>value'. Only include the linebreak at the
26
+ # field, if the lines array have linebreaks at the end of every string
27
+ # element.
28
+ #
29
+ # @return [String] The 'value' as a string or, if 'field' isn't found, an
30
+ # empty string.
31
+ def self.get_hfield(lines, field)
32
+ if ix = lines.find_index(field) then lines[ix + 1] else '' end
33
+ end
12
34
 
13
- # Return the field names for each of the elements returned by
14
- # extract. Ex.: ['Time', 'Max Mem Use', 'opt', ... ]
15
- def names
16
- fail 'This method should have been overwritten by a subclass.'
17
- end
35
+ # Return the field names for each of the elements returned by extract. Ex.:
36
+ # ['Time', 'Max Mem Use', 'opt', ... ]
37
+ #
38
+ # @note To be on the safe side you should create a new array at each call.
39
+ # If you always return a reference to the same array the array can be
40
+ # modified.
41
+ #
42
+ # @return [Array<String>] The strings that will be used to make the column
43
+ # names at the BatchExperiment.experiment method.
44
+ def names
45
+ fail 'This method should have been overwritten by a subclass.'
46
+ end
18
47
 
19
- def extract(content)
20
- extract_from_lines(content.lines.map! { | l | l.chomp! })
21
- end
48
+ # Extract N values of some program output, where N is equal to #names.size.
49
+ # If some value isn't present, the array should remain the same size, and
50
+ # the value at the corresponding position should be nil.
51
+ #
52
+ # @param content [String] Program output.
53
+ # @return [Array<String>] The N extracted values, as strings.
54
+ def extract(content)
55
+ extract_from_lines(content.lines.map! { | l | l.chomp! })
56
+ end
22
57
 
23
- # Extract an array of values from the command output. This array has the same
24
- # size as the one returned by field_names.
25
- def extract_from_lines(lines)
26
- fail 'This method should have been overwritten by a subclass.'
58
+ # Optionally, you can define this method instead of #extract. The #extract
59
+ # method will call this method if not overrided.
60
+ #
61
+ # @param lines [Array<String>] Program output, broken in lines,
62
+ # and the line string elements don't end in linebreak.
63
+ # @return [Array<String>] The N extracted values, as strings.
64
+ def extract_from_lines(lines)
65
+ fail 'This method should have been overwritten by a subclass.'
66
+ end
27
67
  end
28
68
  end
29
69
 
@@ -1,49 +1,88 @@
1
- require 'require_relative'
2
- require_relative './extractor.rb'
1
+ require 'batch_experiment/extractor'
3
2
 
4
- # Sample extractors used at https://github.com/henriquebecker91/masters, where
5
- # this code had its beggining. This file contains the code used to extract info
6
- # from the different outputs generated by UKP solving programs.
3
+ module BatchExperiment
4
+ module FirstLineExtractor
5
+ extend Extractor
6
+ def self.names
7
+ ['first line', 'ext_time', 'ext_mem']
8
+ end
7
9
 
8
- class SampleExtractor
9
- include Extractor
10
- def names
11
- ['first word', 'second word', 'ext_time', 'ext_mem']
10
+ def self.extract_from_lines(lines)
11
+ [ (lines[0] or ''),
12
+ Extractor.get_field(lines, 'ext_time'),
13
+ Extractor.get_field(lines, 'ext_mem')
14
+ ]
15
+ end
12
16
  end
13
17
 
14
- def extract_from_lines(lines)
15
- words = lines.empty? || lines[0].nil? ? ['',''] : lines[0].split().take(2)
16
- words << Extractor.get_field(lines, 'ext_time')
17
- words << Extractor.get_field(lines, 'ext_mem')
18
- words
19
- end
20
- end
18
+ module WcExtractor
19
+ extend Extractor
20
+ def self.names
21
+ ['lines', 'words', 'bytes', 'ext_time', 'ext_mem']
22
+ end
21
23
 
22
- class UKP5Extractor
23
- include Extractor
24
- def names
25
- ['internal time', 'external time', 'external memory', 'opt']
24
+ def self.extract(content)
25
+ arr = content.split(' ')
26
+ qt_lines, words, bytes = arr[0], arr[1], arr[2]
27
+ lines = content.lines.map! { | l | l.chomp! }
28
+ [ qt_lines, words, bytes,
29
+ Extractor.get_field(lines, 'ext_time'),
30
+ Extractor.get_field(lines, 'ext_mem')
31
+ ]
32
+ end
26
33
  end
27
34
 
28
- def extract_from_lines(lines)
29
- ['Seconds', 'ext_time', 'ext_mem', 'opt'].map do | label |
30
- Extractor.get_field(lines, label)
35
+ module TwoWordsExtractor
36
+ extend Extractor
37
+ def self.names
38
+ ['first word', 'second word', 'ext_time', 'ext_mem']
39
+ end
40
+
41
+ def self.extract_from_lines(lines)
42
+ words = lines.empty? || lines[0].nil? ? ['',''] : lines[0].split().take(2)
43
+ words << Extractor.get_field(lines, 'ext_time')
44
+ words << Extractor.get_field(lines, 'ext_mem')
45
+ words
31
46
  end
32
47
  end
33
- end
34
48
 
35
- class PyaExtractor
36
- include Extractor
37
- def names
38
- ['internal time', 'external time', 'external memory', 'opt']
49
+ # Sample extractors used at https://github.com/henriquebecker91/masters,
50
+ # where this code had its beggining. This file contains the code used to
51
+ # extract info from the different outputs generated by UKP solving programs.
52
+
53
+ # Extractor for the output of the run_ukp5.out program available at
54
+ # https://github.com/henriquebecker91/masters. Not of interest for the
55
+ # majority of the users of this gem. Kept as example, and for this gem author
56
+ # personal use.
57
+ module UKP5Extractor
58
+ extend Extractor
59
+ def self.names
60
+ ['internal time', 'external time', 'external memory', 'opt']
61
+ end
62
+
63
+ def self.extract_from_lines(lines)
64
+ ['Seconds', 'ext_time', 'ext_mem', 'opt'].map do | label |
65
+ Extractor.get_field(lines, label)
66
+ end
67
+ end
39
68
  end
40
69
 
41
- def extract_from_lines(lines)
42
- values = ['Total Time ', 'ext_time', 'ext_mem'].map do | label |
43
- Extractor.get_field(lines, label)
70
+ # Extractor for the output of the pyasukp program available at
71
+ # https://github.com/henriquebecker91/masters. Not of interest for the
72
+ # majority of the users of this gem. Kept as example, and for this gem author
73
+ # personal use.
74
+ class PyaExtractor
75
+ extend Extractor
76
+ def self.names
77
+ ['internal time', 'external time', 'external memory', 'opt']
78
+ end
79
+
80
+ def self.extract_from_lines(lines)
81
+ values = ['Total Time ', 'ext_time', 'ext_mem'].map do | label |
82
+ Extractor.get_field(lines, label)
83
+ end
84
+ opt_key = '#The optimal value for the given capacity'
85
+ values << Extractor.get_hfield(lines, opt_key)
44
86
  end
45
- opt_key = '#The optimal value for the given capacity'
46
- values << Extractor.get_hfield(lines, opt_key)
47
87
  end
48
88
  end
49
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batch_experiment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess
@@ -30,14 +30,16 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - examples/bible.txt
34
+ - examples/example_batch.rb
33
35
  - examples/sample_batch.rb
36
+ - examples/taoteching.txt
34
37
  - examples/ukp_batch.rb
35
38
  - lib/batch_experiment.rb
36
39
  - lib/batch_experiment/extractor.rb
37
40
  - lib/batch_experiment/sample_extractors.rb
38
41
  homepage: https://rubygems.org/gems/batch_experiment
39
42
  licenses:
40
- - Public Domain
41
43
  - Unlicense
42
44
  metadata: {}
43
45
  post_install_message:
@@ -62,3 +64,4 @@ specification_version: 4
62
64
  summary: A ruby script that distributes system commands between cpu cores, and save
63
65
  their output.
64
66
  test_files: []
67
+ has_rdoc: