propan run command dont see root packege #130
-
I have a problem when I place code in packege named "root", separated by modules "main" and "handlers" like this handlers.py from propan import RabbitRouter
router = RabbitRouter(prefix="user/")
@router.handle("created")
async def handle_user_created_event(user_id: str):
... main.py from propan import PropanApp, RabbitBroker
from root.handlers import router
broker = RabbitBroker()
broker.include_router(router)
app = PropanApp(broker) Сommand
How to split propan code by modules in packege? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Propan places your interpreter to the running script root |
Beta Was this translation helpful? Give feedback.
-
As an example: having the following project structure
You should use improts from the |
Beta Was this translation helpful? Give feedback.
Anyway, you can't import from 'root' if your entry script is inside the 'root'
You need to create subdirectory at the same level with 'main.py' and import all modules from it
Also, you can generate any of Propan project templates to take a look at the project structure