MRJob等待直到每个作业完成,然后再将控制权交还给用户。我将一个较大的EMR步骤分解为较小的步骤,并希望一次提交所有这些内容。
文档讨论programmatically submitting tasks,但是示例代码也等待作业完成(因为他们调用了blocks until the job is complete的Runner.run()命令)。
另外,EMR的 Activity 限制为256个 Activity ,但是,我们该如何填充这256个工作,而不是循环并在连接的控制台上获取输出。
最佳答案
经过数天的尝试,以下是我能想到的最好的方法。
我的最初尝试是,当我意识到终端分离后提交的作业不会被淘汰时,我是(以bash脚本的形式)提交并杀死作业。但是,这并不是很好,因为AWS限制了对EMR的调用,因此有些作业在提交之前就被杀死了。
当前最佳解决方案
from jobs import MyMRJob
import logging
logging.basicConfig(
level=logging.INFO,
format = '%(asctime)-15s %(levelname)-8s %(message)s',
)
log = logging.getLogger('submitjobs')
def main():
cluster_id="x-MXMXMX"
log.info('Cluster: %s', cluster_id)
for i in range(10):
n = '%04d' % i
log.info('Adding job: %s', n)
mr_job = MyMRJob(args=[
'-r', 'emr',
'--conf-path', 'mrjob.conf',
'--no-output',
'--output-dir', 's3://mybucket/mrjob/%s' % n,
'--cluster-id', cluster_id,
'input/file.%s' % n
])
runner = mr_job.make_runner()
# the following is the secret sauce, submits the job and returns
# it is a private method though, so may be changed without notice
runner._launch()
if __name__ == '__main__':
main()
关于python - 使用MRJob将作业提交到EMR群集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36874461/