PythonNest / PyNest

PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS
https://pythonnest.github.io/PyNest
MIT License
643 stars 45 forks source link

Create settings.yaml if not found in Module Creation #41

Open geanderson-ai opened 5 months ago

geanderson-ai commented 5 months ago

in get_metadata assert setting_path.exists(), "settings.yaml file not found" AssertionError: settings.yaml file not found

ItayTheDar commented 5 months ago

Hi @geanderson-ai! thanks for raising this issue. Normally, setting.yaml file is created as part of the create-nest-app command. The data stored in this file is critical for the generation of a new module. if we create the file on runtime as part of the generating module command, there will be a missing configuration that should let pynest know how to create the new module. I do agree that there is room to change the assertion message to be much more informative and let the user know what he should do

JEub commented 2 months ago

Can confirm, the settings file is getting created in the environment where the project is initialized. However, it does not port to other developers in their own local environments.

To locally resolve this (for others who may be facing this issue) add a settings.yaml file to the <your python environment path>/lib/site-packages/nest directory with the following contents:

config:
  db_type: <your database type>
  is_async: <true | false>
JEub commented 2 months ago

@ItayTheDar would it make more sense to ship this settings file as part of the application project directory instead of pointing the template to the library path at Path(__file__).parent.parent / "settings.yaml"?

I suspect it would make joint development significantly easier.

ItayTheDar commented 1 month ago

@JEub I think that this is a bad practice and my bad from the beginning. This was for me a way to maintain context for the cli commands generations but it is too fragile. I need some configuration files that is generated with the application and follows the best practices