This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM public.ecr.aws/lambda/python:3.8 | |
| # Install dependencies | |
| COPY requirements.txt /tmp/ | |
| RUN pip3 install -r /tmp/requirements.txt --no-cache | |
| # Copy inference code | |
| COPY predict.py ${LAMBDA_TASK_ROOT}/ | |
| CMD [ "predict.handler" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import boto3 | |
| import joblib | |
| import pandas as pd | |
| # download model file from S3 into /tmp folder | |
| s3 = boto3.client('s3') | |
| bucket = os.environ['BUCKET'] | |
| key = os.environ['KEY'] | |
| s3.download_file(bucket, key, '/tmp/model.pkl') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "length": -0.158164, | |
| "diameter": -0.280982, | |
| "height": -0.227545, | |
| "whole_weight": -0.352298, | |
| "shucked_weight": -0.596421, | |
| "viscera_weight": -0.019102, | |
| "shell_weight": -0.135293, | |
| "sex_M": 0.0, | |
| "sex_F": 0.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import boto3 | |
| import logging | |
| import argparse | |
| import requests | |
| logger = logging.getLogger(__name__) | |
| api_client = boto3.client('apigatewayv2') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: 0.2 | |
| phases: | |
| install: | |
| runtime-versions: | |
| python: 3.8 | |
| commands: | |
| - npm install -g [email protected] | |
| - pip install --upgrade --force-reinstall botocore boto3 awscli |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import xgboost | |
| import pandas as pd | |
| import pickle as pkl | |
| from utils import extract_model | |
| # download model file from S3 into /tmp folder | |
| extract_model(os.environ['MODEL_S3_URI'], '/tmp') | |
| # LOAD MODEL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM public.ecr.aws/lambda/python:3.8 | |
| # Install dependencies | |
| COPY requirements.txt /tmp/ | |
| RUN pip3 install -r /tmp/requirements.txt --no-cache | |
| # Copy inference code | |
| COPY predict.py utils.py ${LAMBDA_TASK_ROOT}/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from locust.contrib.fasthttp import FastHttpUser | |
| from locust import between, task | |
| class ApiUser(FastHttpUser): | |
| wait_time = between(1, 3) | |
| @task() | |
| def predict_lambda(self): | |
| payload = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import invokust | |
| from load_test.api_user import ApiUser | |
| def run_load_test(host): | |
| settings = invokust.create_settings( | |
| classes=[ApiUser], | |
| host=host, | |
| num_users=1000, | |
| spawn_rate=100, | |
| run_time='1m' |