Giter VIP home page Giter VIP logo

fastapi_playground's Introduction

fastapi_playground

Place for studying and experimenting with FastAPI

Install

pip install -r requirements.txt

Locally test the API

  1. Run the API on terminal
uvicorn etl_api:app --reload --host=127.0.0.1 --port=9999
  1. Goto the APIHub Page: localhost:9999/docs

  2. Run the apitest:

python test_execution.py

Run the API server on colab and test it locally

  1. Run the colab notebook: ColabFastAPI.ipynb

  2. Replace the api url in test_colab_execution.py with that shown in the last cell of colab:

e.g., Colab api url: http://c26c-35-245-61-122.ngrok.io

  1. On local terminal, execute test_colab_execution.py

Run the Ray server in container and port it to the internet via fastapi

  1. Build a image with ray serving
docker build -t ray_server .
  1. Run the image as container and start the API inside
docker run -it -p 9999:9999 --shm-size=4.80gb --rm ray_server bash
  1. Run start.sh in the container
redis-server &
echo 'redis started'
env RAY_LOG_TO_STDERR=1 ray start --head --port=7000 --redis-shard-ports=6379
sleep 20
uvicorn executor_api:app --host 172.17.0.2 --port 9999
  1. Build an router api that connect the in-container API to the outside world

Run on stand alone MAC account

Create a minimum privilege user account

Install python envirnoment for ray

follow REF: https://docs.ray.io/en/master/ray-overview/installation.html#m1-mac-apple-silicon-support

Install packages:

pip install -r requirements.txt

Run ray

ray start --head

Run API

python etl_api.py

fastapi_playground's People

Contributors

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