【问题标题】:AWS EMR - How to automatically edit file on all slave nodes?AWS EMR - 如何自动编辑所有从节点上的文件?
【发布时间】:2023-03-17 20:07:01
【问题描述】:

我正在 AWS EMR 集群的所有从节点上运行 Python 脚本。我需要在每个从节点上配置 matplotlib 使用非交互式后端,否则会遇到错误(detailed description provided here

我目前的解决方案是手动ssh到每个slave节点并手动编辑/usr/local/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc:

backend : agg

显然,这种方法非常耗时且效率低下。

谁能提供一个在所有从节点上自动执行此任务的小(伪)代码 sn-p?

【问题讨论】:

  • 在所有节点上运行的脚本是否相同?在这种情况下,脚本本身可以将后端设置为"Agg"
  • 是的,要执行的python脚本在所有节点上都是一样的。实际上从 python 脚本设置后端是个好主意,我会研究它。谢谢

标签: python matplotlib edit amazon-emr worker


【解决方案1】:

最简单的解决方案是在 Amazon EMR 启动实例后通过bootstrap action 提供一个 shell 脚本:

#! /bin/sh
sudo sed -i 's/TkAgg/agg/g' /usr/local/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 2020-11-14
    • 1970-01-01
    • 2016-05-14
    相关资源
    最近更新 更多