Giter VIP home page Giter VIP logo

atv's Introduction

ATV

Asiointitietovaranto Django REST API

Pytest Codestyle codecov

Development with Docker

Prerequisites:

  • Docker
  • Docker Compose
  1. Create a docker-compose.env.yaml file in the project folder:

    • Use docker-compose.env.yaml.example as a base, it does not need any changes for getting the project running.
    • Set entrypoint/startup variables according to taste.
      • DEBUG, controls debug mode on/off
      • APPLY_MIGRATIONS, applies migrations on startup
      • CREATE_ADMIN_USER, creates an admin user with credentials admin:(password, see below) ([email protected])
      • ADMIN_USER_PASSWORD, the admin user's password. If this is not given, a random password is generated and written into stdout when an admin user is created automatically.
  2. Run docker-compose up

Optional steps

  1. Run migrations:

    • Taken care by the example env
    • docker exec atv-backend python manage.py migrate
  2. Create superuser:

    • Taken care by the example env
    • docker exec -it atv-backend python manage.py add_admin_user

Development without Docker

Prerequisites:

  • PostgreSQL 14
  • Python 3.11

Installing Python requirements

  • Run pip install -r requirements.txt
  • Run pip install -r requirements-dev.txt (development requirements)

Database

To setup a database compatible with default database settings:

Create user and database

sudo -u postgres createuser -P -R -S atv  # use password `atv`
sudo -u postgres createdb -O atv atv

Allow user to create test database

sudo -u postgres psql -c "ALTER USER atv CREATEDB;"

Daily running

  • Create .env file: touch .env
DEBUG=1
DATABASE_URL=postgres://atv:atv@localhost:5437/atv

# Optionals (with a default value on settings.py)
FIELD_ENCRYPTION_KEYS=
  • Set the DEBUG environment variable to 1.
  • Run python manage.py migrate
  • Run python manage.py add_admin_user
  • Run python manage.py runserver 0:8000

The project is now running at localhost:8000

Keeping Python requirements up to date

  1. Install pip-tools:

    • pip install pip-tools
  2. Add new packages to requirements.in or requirements-dev.in

  3. Update .txt file for the changed requirements file:

    • pip-compile requirements.in
    • pip-compile requirements-dev.in
  4. If you want to update dependencies to their newest versions, run:

    • pip-compile --upgrade requirements.in
  5. To install Python requirements run:

    • pip-sync requirements.txt

Code format

This project uses black, flake8 and isort for code formatting and quality checking. Project follows the basic black config, without any modifications.

Basic black commands:

  • To let black do its magic: black .
  • To see which files black would change: black --check .

pre-commit can be used to install and run all the formatting tools as git hooks automatically before a commit.

Running tests

  • Set the DEBUG environment variable to 1.
  • Run pytest.

atv's People

Contributors

a-rmz avatar antiaki-m avatar charn avatar github-actions[bot] avatar klempine avatar nicobav avatar tautvydasgustas1 avatar terovirtanen avatar

Stargazers

 avatar

Watchers

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