Before you begin, ensure you have installed:
- Docker
- Docker Compose
- AWS CLI
- Python 3.11.3 (or the Python version referenced in the
Dockerfile) - DBeaver or another database GUI tool for PostgresQL
- (optional)
pyenv local 3.11.3This command set python version 3.11.3 only for the project - (optional)
python --versionCheck ifpython 3.11.3is set for the project - (optional)
python -m venv venvWill creat venv environment - (optional)
source venv/Scripts/activateWill activate venv environment (need to check path)
git clone https://github.com/WGU-edu/smart-owlcd smart-owlpip install --no-cache-dir --upgrade -r requirements.txt
-
Create a file named
.envinside the project root directory and add the following content# AWS AWS_REGION=us-west-2 # DynamoDB DYNAMO_DB_TABLE=openai-call-log DYNAMO_DB_ENDPOINT=http://localhost:8000 # OpenAI OPEN_AI_KEY=[[OPENAI KEY HERE]] # PostgreSQL POSTGRES_USER=user POSTGRES_PASSWORD=password POSTGRES_SERVER=localhost POSTGRES_PORT=5432 POSTGRES_DB=chatbot-rag # Redis REDIS_HOST=localhost REDIS_PORT=6379 ##### DATABRICKS ##### DATABRICKS_HOST=https://wgu-prod.cloud.databricks.com ENVIRONMENT=dev # Service principal: "dev" DATABRICKS_SP_CLIENT_ID=[[SP CLIENT ID HERE]] DATABRICKS_SP_SECRET=[[SP SECRET HERE]]
-
Add the following profile to the file
~/.aws/config[profile local] region = us-west-2 output = json -
Add the following credentials for the
localprofile to~/.aws/credentials[local] aws_access_key_id = accesskeyid aws_secret_access_key = secretaccesskey
-
Comment some parts in source code in order to manually add a superuser via Swagger UI (this part should be reverted after adding a superuser)
app/db/models/user.py-> comment foravailable_modelsapp/apis/v1/route_user.py->create_user: removecurrent_userparameter and commentis_super_userblockapp/db/repository/user.py->create_new_user: commentavailable_modelsapp/schemas/user.py-> comment all lines related toavailable_models
-
Create initial docker images by running
docker-compose -f run_locally/docker-compose.dev.yml up --build--buildflag ensures that Docker will rebuild the images specified in the Dockerfile if they are out of date or if there have been any changes to the Dockerfile or the files it copies into the container.- Docker will first build the application image by following the steps in the
Dockerfile. nginx.conffile should be inrun_locallyfolder to run nginx- execute all commands inside YAML file
localhost:8080will be reachable
-
Create a superuser via Swagger UI in
localhost:8080/docs
-
Stop all containers and remove them by running
docker stop $(docker ps -q)anddocker rm $(docker ps -aq) -
Run PostgreSQL, DynamoDB, Reddis by running
docker-compose -f run_locally/docker-compose.dbs.yml up -d-fflag specifies the path to the Docker Compose YAML file,-d: This flag runs the containers in detached mode, meaning the command will run in the background -
Connect to postgreSQL database server via GUI (DBeaver or Other) by using credentials provided in
docker-compose.dbs.ymlfile- Check if
available_columnsare not added inusertable at this time
- Check if
-
Upgrade your database schema by running
alembic upgrade headto the latest version as defined by your migration scripts- All versions defined in
alembic/versionsfolder will be executed sequentially alembic.inishould exist inside project root folder
- All versions defined in
-
Check
usertable ifavailable_modelsis added
- Uncomment all source code in Section 2
./run_locally/init-local-ddb.shaws dynamodb list-tables --endpoint-url http://localhost:8000 --profile localwill list all tables in dynamodb- Manually accessible to local dynamodb server by configuring provided in
.envfile on AWS NoSQL Workbench GUI openai-call-logtable should be found
RUN_LOCALLY=true uvicorn app.main:app --host "localhost" --port 8080 --reloaddocker-compose -f run_locally/docker-compose.dev.yml up --build --scale api=2
Run localhost:8080