

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Lift-and-shift 使用 @step 装饰器的 Python 代码
<a name="pipelines-step-decorator"></a>

`@step` 装饰器是将本地机器学习 (ML) 代码转换为一个或多个管道步骤的功能。您可以像编写任何 ML 项目一样编写 ML 函数。在本地测试或使用装饰器作为训练作业进行测试后，您可以通过添加`@remote`装饰器将该函数转换为 A SageMaker I 管道步骤。`@step`然后，您可以将 `@step` 装饰函数调用的输出作为一个步骤传递给 Pipelines，以创建并运行管道。您还可以使用 `@step` 装饰器串联一系列函数，创建多步骤有向无环图 (DAG) 管道。

使用 `@step` 装饰器的设置与使用 `@remote` 装饰器的设置相同。关于如何[设置环境](https://docs.amazonaws.cn/sagemaker/latest/dg/train-remote-decorator.html#train-remote-decorator-env)和[使用配置文件](https://docs.amazonaws.cn/sagemaker/latest/dg/train-remote-decorator-config.html)设置默认值，请参阅远程功能文档。有关 `@step` 装饰器的更多信息，请参阅 [sagemaker.workflow.function\$1step.step](https://sagemaker.readthedocs.io/en/stable/workflows/pipelines/sagemaker.workflow.pipelines.html#sagemaker.workflow.function_step.step)。

要查看演示如何使用 `@step` 装饰器的示例笔记本，请参阅 [@step 装饰器示例笔记本](https://github.com/aws/amazon-sagemaker-examples/tree/main/sagemaker-pipelines/step-decorator)。

下文将介绍如何使用 `@step` 装饰器注释本地 ML 代码以创建步骤、使用步骤创建和运行管道，以及如何根据使用场景定制体验。

**Topics**
+ [使用 `@step` 装饰函数创建管道](pipelines-step-decorator-create-pipeline.md)
+ [运行管道](pipelines-step-decorator-run-pipeline.md)
+ [配置您的管道](pipelines-step-decorator-cfg-pipeline.md)
+ [最佳实践](pipelines-step-decorator-best.md)
+ [限制](pipelines-step-decorator-limit.md)