leosussan / fastapi-gino-arq-uvicorn Goto Github PK
View Code? Open in Web Editor NEWHigh-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
License: MIT License
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
License: MIT License
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'>```
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'
What about tests?
Do you have a plans to add any test examples?
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?
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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.