CodeWhisperer's features are becoming a part of Amazon Q Developer. Learn more
Using CodeWhisperer with Amazon SageMaker AI Studio
This page describes how to set up and activate Amazon CodeWhisperer for Amazon SageMaker AI Studio. Once activated, CodeWhisperer can make code recommendations automatically as you write your code.
Note
Python is the only programming language that CodeWhisperer supports in SageMaker AI Studio.
-
Set up Amazon SageMaker AI prerequisites.
The prerequisites for using SageMaker AI include creating an AWS account and creating an administrative user.
For more information, see Set up Amazon SageMaker AI prerequisites in the Amazon SageMaker AI User Guide.
-
Set up a Amazon SageMaker AI Domain.
To use Amazon SageMaker AI Studio, you must complete the Amazon SageMaker AI Domain onboarding process using the SageMaker AI console or the AWS CLI. For more information, see Onboard to Amazon SageMaker AI Domain in the Amazon SageMaker AI User Guide.
-
Add the CodeWhisperer-related permissions to your SageMaker AI execution role.
Create an IAM policy containing the following statement. Then attach that policy to the execution role (IAM) or permission set (IAM Identity Center) associated with your user profile.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "CodeWhispererPermissions", "Effect": "Allow", "Action": ["codewhisperer:GenerateRecommendations"], "Resource": "*" } ] }
For more information, see Creating IAM policies and Adding and removing IAM identity permissions in the IAM User Guide.
-
Enable the CodeWhisperer extension in your SageMaker AI Studio domain.
Open the Launcher tab. Then, in the system terminal (not the image terminal) inside SageMaker AI Studio, run the following commmands.
conda activate studio pip install amazon-codewhisperer-jupyterlab-ext~=1.0 jupyter server extension enable amazon_codewhisperer_jupyterlab_ext conda deactivate restart-jupyter-server
For more information about this step and the next, see Use the Amazon SageMaker AI Studio Launcher in the Amazon SageMaker AI Developer Guide.
-
Open a new notebook.
Note
Code completions with CodeWhisperer only appear in code cells. They do not appear in markdown cells.
Now you should be ready to code with CodeWhisperer in SageMaker AI Studio. (You may need to refresh your browser first.)
For keyboard shortcuts, see User actions.