full-keyboard-92367
09/21/2021, 5:59 PMuvicorn module:app --reload
and programmatically uvicorn.run(app)
Unfortunately uvicorn discontinued usage of reload while programmatically running the server, so for reload feature to work(crucial in a development environment), the command has to be executed via shell.
I can't for the life of me figure out how to run a shell command or create a shell entrypoint with pants.
Also it would be great if you guys could provide point me to an actual real world project with pants for a reference to make sure I'm doing this correctly.happy-kitchen-89482
09/21/2021, 10:26 PM--loop
work in this case?witty-crayon-22786
09/21/2021, 10:27 PMhappy-kitchen-89482
09/21/2021, 11:50 PMpex_binary
target) it will run from the sandboxed copy of your code, not the original in your source tree. So it won't "see" edits in your source tree.happy-kitchen-89482
09/21/2021, 11:50 PMhappy-kitchen-89482
09/21/2021, 11:51 PM--loop
flag.happy-kitchen-89482
09/21/2021, 11:51 PMhappy-kitchen-89482
09/21/2021, 11:52 PMhappy-kitchen-89482
09/21/2021, 11:53 PM--loop
(as opposed to relying on uvicorn's own file watching) is that it will do the right thing even in complicated situations, such as changes to .proto files.full-keyboard-92367
09/22/2021, 5:29 AMOne solution is to run uvicorn outside of Pants (in a virtualenv that Pants can build for you)Ya I tried that, I followed https://www.pantsbuild.org/docs/python-third-party-dependencies#tip-set-up-a-virtual-environment-optional to create a venv, but I require pant's dependency injection to import a "common" module into my servers.
happy-kitchen-89482
09/22/2021, 5:35 AMfull-keyboard-92367
09/22/2021, 5:36 AMhappy-kitchen-89482
09/22/2021, 5:44 AMproject_1
, project_2
and common
different source roots (https://www.pantsbuild.org/docs/source-roots) ?happy-kitchen-89482
09/22/2021, 5:44 AMfull-keyboard-92367
09/22/2021, 5:48 AMhappy-kitchen-89482
09/22/2021, 3:07 PMhappy-kitchen-89482
09/22/2021, 3:10 PMpython
that contains:
PYTHONPATH=src/python:${PYTHONPATH:-} /path/to/venv/bin/python $@
happy-kitchen-89482
09/22/2021, 3:11 PMhappy-kitchen-89482
09/22/2021, 3:12 PMmodern-wolf-36228
09/22/2021, 5:20 PMwitty-crayon-22786
09/22/2021, 5:35 PM--loop
with package
and relaunch when a new file is produced maybe?witty-crayon-22786
09/22/2021, 5:36 PMmodern-wolf-36228
09/22/2021, 5:38 PMmodern-wolf-36228
09/22/2021, 5:39 PMmodern-wolf-36228
09/22/2021, 5:40 PMwitty-crayon-22786
10/06/2021, 8:18 PM