Sign inSign up

nopatience/core

By nopatience

Updated over 7 years ago

Core service

Image
0

258

nopatience/core repository overview

NoPatience Core

Core is the server side for NoPatience. It handles database migrations and connections as well as exposing a RESTful API for interacting with any stored data.

Requirements

Python 3.6 - currently 3.7 is not supported as it introduces breaking changes to some of the libraries this application depends on.

Entry Points

There are two entry points to the Core server.

The first is main.py which is capable of being the entry point to uWSGI, and it is also capable of running a development server without uWSGI.

The second entry point is Migrator.py which is used for DB migration management. Migrations are explained in more detail below.

Quickstart

To run NoPatience/Core in development mode, uncomment the last line found in main.py and run it using a python interpreter. It is highly suggested to use a Python VENV to do this as to not pollute your global python interpreter.

Migrations

Recommend to use a venv to run these commands as installing flask on your global python interpreter is not advised.

The migrations will be run each time the server is started. If you are deploying this. you should not need to manually run the migrations

More details: https://flask-migrate.readthedocs.io/en/latest/#command-reference

Getting Setup to run Migration commands:
  • On Linux: export FLASK_APP=migrator.py
  • On Windows: set FLASK_APP=migrator.py

You also require a running DB server which can be connected to.

Migrations:

Run all of these commands from the repository root.

Setup
  • Setting up migrations: flask db init --directory src/db/migrations
Creating new Migrations

Anytime you create new tables, or change tables a new migration must be created.

Creating new migrations requires a DB connection unless you run them offline.

** Note: Anytime you create a new model, it MUST be imported in the __init__.py file found in src.db.models **

  • Creating migrations: flask db migrate --directory src/db/migrations --message "message here"
Creating migrations offline (NOT Suggested)

https://alembic.zzzcomputing.com/en/latest/offline.html

Cautions and Warnings

Taken from the Flask-Migrate docs which was taken from the Alembic docs: https://flask-migrate.readthedocs.io/en/latest/

The migration script needs to be reviewed and edited, as Alembic currently does not detect every change you make to your models. In particular, Alembic is currently unable to detect table name changes, column name changes, or anonymously named constraints. A detailed summary of limitations can be found in the Alembic autogenerate documentation. Once finalized, the migration script also needs to be added to version control.

Running Migrations
  • Running migrations: flask db upgrade --directory src/db/migrations

Documentation

Tag summary

Content type

Image

Digest

Size

390.2 MB

Last updated

over 7 years ago

docker pull nopatience/core