【问题标题】:Boto3 API for EMR doesn't support 'OnDemandPrice'EMR 的 Boto3 API 不支持“OnDemandPrice”
【发布时间】:2021-11-10 03:59:11
【问题描述】:

在使用 Boto3 创建 EMR spark 集群时遇到了一些问题。我得到的错误如下:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the RunJobFlow operation: Attempted to set bid price for on demand instance group.

我指定这个配置如下:

 'Name': 'Core - 2',
 'InstanceRole': 'CORE',
 'InstanceType': 'i3.2xlarge',
 'InstanceCount': 50,
 'BidPrice': 'OnDemandPrice',

似乎Boto3 API 不允许这样做,我也不想使用 AWS Cli。是否有通过Boto3 指定 Spot 实例的解决方法?

【问题讨论】:

  • 你能分享你当前使用的产生错误的boto3吗?
  • 是1.18.41版
  • 我的意思是,产生错误的代码。
  • 配置太长了。但基本上添加这个 sn-p ``` 'InstanceGroups': [ { 'Name': 'Task', 'InstanceRole': 'TASK', 'InstanceType': 'i3.2xlarge', 'InstanceCount': 1, 'BidPrice ': 'OnDemandPrice' }, ```
  • 您可以使用正确格式的代码块更新答案。

标签: python amazon-web-services apache-spark boto3 amazon-emr


【解决方案1】:

boto3 repo 中有一个未解决的问题。目前,如果您指定"Market": "SPOT"BidPriceAsPercentageOfOnDemandPrice 将默认为 100%,即按需价格。

这是一个使用 boto3==1.18.42 的示例。

import boto3

client = boto3.client("emr", region_name="us-east-1")

response = client.run_job_flow(
    Name="Boto3 test cluster",
    ReleaseLabel="emr-5.33.0",
    Instances={
        "KeepJobFlowAliveWhenNoSteps": True,
        "TerminationProtected": False,
        "InstanceGroups": [
            {
                "InstanceRole": "MASTER",
                "InstanceCount": 1,
                "InstanceType": "i3.2xlarge",
                "Name": "Master",
            },
            {
                "InstanceRole": "CORE",
                "InstanceCount": 2,
                "InstanceType": "i3.2xlarge",
                "Name": "Core",
                "Market": "SPOT",
            },
        ],
    },
    VisibleToAllUsers=True,
    JobFlowRole="EMR_EC2_DefaultRole",
    ServiceRole="EMR_DefaultRole",
)

【讨论】:

    猜你喜欢
    • 2019-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 2019-05-29
    相关资源
    最近更新 更多