【发布时间】:2021-02-17 05:16:42
【问题描述】:
我已经编写了一个简单的 AWS step functions 工作流程,只需一步:
from stepfunctions.inputs import ExecutionInput
from stepfunctions.steps import Chain, TuningStep
from stepfunctions.workflow import Workflow
import train_utils
def main():
workflow_execution_role = 'arn:aws:iam::MY ARN'
execution_input = ExecutionInput(schema={
'app_id': str
})
estimator = train_utils.get_estimator()
tuner = train_utils.get_tuner(estimator)
tuning_step = TuningStep(state_id="HP Tuning", tuner=tuner, data={
'train': f's3://my-bucket/{execution_input["app_id"]}/data/'},
wait_for_completion=True,
job_name='HP-Tuning')
workflow_definition = Chain([
tuning_step
])
workflow = Workflow(
name='HP-Tuning',
definition=workflow_definition,
role=workflow_execution_role,
execution_input=execution_input
)
workflow.create()
if __name__ == '__main__':
main()
我的目标是从运行时提供的执行 JSON 中提取训练输入。当我执行工作流时(从步骤函数控制台),提供 JSON {"app_id": "My App ID"} 时,调整步骤不会获得正确的数据,而是获得stepfunctions.inputs.placeholders.ExecutionInput 的 to_string 表示。此外,在查看生成的 ASL 时,我可以看到执行输入被呈现为字符串:
...
"DataSource": {
"S3DataSource": {
"S3DataType": "S3Prefix",
"S3Uri": "s3://my-bucket/<stepfunctions.inputs.placeholders.ExecutionInput object at 0x12261f7d0>/data/",
"S3DataDistributionType": "FullyReplicated"
}
},
...
我做错了什么?
更新: 正如@yoodan 提到的,SDK 可能落后了,所以我必须在调用 create 之前编辑定义。我可以看到有一种方法可以在调用 create 之前查看定义,但是我可以修改图形定义吗?怎么样?
【问题讨论】:
-
如果你有定义,你可以使用 Boto3 用你的定义调用 CreateStateMachine:boto3.amazonaws.com/v1/documentation/api/latest/reference/…
标签: python machine-learning state-machine aws-step-functions hyperparameters