Skip to content

Latest commit

 

History

History
238 lines (170 loc) · 9.36 KB

File metadata and controls

238 lines (170 loc) · 9.36 KB

Connected Mobility Solution on AWS - Predictive Maintenance Module

Connected Mobility Solution on AWS | 🚧 Feature request | 🐛 Bug Report | ❓ General Question

Note: If you want to use the solution without building from source, navigate to the AWS Solution Page.

Solution Overview

CMS Predictive Maintenance is a practical example for implementing a new module within CMS on AWS. This module contains the necessary files for configuring a CMS on AWS module to be deployed via CMS Backstage. Compare the CMS Predictive Maintenance module file structure and files against existing CMS on AWS modules for a better idea of how to customize the CMS Predictive Maintenance module for your own usage.

For more information and a detailed deployment guide, visit the Connected Mobility Solution on AWS solution page.

Architecture Diagram

Machine Learning Pipeline

Architecture Diagram - Machine Learning Pipeline

Generative AI Agent

Architecture Diagram - Generative AI Agent

Sequence Diagram

Machine Learning Pipeline

Sequence Diagram - Machine Learning Pipeline

Generative AI Agent

Sequence Diagram - GenAI Agent

AWS CDK and Solutions Constructs

AWS Cloud Development Kit (AWS CDK) and AWS Solutions Constructs make it easier to consistently create well-architected infrastructure applications. All AWS Solutions Constructs are reviewed by AWS and use best practices established by the AWS Well-Architected Framework.

In addition to the AWS Solutions Constructs, the solution uses AWS CDK directly to create infrastructure resources.

Customizing the Module

Prerequisites

MacOS Installation Instructions

Pyenv Github Repository

brew install pyenv
pyenv install 3.12

Pipenv Github Repository

pip install --user pipenv
pipenv sync --dev

NVM Github Repository

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

NPM/Node Official Documentation

nvm install 18
nvm use 18

Manual Steps

Foundation Model Access Permissions

  • Access to Amazon Bedrock foundation models isn't granted by default. Follow the Bedrock Official Documentation to gain access to all the foundation Models.

Clone the Repository

git clone https://github.com/aws-solutions/connected-mobility-solution-on-aws.git
cd connected-mobility-solution-on-aws/source/modules/cms_predictive_maintenance/

Install Required Dependencies

make install

Unit Test

After making changes, run unit tests to make sure added customization pass the tests:

make test

Build the Module

The build script manages dependencies, builds required assets (e.g. packaged lambdas), and creates the AWS Cloudformation templates.

make build

Upload Assets to S3

make upload

Deploy on AWS

make deploy

Delete

make destroy

Usage

Run Amazon SageMaker Pipeline

  • Upload the dataset that you want to train a predictive model to the S3 bucket with the name stored in the SSM Parameter named /solution/cms/predictive-maintenance/predictor/pipeline/assets-bucket/name. The dataset should be named dataset.csv and can be present in any subfolder within the S3 bucket. All the columns of the CSV file except the last column are treated as inputs to the model and the last column values are treated as the output labels.
  • Open the SageMaker console
  • In the Applications and IDEs section, open the Studio subsection
  • Select the cms-predictive-maintenance-admin user profile and click Open Studio
  • In the SageMaker Studio console, open Pipelines and open the cms-predictive-maintenance-pipeline
  • Click the Execute button and fill in the input parameters
  • For the RawDatasetS3Uri, input the S3 URI of the dataset
  • Click Execute to run the pipeline

Amazon Bedrock Agent

Use the following scripts to test the chatbot functionality.

# Test RAG using the created Bedrock Knowledge Base
pipenv run python3 test_scripts/chatbot_query_knowledge_base.py --query "<insert query here>"

# Test orchestration using the created Bedrock Agent
pipenv run python3 test_scripts/chatbot_query_agent.py --query "<insert query here>"

APIs

API Path HTTP Method Description
/predict POST Provide an input to the trained SageMaker model and receive a prediction output
/batch-predict POST Upload a batch dataset as a CSV file to the S3 bucket whose name is stored in the SSM parameter named /solution/cms/predictive-maintenance/predictor/pipeline/assets-bucket/name and its object key being inference/latest.csv. This API will kick off a SageMaker BatchTransform job and store the results in the same S3 bucket with object key as inference/latest.csv.out

A postman collection is provided to test these API calls and provides the required API schema.

Cost Scaling

There is no cost the CMS Predictive Maintenance module.

For more details, see the implementation guide.

Collection of Operational Metrics

This solution collects anonymized operational metrics to help AWS improve the quality and features of the solution. For more information, including how to disable this capability, please see the implementation guide.

License

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.