Team Ai
Apppublic

Decoder2704/python-chatbot-jay

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
PRE_DEPLOY_CHECKLIST.md143 linesDownload Raw Back to docs
1# Pre-deployment checklist — Hugging Face Docker Space (React + FastAPI)2 3Run these **before** pushing to a Space or tagging a release. Order is suggested, not strict.4 5---6 7## 1. Artifacts exist (retrieval)8 9From repo root, verify files are present and non-empty:10 11```bash12ls -la backend/artifacts/vectorizer.pkl \13       backend/artifacts/question_vectors.pkl \14       backend/artifacts/chatbot_df.pkl15```16 17**Pass:** All three exist with non-zero size.  18**If missing:** Build locally per `backend/RUN_STEPS.md` / `scripts/run_all_build_steps.py` (or your pipeline), then re-check.19 20---21 22## 2. Dataset / artifact paths (notebook-aligned layout)23 24Paths are resolved from `backend/app/paths.py` (not shell `cwd`). Quick sanity check:25 26```bash27cd backend && python -c "28from app.paths import (29    ARTIFACT_VECTORIZER_PATH,30    ARTIFACT_QUESTION_VECTORS_PATH,31    ARTIFACT_CHATBOT_DF_PATH,32    DATA_DIR,33    ARTIFACTS_DIR,34)35print('ARTIFACTS_DIR:', ARTIFACTS_DIR)36print('DATA_DIR:     ', DATA_DIR)37for p in (ARTIFACT_VECTORIZER_PATH, ARTIFACT_QUESTION_VECTORS_PATH, ARTIFACT_CHATBOT_DF_PATH):38    print(p, 'OK' if p.is_file() else 'MISSING')39"40```41 42**Pass:** Each artifact prints `OK`.  43**Note:** `backend/data/` should contain your pipeline outputs if the app expects them at runtime.44 45---46 47## 3. FastAPI starts locally48 49```bash50cd backend51python -c "from app.main import app; print('import ok')"52```53 54Optional full smoke (loads artifacts):55 56```bash57cd backend && uvicorn app.main:app --host 127.0.0.1 --port 800058```59 60In another terminal (or the same machine), **open the app in a browser** (integrated dev setup below) and send a test message in chat.61 62**Pass:** Health and chat behavior look correct from the UI (successful reply payload in the chat thread). Stop uvicorn with Ctrl+C when done.63 64---65 66## 4. React builds successfully67 68```bash69cd frontend70npm ci71npm run build72```73 74**Pass:** Completes with no errors; `frontend/dist/` contains `index.html` and `assets/`.75 76---77 78## 5. Frontend + backend locally (integrated)79 80**Option A — Vite dev + API (recommended for UI dev)**81 82Terminal 1:83 84```bash85cd backend && uvicorn app.main:app --host 127.0.0.1 --port 800086```87 88Terminal 2:89 90```bash91cd frontend && npm run dev92```93 94Open the URL Vite prints (e.g. `http://localhost:5173`). Send a message; confirm a bot reply.  95**Pass:** No console CORS errors if using default relative API + Vite proxy (`vite.config.js`).  96If you use `VITE_API_URL` in `.env.local`, confirm backend **CORS** allows your dev origin.97 98**Option B — Same as Docker (optional)**99 100Build UI and point backend at static files (if `backend/static/dist` exists):101 102```bash103cd frontend && npm run build104mkdir -p ../backend/static/dist && cp -r dist/* ../backend/static/dist/105cd ../backend && uvicorn app.main:app --host 127.0.0.1 --port 8000106```107 108Open `http://127.0.0.1:8000/`. **Pass:** SPA loads and chat works against same origin.109 110---111 112## 6. Docker build works locally113 114From **repository root** (where `Dockerfile` lives):115 116```bash117docker build -t pybot-hf-test .118```119 120Run (maps HF-style port):121 122```bash123docker run --rm -p 7860:7860 pybot-hf-test124```125 126Open `http://127.0.0.1:7860/` in a browser — UI should load; send one chat and confirm a reply.  127**Pass:** Build succeeds; container stays up; UI and chat flow OK.  128**Remind:** Image must include `backend/data` and `backend/artifacts` if those directories are in the build context (not excluded by `.dockerignore`).129 130---131 132## 7. Git / Space push (quick)133 134- [ ] `README.md` has Hugging Face YAML (`sdk: docker`, `app_port: 7860`) if you use card metadata  135- [ ] No secrets in repo (`.env`, API keys)  136- [ ] Large files: confirm Space / Git limits; use Git LFS or external storage if needed  137 138---139 140## One-line summary141 142**Artifacts OK → paths OK → uvicorn OK → `npm run build` OK → dev or Docker smoke OK → then push.**143