

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

# EMR Notebook에 대한 Ruby 샘플
<a name="emr-managed-notebooks-headless-ruby"></a>

이 주제에는 노트북 기능을 보여주는 Ruby 샘플이 포함되어 있습니다.

**참고**  
EMR Notebooks는 콘솔에서 EMR Studio Workspace로 사용 가능합니다. 콘솔의 **워크스페이스 생성** 버튼을 사용하면 새 노트북을 생성할 수 있습니다. EMR Notebooks 사용자는 Workspace에 액세스하거나 Workspace를 생성하려면 추가 IAM 역할 권한이 필요합니다. 자세한 내용은 [Amazon EMR Notebooks가 콘솔에서 Amazon EMR Studio 워크스페이스 역할](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-migration.html) 및 [Amazon EMR 콘솔](https://docs.aws.amazon.com/emr/latest/ManagementGuide/whats-new-in-console.html)을 참조하세요.

다음 Ruby 코드 샘플에서는 노트북 실행 API 사용을 보여줍니다.

```
# prepare an Amazon EMR client

emr = Aws::EMR::Client.new(
  region: 'us-east-1',
  access_key_id: 'AKIA...JKPKA',
  secret_access_key: 'rLMeu...vU0OLrAC1',
)
```

## 노트북 실행 시작 및 실행 ID 가져오기
<a name="emr-managed-notebooks-headless-ruby-startretrieve"></a>

이 예제에서 Amazon S3 편집기 및 EMR 노트북은 `s3://amzn-s3-demo-bucket/notebooks/e-EA8VGAA429FEQTC8HC9ZHWISK/test.ipynb`입니다.

Amazon EMR API `NotebookExecution` 작업에 대한 자세한 내용은 [Amazon EMR API 작업](https://docs.aws.amazon.com/emr/latest/APIReference/API_Operations.html)을 참조하세요.

```
start_response = emr.start_notebook_execution({
    editor_id: "e-EA8VGAA429FEQTC8HC9ZHWISK",
    relative_path: "test.ipynb",
    
    execution_engine: {id: "j-3U82I95AMALGE"},
    
    service_role: "EMR_Notebooks_DefaultRole",
})


notebook_execution_id = start_resp.notebook_execution_id
```

## 노트북 실행 설명 및 세부 정보 인쇄
<a name="emr-managed-notebooks-headless-ruby-describeprint"></a>

```
describe_resp = emr.describe_notebook_execution({
    notebook_execution_id: notebook_execution_id
})
puts describe_resp.notebook_execution
```

위 명령의 출력은 다음과 같습니다.

```
{
:notebook_execution_id=>"ex-IZX3VTVZWVWPP27KUB90BZ7V9IEDG", 
:editor_id=>"e-EA8VGAA429FEQTC8HC9ZHWISK",
:execution_engine=>{:id=>"j-3U82I95AMALGE", :type=>"EMR", :master_instance_security_group_id=>nil}, 
:notebook_execution_name=>"", 
:notebook_params=>nil, 
:status=>"STARTING", 
:start_time=>2020-07-23 15:07:07 -0700, 
:end_time=>nil, 
:arn=>"arn:aws:elasticmapreduce:us-east-1:123456789012:notebook-execution/ex-IZX3VTVZWVWPP27KUB90BZ7V9IEDG", 
:output_notebook_uri=>nil, 
:last_state_change_reason=>"Execution is starting for cluster j-3U82I95AMALGE.", :notebook_instance_security_group_id=>nil, 
:tags=>[]
}
```

## 노트북 필터
<a name="emr-managed-notebooks-headless-ruby-filters"></a>

```
"EditorId": "e-XXXX",           [Optional]
"From" : "1593400000.000",    [Optional]
"To" :
```

### 노트북 실행 중지
<a name="emr-managed-notebooks-headless-ruby-stop"></a>

```
stop_resp = emr.stop_notebook_execution({
    notebook_execution_id: notebook_execution_id
})
```