![](/img/trans.png)
[英]MRJob fails to star new jobs on EMR when using --pool-emr-job-flows
[英]Submit jobs to EMR cluster using MRJob
经过数天的尝试,以下是我能想到的最好的方法。
我的最初尝试是,当我意识到终端分离后提交的作业不会被淘汰时,我是(以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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.