不支持 EMR 的 Boto3 API 'OnDemandPrice'
Boto3 API for EMR doesn't support 'OnDemandPrice'
使用 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 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",
)
使用 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 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",
)