amazon-sagemaker - 如何判断一个人的工作成本是多少
问题描述
有没有办法知道个人培训工作的成本是多少?
我可以在计费仪表板中看到每日/每小时费用,这是一个很好的代理。我也查看了使用报告,但没有看到将 UsageValues 相加的方法,也没有看到使用报告中的标签。
解决方案
当您调用DescribeTrainingJob API 调用时,您将获得以下值:TrainingStartTime 和 TrainingEndTime。您需要为这些时间之间的时间间隔付费。
现在您需要在 ResourceConfig 下(在同一 API 调用输出中)获取接下来的两个值来完成成本计算:InstanceType 和 InstanceCount。
最后,您可以查询您正在使用的 InstanceType 的定价 API,并获取您正在运行的区域的价格。
import boto3
pricing_client = boto3.client('pricing', region_name='us-east-1')
filterValue = instanceType + "-Training"
response = pricing_client.get_products(
ServiceCode='AmazonSageMaker',
Filters=[
{
'Type': 'TERM_MATCH',
'Field': 'instanceType',
'Value': filterValue
},
]
)
## TODO: fix this line to take the right region and not the first
python_dict = json.loads(response['PriceList'][0])
pricePerHour = next(iter(next(iter(python_dict['terms']['OnDemand'].values()))["priceDimensions"].values()))["pricePerUnit"]['USD']
return float(pricePerHour)
推荐阅读
- spring-boot - 包含的重定向 URI 无效
- npm - NPM 挂在安装包 'zos' 上
- spring-data - 使用spring数据mongo存储库时如何指定集合名称?
- php - 在自定义插件中提交表单导致页面重定向
- android - Firebase Ml 套件人脸识别不适用于 FirebaseVisionFaceDetectorOptions 对象,但在默认模式下工作正常
- javascript - 为什么计算函数会自动运行
- tomcat - 如何在使用 tomcat 服务器安装 Knowage 后修复“HTTP 状态 404 - /knowage/”错误(请求的资源不可用。)
- r-markdown - 使用 knit_child 时 Rmarkdown 挂起
- azure-data-factory - 存储过程返回标量值时查找活动结果的表达式
- linux - 低功耗蓝牙 [4.2 及更高版本] - Linux 上 Qt 大于 20 字节的特征