Skip to content

Latest commit

 

History

History
executable file
·
89 lines (65 loc) · 2.22 KB

File metadata and controls

executable file
·
89 lines (65 loc) · 2.22 KB

Open Prediction Service for Amazon SageMaker

This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

This example uses the Connexion library on top of Flask.

  1. Getting Started

  2. Open Prediction Service

Getting Started

Prerequisites

Python 3.7

Docker

Run the microservice on a Docker container

To build the microservice image

docker build -t sagemaker-service .

To run the microservice

docker run \
    -p 8080:8080 \
    -e AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> \
    -e AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY> \
    -e AWS_DEFAULT_REGION=<AWS_DEFAULT_REGION> \
    --name sagemaker-service \
    sagemaker-service

If you want to run the microservice on another port

docker run \
    -p <PORT>:8080 \
    -e AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> \
    -e AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY> \
    -e AWS_DEFAULT_REGION=<AWS_DEFAULT_REGION> \
    --name sagemaker-service \
    sagemaker-service

To check that you have a running container

docker ps -f name=sagemaker-service

Your predictive service is available at http://localhost:8080/.

Swagger UI documentation is available at http://localhost:8080/ui

Or on the port of choice rescpectively at http://localhost:<PORT>/ and http://localhost:<PORT>/ui

Stop the microservice

To stop the container

docker stop sagemaker-service

Run the microservice without Docker

pip3 install -r requirements.txt
python3 -m swagger_server

Tests

To launch unit tests, use tox:

pip3 install tox
tox

To launch tests on your SageMaker instance:

First, make sure you have a working and configured environment to use AWS SDK (Option 3, 4 or 5 as described in AWS SDK documentation)

Then, run tests using tox:

pip3 install tox
tox swagger_server/test