mandy 0.4.993 → 0.4.994
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/mandy-map +3 -1
- data/lib/mandy.rb +15 -3
- data/lib/mandy/job.rb +18 -0
- data/lib/mandy/task.rb +2 -13
- data/lib/mandy/test_runner.rb +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.994
|
data/bin/mandy-map
CHANGED
@@ -11,9 +11,11 @@ def absolute_path(path)
|
|
11
11
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
12
12
|
end
|
13
13
|
|
14
|
-
file
|
14
|
+
file = absolute_path(ARGV[0])
|
15
15
|
job_name = ARGV[1]
|
16
16
|
|
17
17
|
require file
|
18
18
|
|
19
|
+
STDOUT.sync = true
|
20
|
+
|
19
21
|
Mandy::Job.find_by_name(job_name).run_map
|
data/lib/mandy.rb
CHANGED
@@ -2,6 +2,7 @@ require "rubygems"
|
|
2
2
|
require "json"
|
3
3
|
require "uri"
|
4
4
|
require "cgi"
|
5
|
+
require "fileutils"
|
5
6
|
|
6
7
|
%w(
|
7
8
|
support/formatting
|
@@ -45,6 +46,11 @@ module Mandy
|
|
45
46
|
job
|
46
47
|
end
|
47
48
|
module_function :job
|
49
|
+
|
50
|
+
def parameter(name)
|
51
|
+
Mandy::Job.parameter(name)
|
52
|
+
end
|
53
|
+
module_function :parameter
|
48
54
|
end
|
49
55
|
|
50
56
|
Mandy.autorun = true
|
@@ -71,9 +77,15 @@ at_exit do
|
|
71
77
|
out = File.join(output_folder, "#{i+1}-#{job.name.downcase.gsub(/\W/, '-')}")
|
72
78
|
puts "Running #{job.name}..."
|
73
79
|
reduce_phase = job.reducer_defined? ? %(| sort | mandy-reduce #{file} "#{job.name}") : ''
|
74
|
-
|
80
|
+
command = %(cat #{input} | mandy-map #{file} "#{job.name}" #{reduce_phase})
|
81
|
+
if Mandy::Job.jobs.last==job
|
82
|
+
IO.popen(command) do |stdout|
|
83
|
+
stdout.each_line { |out| STDOUT << out }
|
84
|
+
end
|
85
|
+
else
|
86
|
+
`#{command} > #{out}`
|
87
|
+
end
|
75
88
|
input = out
|
76
89
|
end
|
77
|
-
|
78
|
-
puts File.read(out)
|
90
|
+
FileUtils.rm_rf(output_folder)
|
79
91
|
end
|
data/lib/mandy/job.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Mandy
|
2
2
|
class Job
|
3
|
+
JSON_PAYLOAD_KEY = "json"
|
4
|
+
|
3
5
|
class << self
|
4
6
|
def jobs
|
5
7
|
@jobs ||= []
|
@@ -8,6 +10,22 @@ module Mandy
|
|
8
10
|
def find_by_name(name)
|
9
11
|
jobs.find {|job| job.name == name }
|
10
12
|
end
|
13
|
+
|
14
|
+
def parameter(name)
|
15
|
+
return find_json_param(name) if json_provided?
|
16
|
+
ENV[name.to_s]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def find_json_param(name)
|
22
|
+
json_args = JSON.parse(CGI.unescape(ENV[JSON_PAYLOAD_KEY]))
|
23
|
+
json_args[name.to_s]
|
24
|
+
end
|
25
|
+
|
26
|
+
def json_provided?
|
27
|
+
!ENV[JSON_PAYLOAD_KEY].nil?
|
28
|
+
end
|
11
29
|
end
|
12
30
|
|
13
31
|
attr_reader :settings
|
data/lib/mandy/task.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Mandy
|
2
2
|
class Task
|
3
|
-
JSON_PAYLOAD_KEY = "json"
|
4
3
|
KEY_VALUE_SEPERATOR = "\t" unless defined?(KEY_VALUE_SEPERATOR)
|
5
4
|
NUMERIC_PADDING = 16
|
6
5
|
DEFAULT_COUNTER_GROUP = 'Mandy Counters'
|
@@ -14,7 +13,7 @@ module Mandy
|
|
14
13
|
|
15
14
|
def emit(key, value=nil)
|
16
15
|
data = value.nil? ? key.to_s : "#{output_serialize_key(key)}\t#{output_serialize_value(value)}"
|
17
|
-
@output.puts
|
16
|
+
@output.puts data.chomp
|
18
17
|
end
|
19
18
|
|
20
19
|
def get(store, key)
|
@@ -44,17 +43,7 @@ module Mandy
|
|
44
43
|
end
|
45
44
|
|
46
45
|
def parameter(name)
|
47
|
-
|
48
|
-
ENV[name.to_s]
|
49
|
-
end
|
50
|
-
|
51
|
-
def find_json_param(name)
|
52
|
-
@json_args ||= JSON.parse(CGI.unescape(ENV[JSON_PAYLOAD_KEY]))
|
53
|
-
@json_args[name.to_s]
|
54
|
-
end
|
55
|
-
|
56
|
-
def json_provided?
|
57
|
-
!ENV[JSON_PAYLOAD_KEY].nil?
|
46
|
+
Job.parameter(name)
|
58
47
|
end
|
59
48
|
|
60
49
|
def deserialize_key(key)
|
data/lib/mandy/test_runner.rb
CHANGED