Test driving the Amazon CodeWhisperer customization capability (Preview)
Unless you have been living under a rock, you probably know that GenAI assisted coding assistants like Amazon CodeWhisperer are making an impact on developer productivity !! I have written a bunch of blogs in my personal blog on various facets of CodeWhisperer, and you can view them at https://cmani.medium.com/
While, the vast majority of the folks I work have been more than satisfied with the key features of CodeWhisperer — that its free for individual use (!!!), the in-built security scan feature, the flag or filter code suggestions from CodeWhisperer that resemble open-source training data and many other features. But a few customers/developers also have large existing code bases, frameworks/api’s that they would like to utilize, and also would like coding companions like CodeWhisperer to use these private codebases while generating the coding recommendations. To address this segment of customers, AWS has recently released a public preview of Amazon CodeWhisperer customization capability.
I wanted to try the customization feature of CodeWhisperer myself, which is explained in the launch blog. This short blog shows the steps to test the CodeWhisperer customization.

Let us get started ..
There are a few pre-reqs before you can get started, from the documentation:
Currently, you can customize CodeWhisperer recommendations on codebases written in Java, JavaScript, TypeScript, and Python.
Your data source must contain at least 10 MB, and at most 7 GB, of source code files from supported languages. There is no limit on the number of files, but you must include at least 10 files for each language that you want your customization to support. In the Amazon S3 data source, ensure that all source code is placed within a directory and not at the root level. Any files at the root level will be ignored.
Please check the documentation for the latest updates.
Step 0: Getting the source code aligned
The first hurdle that I encountered (completely my own limitations), was that I did not have a code base which was at-least 10MB, and so I had to fork the popular Apache spark open source project to test this feature 😊 !!

Step 1: Setting up the Customization
This is a very straightforward process, and can be completed from the CodeWhisperer console

The proof in the pudding is to ensure that your codebase gets a rating of 4 and above, which indicates that your codebase is good enough for activation for use by CodeWhisperer.

Fortunately, the fork of Apache Spark got a rating of 5, which was good enough.

Step 2: Using CodeWhisperer customizations
Once the customization is activated, we need to add the user who can access this customization.

Step 3: Start using the code recommendations ..
I am using VS Code with the AWS toolkit installed to access the recommendations from CodeWhisperer. Since, we have deployed a customization, we need to select the customization which we created and activated in the AWS console.

Cool, that’s all there is and now we can check if the code recommendations incorporate the APIs/libraries from the Apache Spark project.

That’s it folks and this was pretty straightforward. I am sure this will be very useful for folks who have existing codebases, and who want to leverage them for generating the code recommendations.
Hope this blog was useful, and helps you to get started in your journey with Amazon CodeWhisperer !!
Namaskara, ping me on LinkedIn, if you need additional information 🙏
Resources:
- CodeWhisperer customization documentation — https://docs.aws.amazon.com/codewhisperer/latest/userguide/customizations-dev.html
- Blog on customization — https://aws.amazon.com/blogs/aws/new-customization-capability-in-amazon-codewhisperer-generates-even-better-suggestions-preview/