vjousse / fastapi-beginners-guide

A complete beginner's guide to FastAPI - Code Samples
3 stars 1 forks source link

Part3 docker #15

Open vincentporte opened 3 years ago

vincentporte commented 3 years ago

error at start with docker

Creating fastapi-beginners-guide_web_1 ... done Creating fastapi-beginners-guide_nginx_1 ... done Attaching to fastapi-beginners-guide_web_1, fastapi-beginners-guide_nginx_1 web_1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) web_1 | INFO: Started reloader process [1] using watchgod web_1 | ERROR: Error loading ASGI app. Could not import module "app.main".

vincentporte commented 3 years ago

tuto part 3 paused before 'configuration' part

vjousse commented 3 years ago

tuto part 3 paused before 'configuration' part

This is due to the problem you've pointed out in the tutorial here: https://github.com/pereprogramming/blog/commit/598ab7425a97bcd5cef796e76f65f65094b3cce6#diff-5af152a502200b6cb25096d2c2aaa646f6171ae36b378866f62134a90c8fe565L83

Remove the 2 lines and you should be fine :+1:

vincentporte commented 3 years ago

I add from app.models.article import Article in app/main.py to prevent warning message RuntimeWarning: Module "app.main" has no models when starting app

web_1    | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
web_1    | INFO:     Started reloader process [1] using watchgod
web_1    | INFO:     Started server process [8]
web_1    | INFO:     Waiting for application startup.
web_1    | /usr/local/lib/python3.8/site-packages/tortoise/__init__.py:601: RuntimeWarning: Module "app.main" has no models
web_1    |   cls._init_apps(apps_config)
web_1    | INFO:     Tortoise-ORM started, {'default': <tortoise.backends.sqlite.client.SqliteClient object at 0x7f6dab11ee50>}, {'models': {}}
web_1    | INFO:     Tortoise-ORM generating schema
web_1    | INFO:     Application startup complete.

It seems to be a duplicate with

vjousse commented 3 years ago

I add from app.models.article import Article in app/main.py to prevent warning message RuntimeWarning: Module "app.main" has no models when starting app

web_1    | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
web_1    | INFO:     Started reloader process [1] using watchgod
web_1    | INFO:     Started server process [8]
web_1    | INFO:     Waiting for application startup.
web_1    | /usr/local/lib/python3.8/site-packages/tortoise/__init__.py:601: RuntimeWarning: Module "app.main" has no models
web_1    |   cls._init_apps(apps_config)
web_1    | INFO:     Tortoise-ORM started, {'default': <tortoise.backends.sqlite.client.SqliteClient object at 0x7f6dab11ee50>}, {'models': {}}
web_1    | INFO:     Tortoise-ORM generating schema
web_1    | INFO:     Application startup complete.

It seems to be a duplicate with

  • the same line in app/views/article.py
  • the model declaration in register_tortoise

Not sure what to do with your comment? Is it still a problem for you? I can't reproduce it with the current code on your branch.

If it's and error in the tutorial that you've fixed, could you tell me what was wrong or directly propose some changes here: https://github.com/pereprogramming/blog/blob/main/content/articles/le-guide-complet-du-debutant-avec-fastapi-partie-3/index.md Thanks!