Guide to deploying Amazon Chronos, a time-series database, using AWS Lambda Web Adapter.
Python
4
3 commits
updated Aug 25, 2024
This repository provides a simple guide to deploying Amazon Chronos, a time-series database, using AWS Lambda Web Adapter. By using Lambda, you can run Chronos without worrying about servers. This setup is cost-effective and scales automatically, making it easier to manage your time-series data in the cloud.
Key Dependencies:
Other references:
main.py: Implementation Using Chronos and Example with FastAPItest_main.py: Testing FastAPI with Pytestlive-demo-scripts.md: Cheat Sheet for Live Demodemo_seq.csv: Time-series data for demoPrepare:
git clone https://github.com/ma2shita/amazon-chronos-with-lambda-web-adapter
cd amazon-chronos-with-lambda-web-adapter
python3 -m venv chronos-libs
source chronos-libs/bin/activate
pip install -U pip
pip install "huggingface_hub[cli]"
pip install git+https://github.com/amazon-science/chronos-forecasting.git
pip install uvicorn fastapi pandas matplotlib
pip install pytest httpx
huggingface-cli download amazon/chronos-t5-tiny
pytest test_main.py
#=> Congrats! You can edit `main.py` and `test_main.py`.
uvicorn --reload --port=8080 main:app
#=> curl localhost:8080
#=> curl -X POST -H "Content-Type:application/json" -d '{"historical":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]}' localhost:8080/forecast.json
cd amazon-chronos-with-lambda-web-adapter
source chronos-libs/bin/activate
pytest test_main.py
## Prepare
aws ecr create-repository --repository-name ${REPO_NAME} # Can be made in the management console.
## Build
docker buildx build --target prod_runner .
#=> You can enter container: `docker run -it --rm ${NEW_IMAGE_ID_AND_TAG} /bin/bash`
docker tag ${NEW_IMAGE_ID_AND_TAG} ${ECR_URL_AND_TAG}
aws ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNTID}.dkr.ecr.${REGION}.amazonaws.com
docker push ${ECR_URL_AND_TAG}
## NEXT: Create or Update a Lambda function based on this container
## Tips: Update a Lambda function via AWS CLI
aws lambda update-function-code --function-name ${MY-FUNCTION} --image-uri ${ECR_URI}
while true ; do aws lambda get-function --function-name amazon-chronos-t5-tiny_fastapi0 | jq -r .Configuration.LastUpdateStatus ; sleep 5 ; done
# waiting for `Successful`
Chronos
Tools and Developments
This project is maintained by Kohei "Max" MATSUSHITA.
If you have any questions or suggestions, feel free to reach out via GitHub.
We welcome contributions to this project! Here’s how you can help:
Thank you for your contributions!
This project is licensed under the MIT License - see the LICENSE file for details.
EoT
Guide to deploying Amazon Chronos, a time-series database, using AWS Lambda Web Adapter.
Python
4
3 commits
updated Aug 25, 2024
This repository provides a simple guide to deploying Amazon Chronos, a time-series database, using AWS Lambda Web Adapter. By using Lambda, you can run Chronos without worrying about servers. This setup is cost-effective and scales automatically, making it easier to manage your time-series data in the cloud.
Key Dependencies:
Other references:
main.py: Implementation Using Chronos and Example with FastAPItest_main.py: Testing FastAPI with Pytestlive-demo-scripts.md: Cheat Sheet for Live Demodemo_seq.csv: Time-series data for demoPrepare:
git clone https://github.com/ma2shita/amazon-chronos-with-lambda-web-adapter
cd amazon-chronos-with-lambda-web-adapter
python3 -m venv chronos-libs
source chronos-libs/bin/activate
pip install -U pip
pip install "huggingface_hub[cli]"
pip install git+https://github.com/amazon-science/chronos-forecasting.git
pip install uvicorn fastapi pandas matplotlib
pip install pytest httpx
huggingface-cli download amazon/chronos-t5-tiny
pytest test_main.py
#=> Congrats! You can edit `main.py` and `test_main.py`.
uvicorn --reload --port=8080 main:app
#=> curl localhost:8080
#=> curl -X POST -H "Content-Type:application/json" -d '{"historical":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]}' localhost:8080/forecast.json
cd amazon-chronos-with-lambda-web-adapter
source chronos-libs/bin/activate
pytest test_main.py
## Prepare
aws ecr create-repository --repository-name ${REPO_NAME} # Can be made in the management console.
## Build
docker buildx build --target prod_runner .
#=> You can enter container: `docker run -it --rm ${NEW_IMAGE_ID_AND_TAG} /bin/bash`
docker tag ${NEW_IMAGE_ID_AND_TAG} ${ECR_URL_AND_TAG}
aws ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNTID}.dkr.ecr.${REGION}.amazonaws.com
docker push ${ECR_URL_AND_TAG}
## NEXT: Create or Update a Lambda function based on this container
## Tips: Update a Lambda function via AWS CLI
aws lambda update-function-code --function-name ${MY-FUNCTION} --image-uri ${ECR_URI}
while true ; do aws lambda get-function --function-name amazon-chronos-t5-tiny_fastapi0 | jq -r .Configuration.LastUpdateStatus ; sleep 5 ; done
# waiting for `Successful`
Chronos
Tools and Developments
This project is maintained by Kohei "Max" MATSUSHITA.
If you have any questions or suggestions, feel free to reach out via GitHub.
We welcome contributions to this project! Here’s how you can help:
Thank you for your contributions!
This project is licensed under the MIT License - see the LICENSE file for details.
EoT