forked from Smerity/cc-mrjob
-
Notifications
You must be signed in to change notification settings - Fork 65
/
run_ccmrjob_hadoop.sh
executable file
·63 lines (55 loc) · 1.81 KB
/
run_ccmrjob_hadoop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
JOB="$1"
INPUT="$2"
OUTPUT="$3"
if [ -z "$JOB" ] || [ -z "$INPUT" ] || [ -z "$OUTPUT" ]; then
echo "Usage: $0 <job> <input> <outputdir>"
echo " Run a CommonCrawl mrjob on Hadoop"
echo
echo "Arguments:"
echo " <job> CCJob implementation"
echo " <input> input path"
echo " <output> output path (must not exist)"
echo
echo "Example:"
echo " $0 word_count hdfs://.../wet.paths hdfs:///.../output/"
echo
echo "Note: don't forget to adapt the number of maps/reduces and the memory requirements"
exit 1
fi
# strip .py from job name
JOB=${JOB%.py}
# wrap Python files for deployment, cf. below option --setup,
# see for details
# http://pythonhosted.org/mrjob/guides/setup-cookbook.html#putting-your-source-tree-in-pythonpath
tar cvfz ${JOB}_ccmr.tar.gz *.py
# number of maps resp. reduces
NUM_MAPS=250
NUM_REDUCES=10
if [ -n "$S3_LOCAL_TEMP_DIR" ]; then
S3_LOCAL_TEMP_DIR="--s3_local_temp_dir=$S3_LOCAL_TEMP_DIR"
else
S3_LOCAL_TEMP_DIR=""
fi
if [ -n "$S3_BUCKET" ]; then
S3_BUCKET="--bucket=$S3_BUCKET"
else
S3_BUCKET=""
fi
python $JOB.py \
-r hadoop \
--jobconf "mapreduce.map.memory.mb=1200" \
--jobconf "mapreduce.map.java.opts=-Xmx1024m" \
--jobconf "mapreduce.reduce.memory.mb=1200" \
--jobconf "mapreduce.reduce.java.opts=-Xmx1024m" \
--jobconf "mapreduce.output.fileoutputformat.compress=true" \
--jobconf "mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.BZip2Codec" \
--jobconf "mapreduce.job.reduces=$NUM_REDUCES" \
--jobconf "mapreduce.job.maps=$NUM_MAPS" \
--setup 'export PYTHONPATH=$PYTHONPATH:'${JOB}'_ccmr.tar.gz#/' \
--no-output \
--cleanup NONE \
$S3_LOCAL_TEMP_DIR \
$S3_BUCKET \
--output-dir "$OUTPUT" \
"$INPUT"