Developing an AI application locally using AWS Chalice

First, let's implement the private APIs and services that provide common capabilities. We will have two services; both of them should be created in the chalicelib directory:

  1. StorageService: The StorageService class that's implemented in the storage_service.py file connects to AWS S3 via boto3 to perform tasks on files we need for the applications.

Let's implement StorageService, as follows:

import boto3class StorageService:    def __init__(self, storage_location):        self.client = boto3.client('s3')        self.bucket_name = storage_location    def get_storage_location(self):        return self.bucket_name    def list_files(self):        response = self.client.list_objects_v2(Bucket = self.bucket_name)        files = []

Get Hands-On Artificial Intelligence on Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.