

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Beispiele für Notebook-CLI-Befehle in EMR Studio
<a name="emr-managed-notebooks-headless-cli"></a>

Dieses Thema zeigt CLI-Befehlsbeispiele für ein EMR-Notebook. In dem Beispiel wird das Demo-Notizbuch aus der EMR Notebooks Notebooks-Konsole verwendet. Um das Notebook zu finden, verwenden Sie den Dateipfad relativ zum Home-Verzeichnis. In diesem Beispiel gibt es zwei Notebookdateien, die Sie ausführen können: `demo_pyspark.ipynb` und `my_folder/python3.ipynb`. 

**Anmerkung**  
EMR Notebooks sind als EMR Studio-Workspaces in der Konsole verfügbar. Mit der Schaltfläche „**Arbeitsbereich erstellen**“ in der Konsole können Sie neue Notizbücher erstellen. Um auf Workspaces zuzugreifen oder diese zu erstellen, benötigen EMR-Notebook-Benutzer zusätzliche IAM-Rollenberechtigungen. Weitere Informationen finden Sie unter [Amazon EMR Notebooks sind Amazon EMR Studio Workspaces in der Konsole und [Amazon](https://docs.aws.amazon.com/emr/latest/ManagementGuide/whats-new-in-console.html) EMR-Konsole](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-migration.html).

Der relative Pfad für die Datei `demo_pyspark.ipynb` ist `demo_pyspark.ipynb`, wie unten dargestellt.

![\[Jupyter notebook interface showing a file explorer and code editor with PySpark content.\]](http://docs.aws.amazon.com/de_de/emr/latest/ManagementGuide/images/notebook_exe_folder_structure_1.png)


Der relative Pfad für `python3.ipynb` ist `my_folder/python3.ipynb`, wie unten dargestellt.

![\[File explorer showing python3.ipynb in my_folder, and Jupyter notebook interface with code.\]](http://docs.aws.amazon.com/de_de/emr/latest/ManagementGuide/images/notebook_exe_folder_structure_2.png)


Informationen zu den API-`NotebookExecution`-Aktionen in Amazon-EMR finden Sie unter [Amazon-EMR-API-Aktionen](https://docs.aws.amazon.com/emr/latest/APIReference/API_Operations.html).

## Ein Notebook ausführen
<a name="emr-managed-notebooks-api-actions"></a>

Sie können den verwenden AWS CLI , um Ihr Notebook mit der `start-notebook-execution` Aktion auszuführen, wie die folgenden Beispiele zeigen. 

**Example – Ausführen eines EMR-Notebooks in einem EMR Studio Workspace mit einem Amazon-EMR-Cluster (läuft auf Amazon EC2)**  

```
aws emr --region us-east-1 \
start-notebook-execution \
--editor-id e-ABCDEFG123456 \
--notebook-params '{"input_param":"my-value", "good_superhero":["superman", "batman"]}' \
--relative-path test.ipynb \
--notebook-execution-name my-execution \
--execution-engine '{"Id" : "j-1234ABCD123"}' \
--service-role EMR_Notebooks_DefaultRole 
 
{
    "NotebookExecutionId": "ex-ABCDEFGHIJ1234ABCD"
}
```

**Example – Ausführen eines EMR-Notebooks in einem EMR Studio Workspace mit einem EMR-Notebooks-Cluster**  

```
aws emr start-notebook-execution \
    --region us-east-1 \
    --service-role EMR_Notebooks_DefaultRole \
    --environment-variables '{"KERNEL_EXTRA_SPARK_OPTS": "--conf spark.executor.instances=1", "KERNEL_LAUNCH_TIMEOUT": "350"}' \
    --output-notebook-format HTML \
    --execution-engine Id=arn:aws:emr-containers:us-west-2:account-id:/virtualclusters/ABCDEFG/endpoints/ABCDEF,Type=EMR_ON_EKS,ExecutionRoleArn=arn:aws:iam::account-id:role/execution-role \
    --editor-id e-ABCDEFG \
    --relative-path EMRonEKS-spark_python.ipynb
```

**Example – Ausführen eines EMR Notebooks unter Angabe seines Amazon-S3-Standorts**  

```
aws emr start-notebook-execution \
    --region us-east-1 \
    --notebook-execution-name my-execution-on-emr-on-eks-cluster \
    --service-role EMR_Notebooks_DefaultRole \
    --environment-variables '{"KERNEL_EXTRA_SPARK_OPTS": "--conf spark.executor.instances=1", "KERNEL_LAUNCH_TIMEOUT": "350"}' \
    --output-notebook-format HTML \
    --execution-engine Id=arn:aws:emr-containers:us-west-2:account-id:/virtualclusters/ABCDEF/endpoints/ABCDEF,Type=EMR_ON_EKS,ExecutionRoleArn=arn:aws:iam::account-id:role/execution-role \
    --notebook-s3-location '{"Bucket": "amzn-s3-demo-bucket","Key": "s3-prefix-to-notebook-location/EMRonEKS-spark_python.ipynb"}' \
    --output-notebook-s3-location '{"Bucket": "amzn-s3-demo-bucket","Key": "s3-prefix-for-storing-output-notebook"}'
```

## Notebook-Ausgabe
<a name="emr-managed-notebooks-headless-cli-output"></a>

 Hier ist die Ausgabe eines Beispiel-Notebooks. Zelle 3 zeigt die neu eingegebenen Parameterwerte.

![\[Jupyter notebook cells showing Python code and output for parameter injection and manipulation.\]](http://docs.aws.amazon.com/de_de/emr/latest/ManagementGuide/images/HelloWorld_notebook.png)


## Ein Notebook beschreiben
<a name="emr-managed-notebooks-headless-cli-describe"></a>

Sie können die `describe-notebook-execution`-Aktion verwenden, um auf Informationen über eine bestimmte Notebook-Ausführung zuzugreifen.

```
aws emr --region us-east-1 \
describe-notebook-execution --notebook-execution-id ex-IZWZZVR9DKQ9WQ7VZWXJZR29UGHTE
 
{
    "NotebookExecution": {
        "NotebookExecutionId": "ex-IZWZZVR9DKQ9WQ7VZWXJZR29UGHTE",
        "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
        "ExecutionEngine": {
            "Id": "j-2QMOV6JAX1TS2",
            "Type": "EMR",
            "MasterInstanceSecurityGroupId": "sg-05ce12e58cd4f715e"
        },
        "NotebookExecutionName": "my-execution",
        "NotebookParams": "{\"input_param\":\"my-value\", \"good_superhero\":[\"superman\", \"batman\"]}",
        "Status": "FINISHED",
        "StartTime": 1593490857.009,
        "Arn": "arn:aws:elasticmapreduce:us-east-1:123456789012:notebook-execution/ex-IZWZZVR9DKQ9WQ7VZWXJZR29UGHTE",
        "LastStateChangeReason": "Execution is finished for cluster j-2QMOV6JAX1TS2.",
        "NotebookInstanceSecurityGroupId": "sg-0683b0a39966d4a6a",
        "Tags": []
    }
}
```

## Ein Notebook stoppen
<a name="emr-managed-notebooks-headless-cli-stop"></a>

Wenn auf Ihrem Notebook eine Ausführung läuft, die Sie beenden möchten, können Sie dies mit dem `stop-notebook-execution`-Befehl tun.

```
# stop a running execution
aws emr --region us-east-1 \
stop-notebook-execution --notebook-execution-id ex-IZWZX78UVPAATC8LHJR129B1RBN4T
 
 
# describe it
aws emr --region us-east-1 \
describe-notebook-execution --notebook-execution-id ex-IZWZX78UVPAATC8LHJR129B1RBN4T
 
{
    "NotebookExecution": {
        "NotebookExecutionId": "ex-IZWZX78UVPAATC8LHJR129B1RBN4T",
        "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
        "ExecutionEngine": {
            "Id": "j-2QMOV6JAX1TS2",
            "Type": "EMR"
        },
        "NotebookExecutionName": "my-execution",
        "NotebookParams": "{\"input_param\":\"my-value\", \"good_superhero\":[\"superman\", \"batman\"]}",
        "Status": "STOPPED",
        "StartTime": 1593490876.241,
        "Arn": "arn:aws:elasticmapreduce:us-east-1:123456789012:editor-execution/ex-IZWZX78UVPAATC8LHJR129B1RBN4T",
        "LastStateChangeReason": "Execution is stopped for cluster j-2QMOV6JAX1TS2. Internal error",
        "Tags": []
    }
}
```

## Listet die Ausführungen für ein Notebook nach Startzeit auf
<a name="emr-managed-notebooks-headless-cli-list"></a>

Sie können einen `--from`-Parameter an `list-notebook-executions` übergeben, um die Ausführungen Ihres Notebooks nach Startzeit aufzulisten.

```
# filter by start time 
aws emr --region us-east-1 \ 
list-notebook-executions --from 1593400000.000
 
{
    "NotebookExecutions": [
        {
            "NotebookExecutionId": "ex-IZWZX78UVPAATC8LHJR129B1RBN4T",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "STOPPED",
            "StartTime": 1593490876.241
        },
        {
            "NotebookExecutionId": "ex-IZWZZVR9DKQ9WQ7VZWXJZR29UGHTE",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "RUNNING",
            "StartTime": 1593490857.009
        },
        {
            "NotebookExecutionId": "ex-IZWZYRS0M14L5V95WZ9OQ399SKMNW",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "STOPPED",
            "StartTime": 1593490292.995
        },
        {
            "NotebookExecutionId": "ex-IZX009ZK83IVY5E33VH8MDMELVK8K",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "FINISHED",
            "StartTime": 1593489834.765
        },
        {
            "NotebookExecutionId": "ex-IZWZXOZF88JWDF9J09GJ91R57VI0N",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "FAILED",
            "StartTime": 1593488934.688
        }
    ]
}
```

## Listet die Ausführungen für ein Notebook nach Startzeit und Status auf
<a name="emr-managed-notebooks-headless-cli-list"></a>

Der `list-notebook-executions`-Befehl kann auch einen `--status`-Parameter verwenden, um die Ergebnisse zu filtern.

```
# filter by start time and status 
aws emr --region us-east-1 \                 
list-notebook-executions --from 1593400000.000 --status FINISHED
{
    "NotebookExecutions": [
        {
            "NotebookExecutionId": "ex-IZWZZVR9DKQ9WQ7VZWXJZR29UGHTE",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "FINISHED",
            "StartTime": 1593490857.009
        },
        {
            "NotebookExecutionId": "ex-IZX009ZK83IVY5E33VH8MDMELVK8K",
            "EditorId": "e-BKTM2DIHXBEDRU44ANWRKIU8N",
            "NotebookExecutionName": "my-execution",
            "Status": "FINISHED",
            "StartTime": 1593489834.765
        }
    ]
}
```