Giter Site home page Giter Site logo

mypy-model's Introduction

Python I/O redirection with Docker example

Toy project experimenting how to use a Python app inside a Docker container to stream commands via STDIN and receive responses via STDOUT just like you would do with a local Python app.

Each line in STDIN is interpreted as a Base64-encoded JSON string containing the model inputs.

This might help in deciding how to invoke apps embedded with Docker.

Building the Docker image

docker build -t mypy-model .

Invoking it

The following command prints file input.json 10 times onto STDIN, encodes each of them via Base 64 and feeds the result to the model:

$ seq 1 10 | xargs -I{} sh -c "cat input.json | base64" | docker run --rm -i mypy-model
{"score": [{"Date_Time": "2017-07-30 12:05:00", "Predicted_Temperature": 29.961414831320837}, {"Date_Time": "2017-07-30 12:10:00", "Predicted_Temperature": 30.02936509060561}, {"Date_Time": "2017-07-30 12:15:00", "Predicted_Temperature": 30.201606037722854}, {"Date_Time": "2017-07-30 12:20:00", "Predicted_Temperature": 30.204359454268854}, {"Date_Time": "2017-07-30 12:25:00", "Predicted_Temperature": 30.046219875248795}, {"Date_Time": "2017-07-30 12:30:00", "Predicted_Temperature": 30.03961423865934}, {"Date_Time": "2017-07-30 12:35:00", "Predicted_Temperature": 30.157289798825246}, {"Date_Time": "2017-07-30 12:40:00", "Predicted_Temperature": 30.400845008340156}, {"Date_Time": "2017-07-30 12:45:00", "Predicted_Temperature": 30.56468920944036}, {"Date_Time": "2017-07-30 12:50:00", "Predicted_Temperature": 30.664924338250472}, {"Date_Time": "2017-07-30 12:55:00", "Predicted_Temperature": 30.59871479351105}, {"Date_Time": "2017-07-30 13:00:00", "Predicted_Temperature": 30.628119156333923}]}
...
{"score": [{"Date_Time": "2017-07-30 12:05:00", "Predicted_Temperature": 29.961414831320837}, {"Date_Time": "2017-07-30 12:10:00", "Predicted_Temperature": 30.02936509060561}, {"Date_Time": "2017-07-30 12:15:00", "Predicted_Temperature": 30.201606037722854}, {"Date_Time": "2017-07-30 12:20:00", "Predicted_Temperature": 30.204359454268854}, {"Date_Time": "2017-07-30 12:25:00", "Predicted_Temperature": 30.046219875248795}, {"Date_Time": "2017-07-30 12:30:00", "Predicted_Temperature": 30.03961423865934}, {"Date_Time": "2017-07-30 12:35:00", "Predicted_Temperature": 30.157289798825246}, {"Date_Time": "2017-07-30 12:40:00", "Predicted_Temperature": 30.400845008340156}, {"Date_Time": "2017-07-30 12:45:00", "Predicted_Temperature": 30.56468920944036}, {"Date_Time": "2017-07-30 12:50:00", "Predicted_Temperature": 30.664924338250472}, {"Date_Time": "2017-07-30 12:55:00", "Predicted_Temperature": 30.59871479351105}, {"Date_Time": "2017-07-30 13:00:00", "Predicted_Temperature": 30.628119156333923}]}

As a result, the output JSON prediction will be printed out 10 times on STDOUT.

mypy-model's People

Watchers

 avatar  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.