-
Notifications
You must be signed in to change notification settings - Fork 11
Update debugging support for Django and Celery #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use docker-compose override file pattern for enabling remote debugging with debugpy in VS Code. Supports debugging the main Django app and Celery workers independently or simultaneously. Changes: - Update docker-compose.yml to use /start-celeryworker script - Add docker-compose.override.yml.example to enable debuggers - Update start scripts to look for DEBUGGER environment variable - Add debugger config for main Django app in addition to Celery workers
✅ Deploy Preview for antenna-preview canceled.
|
|
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds local VS Code remote-debugging for Django and Celery using debugpy: documentation and README updates, new VS Code launch configurations, an example docker-compose.override enabling DEBUGGER=1 with port mappings and mounted start scripts, and debug-aware conditional start scripts. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Docker as Docker Compose
participant Django as Django Container
participant Celery as Celery Container
participant VSCode as VS Code (debugger)
Dev->>Docker: docker compose up (with override)
Docker->>Docker: set DEBUGGER=1 (from override)
alt DEBUGGER=1
Docker->>Django: run /start -> debugpy listen 5678
Docker->>Celery: run /start-celeryworker -> debugpy listen 5679
else DEBUGGER!=1
Docker->>Django: run normal uvicorn (reload)
Docker->>Celery: run normal Celery worker
end
Dev->>VSCode: Launch "Attach: Django + Celery" (or individual attaches)
VSCode->>Django: attach to localhost:5678
VSCode->>Celery: attach to localhost:5679
note right of VSCode: breakpoints and inspection via debugpy
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the debugging experience for local development by introducing a clean docker-compose override pattern to enable debugpy for Django and Celery services. The change removes hardcoded debugging configuration from docker-compose.yml and makes it opt-in through a git-ignored override file.
Key changes:
- Introduced docker-compose.override.yml.example with debugger configuration
- Updated start scripts to conditionally enable debugpy based on DEBUGGER environment variable
- Added comprehensive VS Code launch configurations for debugging Django and Celery independently or together
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docker-compose.yml | Removed hardcoded debugpy configuration from celeryworker service, replaced with standard /start-celeryworker script |
| docker-compose.override.yml.example | New file providing opt-in debugger configuration with DEBUGGER=1 environment variable and port mappings |
| compose/local/django/start | Added conditional debugpy support based on DEBUGGER environment variable |
| compose/local/django/celery/worker/start | Added conditional debugpy support based on DEBUGGER environment variable |
| .vscode/launch.json | Added individual and compound debug configurations for Django and Celery |
| README.md | Added comprehensive debugging setup, usage, and troubleshooting documentation |
| .agents/AGENTS.md | Added debugging section for Claude Agent with implementation details |
| .gitignore | Added docker-compose.override.yml to git-ignore list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (2)
compose/local/django/celery/worker/start (2)
3-5: Past review feedback addressed.The
set -o pipefailhas been added as suggested in the previous review, improving error handling for piped commands.
8-8: Past review feedback addressed.The comment about auto-reload being disabled during debugging addresses the concern raised in the previous review about documenting this behavioral difference.
🧹 Nitpick comments (4)
compose/local/django/start (1)
12-12: Consider making uvicorn port explicit in debug mode.The debug command doesn't specify an explicit port for uvicorn (will default to 8000). While this matches the default behavior, making it explicit would improve clarity and consistency with the non-debug path.
Apply this diff to make the port explicit:
- exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0 + exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0 --port 8000README.md (1)
270-273: Note: Symlink approach has trade-offs.The documentation offers
ln -sas an alternative tocp. While valid, a symlink means local changes todocker-compose.override.ymlwould affect the tracked example file if the link is reversed, and updates to the example file automatically apply to the override. Thecpapproach is safer for most users as it creates an independent file.Consider adding a note about the difference:
1. Copy or link the override example file: ```bash cp docker-compose.override-example.yml docker-compose.override.yml - # OR + # OR use symlink (changes to example file will auto-apply) ln -s docker-compose.override-example.yml docker-compose.override.yml ```compose/local/django/celery/worker/start (1)
9-10: Consider adding-Xfrozen_modules=offflag for consistency.The Django start script uses
-Xfrozen_modules=offwhen launching with debugpy (Line 12 incompose/local/django/start), but the Celery worker script doesn't include this flag. For consistency and to ensure the same debugging experience, consider adding it here as well.Apply this diff:
- exec watchfiles --filter python 'python -m debugpy --listen 0.0.0.0:5679 -m celery -A config.celery_app worker -l INFO' + exec watchfiles --filter python 'python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5679 -m celery -A config.celery_app worker -l INFO'.vscode/launch.json (1)
43-57: Consider removing redundant debug configuration.The existing "Python Debugger: Remote Attach" configuration (Lines 43-57) appears redundant with the new "Attach: Django" configuration (Lines 11-26), as both attach to port 5678. The key difference is the remoteRoot path (
"."vs"/app"). If the new configuration with"/app"is correct, consider removing the old one to avoid confusion.If the remoteRoot verification confirms
/appis correct, remove the redundant configuration:}, - { - "name": "Python Debugger: Remote Attach", - "type": "debugpy", - "request": "attach", - "connect": { - "host": "localhost", - "port": 5678 - }, - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } - ] - } ] }Alternatively, if both path mappings are needed for different scenarios, consider renaming the old configuration to clarify when each should be used.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.agents/AGENTS.md(1 hunks).vscode/launch.json(1 hunks)README.md(1 hunks)compose/local/django/celery/worker/start(1 hunks)compose/local/django/start(1 hunks)docker-compose.override-example.yml(1 hunks)docker-compose.yml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docker-compose.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (7)
compose/local/django/start (2)
7-8: Inconsistent summary - but code is correct.The AI summary states that the migrate step was removed, but Line 7 shows
python manage.py migrateis still present. Keeping the migration step is the correct approach, as it ensures the database schema is up-to-date before starting the server.
11-12: ****The raised concerns are not valid. Verification confirms:
debugpyis already listed inrequirements/local.txtwith an explicit comment for remote debugging- Python 3.11.11 is configured in the Dockerfile, which supports the
-Xfrozen_modules=offflagThe implementation is correct and requires no changes.
Likely an incorrect or invalid review comment.
README.md (1)
262-307: Comprehensive debugging documentation.The debugging section is well-structured with clear setup instructions, usage guidance, troubleshooting tips, and disable procedures. Port numbers, commands, and configuration names are all consistent with the implementation.
docker-compose.override-example.yml (1)
1-30: Well-structured override example.The override file is clean and well-documented, with clear setup instructions and consistent port mappings (5678 for Django, 5679 for Celery) that align with the start scripts and VS Code configuration.
.agents/AGENTS.md (1)
69-96: Consistent debugging documentation for agents.The debugging section provides clear guidance for Claude agents working with the codebase. The content is consistent with README.md, port numbers align with the implementation, and the technical explanation is accurate.
.vscode/launch.json (1)
3-9: Well-structured compound configuration.The compound configuration correctly references both debug configurations by name and uses
stopAll: trueto ensure all debuggers stop together, which provides a better debugging experience.compose/local/django/celery/worker/start (1)
9-10: No action required—debugpy is already available in the Celery worker image.The Dockerfile installs dependencies from
requirements/local.txt, which already includesdebugpyas an explicit dependency. Since both the django and celeryworker services inherit from the same docker anchor and use the same Dockerfile, debugpy is installed in both images during the build process. The code at lines 9-10 will not fail due to missing debugpy.
Summary
Clean up the docker-compose start command & how we enable the VS Code debugger for both Celery workers & the main Django app.
List of Changes
Related Issues
The debugger has been partially added in multiple PRs. This one full replaces #953 and will replace part of what's in #1034 & #1041
Detailed Description
Use docker-compose override file pattern for enabling remote debugging with debugpy in VS Code. Supports debugging the main Django app and Celery workers independently or simultaneously.
How to Test the Changes
Open on the debugger panel in VS Code
Choose the "Attach: Django + Celery" launch config & press Play
Set a breakpoint in a celery task or django function
Screenshots
Deployment Notes
Relevant to local dev only
Checklist
Summary by CodeRabbit
New Features
Documentation
Chores