mandy 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/bin/mandy +1 -0
  2. data/lib/mandy.rb +23 -1
  3. metadata +1 -1
data/bin/mandy CHANGED
@@ -11,6 +11,7 @@ puts ''
11
11
  'mandy-install' => 'Installs the Mandy Rubygem on several hosts via ssh.',
12
12
  'mandy-local' => 'Run a Map/Reduce task locally without requiring hadoop',
13
13
  'mandy-hadoop' => 'Run a Map/Reduce task on hadoop using the provided cluster config',
14
+ 'mandy-run' => 'Run an entire Map/Reduce workflow with one command',
14
15
  'mandy-rm' => 'remove a file or directory from HDFS',
15
16
  'mandy-put' => 'upload a file into HDFS',
16
17
  'mandy-map' => 'Run a map task reading on STDIN and writing to STDOUT',
data/lib/mandy.rb CHANGED
@@ -29,12 +29,12 @@ require "cgi"
29
29
 
30
30
  module Mandy
31
31
  class << self
32
+ attr_accessor :local_input
32
33
  def stores
33
34
  @stores||={}
34
35
  end
35
36
  end
36
37
 
37
-
38
38
  def job(name, &blk)
39
39
  job = Mandy::Job.new(name)
40
40
  job.instance_eval(&blk) unless blk.nil?
@@ -42,4 +42,26 @@ module Mandy
42
42
  job
43
43
  end
44
44
  module_function :job
45
+ end
46
+
47
+ at_exit do
48
+ raise $! if $!
49
+ caller = Kernel.caller.first.split(':').first
50
+ next if caller =~ /bin\/(rake|mandy)/
51
+ input = Mandy.local_input || ENV['MANDY_INPUT']
52
+ unless input
53
+ print "Input file: "
54
+ input = gets.chomp
55
+ end
56
+ file = caller
57
+ output_folder = FileUtils.mkdir_p("/tmp/mandy-local")
58
+ out = nil
59
+ Mandy::Job.jobs.each_with_index do |job, i|
60
+ out = File.join(output_folder, "#{i+1}-#{job.name.downcase.gsub(/\W/, '-')}")
61
+ puts "Running #{job.name}..."
62
+ `cat #{input} | mandy-map #{file} "#{job.name}" | sort | mandy-reduce #{file} "#{job.name}" > #{out}`
63
+ input = out
64
+ end
65
+
66
+ puts File.read(out)
45
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Kent