Skip to content

Commit

Permalink
adds makefile, closes the-full-stack#6
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesfrye committed Feb 1, 2023
1 parent c4a8e34 commit b8b0a47
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
OPENAI_API_KEY=
PYTHON_VERSION=

MODAL_TOKEN_ID=
MODAL_TOKEN_SECRET=
MODAL_USER_NAME=charlesfrye

DISCORD_AUTH=
MONGODB_URL=

MONGODB_URI=
MONGODB_PASSWORD=
PYTHON_VERSION=3.10.9
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ifneq (,$(wildcard ./.env))
include .env
# assume includes MODAL_TOKEN_ID and MODAL_TOKEN_SECRET for modal auth,
# assume includes MODAL_USER_NAME and DISCORD_AUTH for running discord bot
# assume includes MONGODB_URI and MONGODB_PASSWORD for document store setup
export
endif

.PHONY: help
.DEFAULT_GOAL := help

help: ## get a list of all the targets, and their short descriptions
@# source for the incantation: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}'

discord_bot: environment ## run the Discord bot frontend locally
@echo "###"
@echo "# 🥞: Assumes you've set up your bot and deployed the backend on Modal"
@echo "###"
python run_bot.py

deploy_backend: modal_auth ## deploy the Q&A backend on Modal
@echo "###"
@echo "# 🥞: Assumes you've set up the vector storage"
@echo "###"
modal deploy app.py

local_query: modal_auth ## run a test query locally
@echo "###"
@echo "# 🥞: Assumes you've set up the vector storage"
@echo "###"
modal run app.py::stub.cli --query "What is PyTorch?"

document_storage: dev_environment ## runs the corpus generation notebook locally, stor
@echo "###"
@echo "# 🥞: Assumes you've created a Mongo database with name fsdl and collection ask-fsdl first"
@echo "###"
nbconvert jupyter nbconvert --ExecutePreprocessor.timeout=600 --to notebook --execute "Building the FSDL Corpus.ipynb"

vector_storage: modal_auth ## updates a Pinecone vector store to contain embeddings of the document corpus
@echo "###"
@echo "# 🥞: Assumes you've set up the document storage
@echo "###"
modal run app.py::stub.sync_vector_db_to_doc_db

debugger: modal_auth ## starts a debugger in the terminal running on Modal's infra
modal run app::stub.debug

modal_auth: environment ## confirms authentication with Modal, using secrets from `.env` file
@echo "###"
@echo "# 🥞: If you haven't gotten a Modal token yet, run make modal_token
@echo "###"
@modal token set --token-id $(MODAL_TOKEN_ID) --token-secret $(MODAL_TOKEN_SECRET)

modal_token: environment ## creates token ID and secret for authentication with modal
modal token new
@echo "###"
@echo "# 🥞: Copy the token info from the file mentioned above into .env"
@echo "###"

environment: ## installs required environment for deployment
pip install -qqq -r requirements.txt

dev_environment: ## installs required environment for document corpus generation
pip install -qqq -r requirements-dev.txt

0 comments on commit b8b0a47

Please sign in to comment.