Giter Club home page Giter Club logo

cpho-phase2's Introduction

CPHO server

See the CPHO slack channel's link bar for the dev app's URL

Setting up the development environment

Note: run all this in the repo's root directory

  1. install python3.10

  2. install postgres instructions here

  3. clone repo

  4. create a virtual environment in repo root (python -m venv venv)

  5. activate virtual environment (source venv/Scripts/activate on windows, venv/bin/activate on *nix)

  6. install dependencies (pip install -r server/requirements.txt -r server/requirements_dev.txt)

  7. (if applicable) Start the db server: pg_ctl -D ~/pg/data/ -l logfile start

  8. setting postgres:

    ./server/dev-db-init.sh
    
  9. seed the DB

    •   python ./manage.py migrate
        python ./manage.py loaddata cpho/fixtures/dimension_lookups.yaml
        python ./manage.py loaddata cpho/fixtures/periods.yaml
        python -m manage seed_countries --mode reset --yes
        python ./manage.py runscript cpho.scripts.dev
  10. python manage.py runserver

Other useful dev commands:

resetting dev db:

dropdb -U cpho_db_user cpho_dev_db;
createdb -U cpho_db_user cpho_dev_db;

Resetting test db (useful when migrations get in the way of running tests)

dropdb -U cpho_db_user cpho_test_db

Manually running format commands

In the case your CI is failing due to formatting issues, you can run the following commands to fix them all.

  1. isort server --settings-path pyproject.toml
  2. black server/ --config pyproject.toml
  3. djlint --reformat server --configuration pyproject.toml

Using SQlite

Note: if you set USE_SQLITE=True in your .env file, you don't need to set any of the DB-related environment variables and the app will use sqlite instead of postgres. This is useful for testing/development, especially on the PHAC workstations. Note that changelogs won't work with sqlite, so those tests will always fail.

Remote DB manipulation

To connect to the remote DB from your local machine, download, chmod and ensure the cloud-sql-proxy is in your path, then run source deploy/connect_cloud_sql_proxy.sh. In a different shell, you can now run ./manage.py commands directly against the remote DB. Be careful and make sure you close the script process when you're done.

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.