Using CodeWhisperer with Amazon SageMaker Studio - CodeWhisperer

CodeWhisperer's features are becoming a part of Amazon Q Developer. Learn more

Using CodeWhisperer with Amazon SageMaker Studio

This page describes how to set up and activate Amazon CodeWhisperer for Amazon SageMaker 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 Studio.

  1. Set up Amazon SageMaker prerequisites.

    The prerequisites for using SageMaker include creating an AWS account and creating an administrative user.

    For more information, see Set up Amazon SageMaker prerequisites in the Amazon SageMaker User Guide.

  2. Set up a Amazon SageMaker Domain.

    To use Amazon SageMaker Studio, you must complete the Amazon SageMaker Domain onboarding process using the SageMaker console or the AWS CLI. For more information, see Onboard to Amazon SageMaker Domain in the Amazon SageMaker User Guide.

  3. Add the CodeWhisperer-related permissions to your SageMaker 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.

  4. Enable the CodeWhisperer extension in your SageMaker Studio domain.

    Open the Launcher tab. Then, in the system terminal (not the image terminal) inside SageMaker 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 Studio Launcher in the Amazon SageMaker Developer Guide.

  5. 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 Studio. (You may need to refresh your browser first.)

For keyboard shortcuts, see User actions.