-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor app into eligibility_server/app #19
Conversation
Tried: docker-compose run --rm -e DEBUGGER=True -e FLASK_APP=eligibility_server/app.py -e FLASK_ENV=development --service-ports dev python -m debugpy --wait-for-client --listen 0.0.0.0:5678 eligibility_server/app.py and added a breakpoint in if __name__ == "__main__":
print(app)
print("STUFF")
breakpoint()
app.run(host="0.0.0.0", debug=True) # nosec I was able to get the VS Code debugger working and look into the ➜ eligibility-server git:(chore/move-into-folder) ✗ docker-compose run --rm -e DEBUGGER=True -e FLASK_APP=eligibility_server/app.py -e FLASK_ENV=development --service-ports dev python -m debugpy --wait-for-client --listen 0.0.0.0:5678 eligibility_server/app.py
Creating eligibility-server_dev_run ... done
<Flask 'app'>
STUFF
* Serving Flask app "app" (lazy loading)
* Environment: development
* Debug mode: on
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://192.168.0.2:5000/ (Press CTRL+C to quit)
* Restarting with stat
No module named app |
So I just came across this: https://code.visualstudio.com/docs/python/tutorial-flask#_run-the-app-in-the-debugger Which makes this whole thing much easier! I feel like this is new, So two tricks that got this working for me:
{
"name": "Flask: Eligibility Verification Server",
"type": "python",
"request": "launch",
"module": "flask",
"args": [
"run",
"--host",
"0.0.0.0"
],
"env": {
"FLASK_DEBUG": "1",
"FLASK_ENV": "development"
}
} This now starts the server on-demand with
dev:
build:
context: .
dockerfile: Dockerfile.dev
entrypoint: []
command: sleep infinity
image: eligibility_server:dev
ports:
- 5000
volumes:
- ./:/home/calitp/app/
|
There's a similar write-up for Django, which I tried with https://code.visualstudio.com/docs/python/tutorial-django#_create-a-debugger-launch-profile |
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.
Great job! Few small changes, added some links to more info about Docker entrypoint/command.
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.
Forgot to add:
You can remove debugpy
from the requirements.txt
file too!
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.
🚀 🎸
What this PR does
close #12
app.py
intoeligibility_server/app.py
app
import toeligibility_server.app
debugpy
dependencyTesting
Make sure you can:
docker compose build server
docker compose up server
- open http://localhost:XXXX/healthcheckflask run -h 0.0.0.0
then open http://localhost:XXXX/healthcheckF5
F5
, change some server-side code, and the debugger should automatically restartpytest
Docs
The new port can be found from the VS Code port panel, or with the docker command:
docker ps