

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 파이프라인 실행
<a name="pipelines-step-decorator-run-pipeline"></a>

아래 페이지에서는 SageMaker AI 리소스를 사용하거나 로컬에서 Amazon SageMaker Pipelines으로 파이프라인을 실행하는 방법을 설명합니다.

기존 SageMaker AI 파이프라인 실행과 마찬가지로 `pipeline.start()` 함수로 새 파이프라인 실행을 시작합니다. `start()` 함수에 대한 자세한 내용은 [sagemaker.workflow.pipeline.Pipeline.start](https://sagemaker.readthedocs.io/en/stable/workflows/pipelines/sagemaker.workflow.pipelines.html#sagemaker.workflow.pipeline.Pipeline.start)를 참조하세요.

**참고**  
`@step` 데코레이터를 사용하여 정의된 단계는 훈련 작업으로 실행됩니다. 따라서 다음 제한 사항을 고려해야 합니다.  
계정의 인스턴스 한도 및 훈련 작업 한도. 스로틀링 또는 리소스 한도 문제를 방지하려면 적절하게 한도를 업데이트합니다.
파이프라인에서 훈련 단계를 실행할 때마다 발생하는 금전적 비용. 자세한 내용은 [Amazon SageMaker 요금](https://aws.amazon.com/sagemaker/pricing/)을 참조하세요.

## 로컬에서 실행되는 파이프라인에서 결과 검색
<a name="pipelines-step-decorator-run-pipeline-retrieve"></a>

파이프라인 실행 단계의 결과를 보려면 다음 코드 조각과 같이 [execution.result()](https://sagemaker.readthedocs.io/en/stable/workflows/pipelines/sagemaker.workflow.pipelines.html#sagemaker.workflow.pipeline._PipelineExecution.result           )를 사용합니다.

```
execution = pipeline.start()
execution.result(step_name="train")
```

**참고**  
Pipelines은 로컬 모드에서 `execution.result()`를 지원하지 않습니다.

한 번에 한 단계의 결과만 검색할 수 있습니다. 단계 이름이 SageMaker AI에서 생성된 경우 다음과 같이 `list_steps`을 직접적으로 호출하여 단계 이름을 검색할 수 있습니다.

```
execution.list_step()
```

## 로컬에서 파이프라인 실행
<a name="pipelines-step-decorator-run-pipeline-local"></a>

기존 파이프라인 단계와 마찬가지로 로컬에서 `@step`으로 데코레이션된 단계를 사용하여 파이프라인을 실행할 수 있습니다. 로컬 모드 파이프라인 실행에 대한 자세한 내용은 [로컬 모드를 사용하여 파이프라인 실행](pipelines-local-mode.md) 섹션을 참조하세요. 로컬 모드를 사용하려면 다음 예시와 같이 파이프라인 정의에 `SageMakerSession` 대신 `LocalPipelineSession`을 제공합니다.

```
from sagemaker.workflow.function_step import step
from sagemaker.workflow.pipeline import Pipeline
from sagemaker.workflow.pipeline_context import LocalPipelineSession

@step
def train():
    training_data = s3.download(....)
    ...
    return trained_model
    
step_train_result = train()

local_pipeline_session = LocalPipelineSession()

local_pipeline = Pipeline(
    name="<pipeline-name>",
    steps=[step_train_result],
    sagemaker_session=local_pipeline_session # needed for local mode
)

local_pipeline.create(role_arn="role_arn")

# pipeline runs locally
execution = local_pipeline.start()
```