-
Make sure you have access to the repo and you have the required ssh keys setup for cloning.
-
Clone the repo
git clone https://github.com/Anirudh58/osb.git
-
Follows steps from https://brew.sh/
-
brew install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- add brew to your $PATH
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/anip/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Create a conda environment
conda create -n os_backend python=3.9
- Install all requirements
pip install -r requirements.txt
- Install postgresql
brew install postgresql@15
- Start postgresql
brew services start postgresql@15
- Create the opensports database
createdb osdb
- Create a local user for yourself.
createuser --interactive
- Edit alembic.ini file to point to the correct database url.
sqlalchemy.url = postgresql://<username>:<password>@localhost:5432/osdb
- Apply migrations. Make sure you have the latest code pulled from the repo. All migration versions reside in the
alembic/versionsfolder.
alembic upgrade head
- [Recommended] Run the following script to refresh all data.
cd osb
sh scripts/cricket/refresh.sh
- Run the following script to refresh the player data. If you want to completely wipe and repopulate, set
wipe_and_repopulatetoTruein the script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_players.py
- Run the following script to refresh the match data. If you want to completely wipe and repopulate, set
wipe_and_repopulatetoTruein the script. Make sure the player data is refreshed before running this script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_matches.py
- Run the following script to refresh the match data. If you want to completely wipe and repopulate, set
wipe_and_repopulatetoTruein the script. Make sure the player data is refreshed before running this script.
cd osb
PYTHONPATH=. python scripts/cricket/refresh_innings.py
- This will start the backend server on port localhost:8000.
uvicorn main:app --reload
- Use postman/insomnia to test the endpoints locally.