GithubHelp home page GithubHelp logo

leosussan / fastapi-gino-arq-uvicorn Goto Github PK

View Code? Open in Web Editor NEW
403.0 403.0 43.0 180 KB

High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).

License: MIT License

Dockerfile 4.61% Python 83.65% Mako 4.35% Shell 7.39%
api arq async asyncio fastapi gino openapi3 postgresql pydantic python python3 rest swagger uvicorn uvloop

fastapi-gino-arq-uvicorn's People

Contributors

atolia avatar kleschenko avatar leosussan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastapi-gino-arq-uvicorn's Issues

sqlalchemy_utils generic_repr breaks repr for gino models

While playing around with the gino ORM on the shell, I kept encountering the NoInspectionAvailable error.
Eventually, I traced this back to @generic_repr decorator and removing it fixed the problem.
Here is the full stack trace:

In [1]: from app.settings.globals import ARQ_BACKGROUND_FUNCTIONS, DATABASE_CONFIG
   ...: from app.models.orm.user import User
   ...: from app.application import app, db
   ...: await db.set_bind(DATABASE_CONFIG.url)
   ...: await User.get(1)
Out[1]: -------------------------------------------------
NoInspectionAvailable                     Traceback (most recent call last)
  /my_env/lib/python3.8/site-packages/IPython/core/formatters.py(702)__call__()
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

  /my_env/lib/python3.8/site-packages/IPython/lib/pretty.py(394)pretty()
    392                         if cls is not object \
    393                                 and callable(cls.__dict__.get('__repr__')):
--> 394                             return _repr_pprint(obj, self, cycle)
    395
    396             return _default_pprint(obj, self, cycle)

  /my_env/lib/python3.8/site-packages/IPython/lib/pretty.py(700)_repr_pprint()
    698     """A pprint that just redirects to the normal repr function."""
    699     # Find newlines and replace them with p.break_()
--> 700     output = repr(obj)
    701     lines = output.splitlines()
    702     with p.group():

  /my_env/lib/python3.8/site-packages/sqlalchemy_utils/models.py(89)<lambda>()
     87     if len(fields) == 1 and callable(fields[0]):
     88         target = fields[0]
---> 89         target.__repr__ = lambda self: _generic_repr_method(self, fields=None)
     90         return target
     91     else:

  /my_env/lib/python3.8/site-packages/sqlalchemy_utils/models.py(42)_generic_repr_method()
     40
     41 def _generic_repr_method(self, fields):
---> 42     state = sa.inspect(self)
     43     field_reprs = []
     44     if not fields:

> /my_env/lib/python3.8/site-packages/sqlalchemy/inspection.py(71)inspect()
     69
     70     if raiseerr and (reg is None or ret is None):
---> 71         raise exc.NoInspectionAvailable(
     72             "No inspection system is "
     73             "available for object of type %s" % type_

NoInspectionAvailable: No inspection system is available for object of type <class 'app.models.orm.user.User'>```

500 at the endpoints

I already migrate the models, but when try to manage te basic user CRUD using the endpoints, returns a 500
the create_user returns
AttributeError: 'UserCreateIn' object has no attribute 'first'

Tests is missing

What about tests?
Do you have a plans to add any test examples?

Please defince LICENSE

I am wondering what the license is for this project. Could you please confirm as this project is not licensed, that it is public domain?

Call to DB from ARQ

Thanks for this boilerplate!
I am trying to make some DB calls from within the ARQ worker but can't make it work. Any idea how to do it?

gino.exceptions.UninitializedError: Gino engine is not initialized.

Hi,

I am interested in getting this exact same stack up and running, but after I clone, install all the dependencies and setup the DATABASE in the .env file and run python app/main.py and I get the following error:

$ python app/main.py 
INFO: Uvicorn running on http://localhost:8888 (Press CTRL+C to quit)
INFO: Started reloader process [49720]
INFO: Started server process [49722]
INFO: Waiting for application startup.
INFO: ASGI 'lifespan' protocol appears unsupported.
INFO: ('127.0.0.1', 59591) - "GET / HTTP/1.1" 500
ERROR: Exception in ASGI application
Traceback (most recent call last):
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 370, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/uvicorn/middleware/debug.py", line 81, in __call__
    raise exc from None
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/uvicorn/middleware/debug.py", line 78, in __call__
    await self.app(scope, receive, inner_send)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/starlette/applications.py", line 133, in __call__
    await self.error_middleware(scope, receive, send)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/starlette/middleware/errors.py", line 122, in __call__
    raise exc from None
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/starlette/middleware/errors.py", line 100, in __call__
    await self.app(scope, receive, _send)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/gino/ext/starlette.py", line 73, in __call__
    scope['connection'] = await self.db.acquire(lazy=True)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/gino/api.py", line 481, in acquire
    return self.bind.acquire(*args, **kwargs)
  File "/Users/arnaudsj/.local/share/virtualenvs/h7IURhCI/lib/python3.7/site-packages/gino/api.py", line 501, in __getattribute__
    raise self._exception
gino.exceptions.UninitializedError: Gino engine is not initialized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.