Notebook execution Ruby samples - Amazon EMR
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Notebook execution Ruby samples


EMR Notebooks are available as EMR Studio Workspaces in the console. The Create Workspace button in the console lets you create new notebooks. To access or create Workspaces, EMR Notebooks users need additional IAM role permissions. For more information, see Amazon EMR Notebooks are Amazon EMR Studio Workspaces in the console and Amazon EMR console.

The following are Ruby code samples that demonstrate using the notebook execution API.

# prepare an Amazon EMR client emr = region: 'us-east-1', access_key_id: 'AKIA...JKPKA', secret_access_key: 'rLMeu...vU0OLrAC1', )

Starting notebook execution and getting the execution id

In this example, the Amazon S3 editor and EMR notebook are s3://mybucket/notebooks/e-EA8VGAA429FEQTC8HC9ZHWISK/test.ipynb.

For information about the Amazon EMR API NotebookExecution actions, see Amazon EMR API actions.

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

Describing notebook execution and printing the details

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

The output from the above commands will be as follows.

{ :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=>[] }

Notebook filters

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

Stopping notebook execution

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