Code Monkey home page Code Monkey logo

ts-stationarity-micro's Introduction

Python application test with Github Actions Python application test with AWS Code Builde Code style: black

Time Series Stationarity Test Microservice

Microservice Diagram

Containerized microservice for Time Series stationarity testing with Augmented Dickey-Fuller (ADF) and Kwiatkowski-Phillips-Schmidt-Shin (KPSS) tests.

About this Repository

This is a template repository of a containerized Python Flask Microservice with best CI/CD practices for local deployment or in the cloud.

An AWS CodeBuild workflow is configured to push the latest Docker image to an AWS ECR (Elastic Container Registry). The build is set to trigger on every push to the GitHub repository via buildspec.yml (AWS CodeBuild) and main.yml (GitHub Actions).

AWS

This microservice template can be deployed in most AWS scalable IaaS solutions such as Elastic Beanstalk, AWS EKS, and AWS Fargate + AWS ECS. The build is fully integrated within the AWS environment, from the base Python 3.9 Docker image that is pulled from AWS public container registry, to the final development image that is pushed to the project AWS ECR repository.

The IAM role permissions to push to an ECR repository can be found in this link.

For a sample deployment with AWS Elastic Beanstalk you can follow the procedures in this template repository. Make sure you create an AWS ECR repository and update the Makefile with your repository URI that can be found under 'View push commands'.

Local Deployment - Docker

For the following steps you need a version of Docker Desktop installed in your working environment.

Clone the Repository:

Clone and cd to the repository folder

$ git clone [email protected]:erich-hs/ts-stationarity-micro.git
$ cd ts-stationarity-micro

Docker Image:

Build image locally

$ docker build --tag ts-micro .

Check built image

$ docker image ls

Run a -d dettached local container based on built image, and map localhost:8080 to container port 8080

$ docker run -p 127.0.0.1:8080:8080 --name ts-micro-local -d ts-micro

Docker should return the container ID. You can see it running with

$ docker ps

You can now curl from the local machine to send data with a POST method

$ curl -d '{"timeseries":[1, 2, 3, 4]}' \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/test_stationarity

Shutting down:

Shut down the container

$ docker stop ts-micro-local

Remove the container

$ docker rm ts-micro-local

Local Deployment - Native Environment

To post a sample stationarity test:

Add executable permission to sample_post.sh:

$ chmod +x ./sample_post.sh

Execute sample_post.sh

$ ./sample_post.sh

To directly access the Python function:

Call the python interpeter -c code:

$ python -c 'import stationarity; print(stationarity.stationarity_test([1, 2, 3, 4]))'

To host the application in the local machine:

Run the Flask app locally:

$ python app.py

POST method

$ curl -d '{"timeseries":[1, 2, 3, 4]}' \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/test_stationarity

To run from your CLI:

Call the custom CLI function

$ python cli.py

It should prompt you for the time series input:

List-like, comma separated time series: 1, 2, 3, 4

After inserting a comma separated example the result should be similar to the output below:

image

ts-stationarity-micro's People

Contributors

erich-hs avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.