【问题标题】:MRJob determining if running inline, local, emr or hadoopMRJob 确定是否运行内联、本地、emr 或 hadoop
【发布时间】:2016-04-23 15:26:37
【问题描述】:
【问题讨论】:
标签:
python
hadoop
emr
mrjob
common-crawl
【解决方案1】:
感谢 @pykler 和 @sebastian-nagel 发布有关此问题的信息,因为尝试让 Common Crawl Python 示例在 Amazon EMR 上运行一直很头疼。
针对@pykler 发布的解决方案,我相信有一种更惯用的方式是shown in this PDF:
class CCJob(MRJob):
def configure_options(self):
super(CCJob, self).configure_options()
self.pass_through_option('--runner')
self.pass_through_option('-r')
然后剩下的代码,即if self.options.runner in ['emr', 'hadoop'] 检查,可以保持原样,它应该在 EMR 上正常工作,只需像往常一样传递-r emr 选项。
此外,在 EMR 上运行导入 mrcc 模块的脚本时似乎存在问题。我收到ImportError 说找不到模块。
要解决此问题,您应该创建一个新文件,其中包含要运行的代码,并将 from mrcc import CCJob 导入替换为实际的 mrcc.py 代码。这是 cc-mrjob 存储库的 shown in this fork。
【解决方案2】:
我找到了一个解决方案,但如果有人知道的话,我仍在寻找内置解决方案。 You can add a custom passthrough option that gets passed to your tasks,看起来像这样:
class CCJob(MRJob):
def configure_options(self):
super(CCJob, self).configure_options()
self.add_passthrough_option(
'--platform', default='local', choices=['local', 'remote'],
help="indicate running remotely")
def mapper(self, _, line):
if self.options.platform == 'remote':
pass
并且远程运行时必须通过--platform remote