You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm fairly new to both Python and FastAPI, so I might be missing an obvious solution here. I joined a team that's already working with said stack and they've set up a dev Docker image that runs the app through uvicorn. I see a similar setup in your repo.
Coming from Java, I'd prefer to run and debug the application without the need to run it inside a container (and also setting up remote debugging looks like a pain). Why is there a preference to run it in a container? I tried following FastAPI's suggested setup, but I quickly ran into some module import issues (probably due to my lack of deep Python understanding).
Any guidance on the reason for the design choice and possible bast practices would be welcome :)
The text was updated successfully, but these errors were encountered:
Containers are great because they are easy to set up and run. Also, some networking isolation could be done, which is also nice. But, that is not an obligatory, nor a best practice - just a matter of choice.
If the module imports are not related to circular imports, then it is probably an improper server configuration. The best way that handles all the problems with it is to run the server from the project level, instead of the code level.
Here is the example:
- project/
-- src/
--- main.py
--- utils.py
If you attempt to run your code from the src directory using commands like python -m main, you are likely to encounter import issues with packages.
It's best to run the server from the project root directory, not from the src directory. Use the command python -m src.main from the project/ directory rather than python -m main from the src/ directory. This approach ensures that Python interprets your project structure correctly, resolving any import issues.
I'm fairly new to both Python and FastAPI, so I might be missing an obvious solution here. I joined a team that's already working with said stack and they've set up a dev Docker image that runs the app through uvicorn. I see a similar setup in your repo.
Coming from Java, I'd prefer to run and debug the application without the need to run it inside a container (and also setting up remote debugging looks like a pain). Why is there a preference to run it in a container? I tried following FastAPI's suggested setup, but I quickly ran into some module import issues (probably due to my lack of deep Python understanding).
Any guidance on the reason for the design choice and possible bast practices would be welcome :)
The text was updated successfully, but these errors were encountered: