feat: ⚙️🐞 configure debugger for the backend (#1345)

This commit is contained in:
Matthieu Jacq 2023-10-09 15:23:13 +02:00 committed by GitHub
parent d2fcb737b7
commit fa92243a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 7 deletions

View File

@ -18,4 +18,4 @@ MODEL_PATH=./local_models/ggml-gpt4all-j-v1.3-groovy.bin
RESEND_API_KEY=<change-me>
RESEND_EMAIL_ADDRESS=onboarding@resend.dev
CRAWL_DEPTH=1
CRAWL_DEPTH=1

24
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend",
"remoteRoot": "."
}
],
"justMyCode": true
}
]
}

24
backend/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true
}
]
}

View File

@ -1,6 +1,9 @@
# Using a slim version for a smaller base image
FROM python:3.11-slim-bullseye
ARG DEV_MODE
ENV DEV_MODE=$DEV_MODE
# Install GEOS library, Rust, and other dependencies, then clean up
RUN apt-get update && apt-get install -y \
libgeos-dev \
@ -28,6 +31,8 @@ RUN pip install --upgrade pip
# Increase timeout to wait for the new installation
RUN pip install --no-cache-dir -r requirements.txt --timeout 200
RUN if [ "$DEV_MODE" = "true" ]; then pip install --no-cache debugpy --timeout 200; fi
# Copy the rest of the application
COPY . .

View File

@ -29,6 +29,12 @@ from routes.user_routes import user_router
logger = get_logger(__name__)
if (os.getenv("DEV_MODE") == "true"):
import debugpy
logger.debug("👨‍💻 Running in dev mode")
debugpy.listen(("0.0.0.0", 5678))
sentry_dsn = os.getenv("SENTRY_DSN")
if sentry_dsn:
sentry_sdk.init(

View File

@ -1,4 +1,4 @@
version: '3'
version: "3"
services:
frontend:
@ -22,6 +22,8 @@ services:
build:
context: backend
dockerfile: Dockerfile
args:
- DEV_MODE=true
container_name: backend-core
restart: always
volumes:
@ -31,14 +33,15 @@ services:
- worker
ports:
- 5050:5050
- 5678:5678 # debug port
redis:
image: redis:latest
container_name: redis
restart: always
ports:
- 6379:6379
worker:
env_file:
- ./backend/.env
@ -52,8 +55,7 @@ services:
- redis
volumes:
- ./backend/:/code/
flower:
env_file:
- ./backend/.env

View File

@ -15,9 +15,18 @@ title: Testing Strategies
- Chat related functions
How:
- Pytest
# Frontend
### 🐛 Debugging the backend
The backend is running in a docker container. To debug the backend, you can attach a debugger to the container. The debugger server runs on port `5678`. The backend is started in dev mode with `make dev`.
#### Debug with VSCode
The configuration for this is already set up in the `launch.json` file in the `.vscode` folder. After you started the project in dev mode with `make dev` you can run a debugging session using the `Python: Remote attach` configuration.
## Frontend
- Functional tests
- Good rendering of components
@ -26,5 +35,6 @@ How:
- User can interact with the component
How:
- Vitest
- RTL (React Testing Library)