GithubHelp home page GithubHelp logo

fastapi_1's Introduction

test4

fastapiv2

uvicorn main:app --reload --host 0.0.0.0 --port 8080

Development Requirements

  • Python3.11.0
  • Pip
  • Poetry (Python Package Manager)

Installation

python -m venv venv
source venv/bin/activate
make install

Runnning Localhost

make run

Deploy app

make deploy

Running Tests

make test or pytest

Access Swagger Documentation

http://localhost:8080/docs

Access Redocs Documentation

http://localhost:8080/redoc

Project structure

Files related to application are in the app or tests directories. Application parts are:

app
|
| # Fast-API stuff
├── api                 - web related stuff.
│   └── routes          - web routes.
├── core                - application configuration, startup events, logging.
├── models              - pydantic models for this application.
├── services            - logic that is not just crud related.
├── main-aws-lambda.py  - [Optional] FastAPI application for AWS Lambda creation and configuration.
└── main.py             - FastAPI application creation and configuration.
|
├── data             - where you persist data locally
│   ├── interim      - intermediate data that has been transformed.
│   ├── processed    - the final, canonical data sets for modeling.
│   └── raw          - the original, immutable data dump.
│
└── tests            - pytest

GCP

Deploying inference service to Cloud Run

Authenticate

  1. Install gcloud cli
  2. gcloud auth login
  3. gcloud config set project <PROJECT_ID>

Enable APIs

  1. Cloud Run API
  2. Cloud Build API
  3. IAM API

Deploy to Cloud Run

  1. Run gcp-deploy.sh

Clean up

  1. Delete Cloud Run
  2. Delete Docker image in GCR

AWS

Deploying inference service to AWS Lambda

Authenticate

  1. Install awscli and sam-cli
  2. aws configure

Deploy to Lambda

  1. Run sam build
  2. Run `sam deploy --guiChange this portion for other types of models

Add the correct type hinting when completed

aws cloudformation delete-stack --stack-name <STACK_NAME_ON_CREATION>

Made by https://github.com/arthurhenrique/cookiecutter-fastapi/graphs/contributors with ❤️

Notes:

INSERT INTO notes (text, completed) VALUES ('first' , TRUE); INSERT INTO notes (text, completed) VALUES ('second' , TRUE);

docker exec test4-app-1 pytest

db_url = make_url(str(settings.db_url.with_path("/postgres"))) engine = create_async_engine(db_url, isolation_level="AUTOCOMMIT")

async with engine.connect() as conn:
    database_existance = await conn.execute(
        text(
            f"SELECT 1 FROM pg_database WHERE datname='{settings.db_base}'",  # noqa: E501, S608
        ),
    )
    database_exists = database_existance.scalar() == 1

if database_exists:
    print("Deleting DB")
    await drop_database()

async with engine.connect() as conn:  # noqa: WPS440
    await conn.execute(
        text(
            f'CREATE DATABASE "{settings.db_base}" ENCODING "utf8" TEMPLATE template1',  # noqa: E501
        ),
    )

fastapi_1's People

Watchers

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