2

AWSElasticMapReduceで次のMapReduceを実行しています。

./elastic-mapreduce --create --stream --name CLI_FLOW_LARGE --mapper s3://classify.mysite.com/mapper.py --reducer s3://classify.mysite.com/reducer.py --input s3n://classify.mysite.com/s3_list.txt --output s3://classify.mysite.com/dat_output4/ --cache s3n://classify.mysite.com/classifier.py#classifier.py- cache-archive s3n://classify.mysite.com/policies.tar.gz#policies --bootstrap-action s3://classify.mysite.com/bootstrap.sh --enable-debugging --master-instance-type m1.large --slave-instance-type m1.large --instance-type m1.large

何らかの理由で、cacheFileclassifier.pyがキャッシュされていないように見えます。reducer.pyインポートしようとすると、次のエラーが発生します。

  File "/mnt/var/lib/hadoop/mapred/taskTracker/hadoop/jobcache/job_201204290242_0001/attempt_201204290242_0001_r_000000_0/work/./reducer.py", line 12, in <module>
    from classifier import text_from_html, train_classifiers
ImportError: No module named classifier

classifier.pyに最も確実に存在しs3n://classify.mysite.com/classifier.pyます。価値のあることとして、ポリシーアーカイブは問題なく読み込まれるようです。

4

2 に答える 2

4

EC2でこの問題を修正する方法はわかりませんが、従来のHadoopデプロイメントのPythonで以前に見たことがあります。うまくいけば、レッスンは終わります。

reduce.pyおそらくそこにもあるので、私たちがする必要があるのは、ディレクトリがpythonパスにあることを追加することclassifier.pyです。何らかの理由で、この場所はpythonパスにないため、を見つけることができませんclassifier

import sys
import os.path

# add the directory where reducer.py is to the python path
sys.path.append(os.path.dirname(__file__))
# __file__ is the location of reduce.py, along with "reduce.py"
# dirname strips the file name and only gives the directory
# sys.path is the python path where it looks for modules

from classifier import text_from_html, train_classifiers

コードがローカルで機能する理由は、コードを実行している現在の作業ディレクトリが原因です。Hadoopは、現在の作業ディレクトリに関して、同じ場所から実行されていない可能性があります。

于 2012-05-01T02:57:42.180 に答える
1

orangeoctopus は、彼のコメントからこれを称賛するに値します。作業ディレクトリのシステム パスを追加する必要がありました。

sys.path.append('./')

また、私と同様の問題を抱えている人には、AWS での分散キャッシュの使用に関する次の素晴らしい記事を読むことをお勧めします: https://forums.aws.amazon.com/message.jspa?messageID=152538

于 2012-05-01T19:27:41.873 に答える