Make a .gitignore file in the root directory and include the following code:
client_secret.json
.env
venv/
**/__pycache__/
*.pyc
.DS_Store
(ignore this step if already have venv) If there isn't a venv folder, run python3 -m venv venv in terminal to create an venv.
-
Next, run the following command to activate venv
- macOS:
source venv/bin/activate - windows:
venv\Scripts\activate
- macOS:
-
Once activated, you can install dependencies by
- dev environment:
pip install -e ".[dev]" - production environment:
pip install .
- dev environment:
-
If you encounter an error with psycogp2, run
brew install postgresqlfirst. -
Note: if you install new dependencies, make sure to add it to
pyproject.toml- If runtime dependency -> [project.dependencies]
- If dev/test only -> [project.optional-dependencies].dev◊
Open a terminal (in the backend folder with virtual environment), run python run.py to start the Flask app.
Run pytest in the terminal.
- Note: uses cmucal-test project on supabase for test db
(ignore this unless told otherwise) IF need to get the table schema from Supabase: in the terminal, run sqlacodegen [SUPABASE_DB_URL from env file] --outfile models.py
- comment out the
class Basesection inmodels.py - add
from app.services.db import Baseto the top ofmodels.py - change all capitalized class names from plural to singular. i.e. class Events --> class Event. Don't change the lowercase names in quotes.
(ignore this unless told otherwise)
Note: add APP_ENV=development or APP_ENV=production before you run any alembic operations.
Example commands:
APP_ENV=development alembic revision --autogenerate -m "<insert your message>"
APP_ENV=development alembic upgrade head
APP_ENV=test alembic upgrade head
APP_ENV=production alembic upgrade head
upgrade head= run migrations + bump version.stamp head= bump version only, no migrations executed.
- see scraper readme instructions on
export_soc. Edit Railway cron job at this link.
(ignore this unless told otherwise) IF need to scrape data from handshake, tartanconnect, si, peer tutoring
git pullthe scraper branch, and switch to this branchcd scraper- Run these commands:
python exporters/handshake_export_to_excel.pypython exporters/tartanconnect_export_to_excel.pypython exporters/si_export_to_excel.pypython exporters/peer_tutoring_export_to_excel.py
- Then you can see an excel sheet exported to the base folder