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

Overview

fastapi-gino-arq-uvicorn

High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (powered by Redis & PostgreSQL).

Contents

Get Started

Setup

  1. Clone this Repository. git clone https://github.com/leosussan/fastapi-gino-arq-uvicorn.git
  2. Install Python 3.8 and poetry.
    • Recommended Method: asdf - a universal version manager (think nvm or pyenv)
      • Follow these instructions to install asdf.
      • Run the following commands from the project root:
        • asdf plugin add python
        • asdf plugin add poetry
        • asdf install -- will download & configure this project's Python + poetry setup
    • If you have Python 3.8 and poetry installed already, please feel free to skip.
  3. Install dependencies (poetry install).
  4. Activate pre-commit hooks (in poetry shell, run pre-commit install).
  5. Make a copy of .dist.env, rename to .env. Fill in PostgreSQL, Redis, Sentry (optional) variables.
  6. Generate DB Migrations: in poetry shell, run alembic revision --autogenerate.
    • Apply migrations manually with alembic upgrade head.
    • If using the Dockerfile, migrations are applied at startup.

Run

Run Locally

NOTE: You must have PostgreSQL & Redis running locally.

  1. Make sure PostgreSQL & Redis are running locally.
  2. Run:
    • FastAPI Application:
      • For Active Development (w/ auto-reload): Run locally with poetry run task app
      • For Debugging (compatible w/ debuggers, no auto-reload): Configure debugger to run python app/main.py.
    • Background Task Worker:
      • For Active Development: Run poetry run task worker

Run Locally with Docker-Compose.

  1. Make sure Docker is running locally.
  2. Run poetry run task compose-up*.
    • Run poetry run task compose-down to spin down, clean up.

*app/settings/prestart.sh will run migrations for you before the app starts.

Build Your Application

  • Create routes in /app/routes, import & add them to the ROUTERS constant in /app/main.py
  • Create database models to /app/models/orm, add them to /app/models/orm/migrations/env.py for migrations
  • Create pydantic models in /app/models/pydantic
  • Store complex db queries in /app/models/orm/queries
  • Store complex tasks in app/tasks.
  • Add / edit globals to /.env, expose & import them from /app/settings/globals.py
    • Use any coroutine as a background function: store a reference in the ARQ_BACKGROUND_FUNCTIONS env.
    • Set SENTRY_DSN in your environment to enable Sentry.
  • Define code to run before launch (migrations, setup, etc) in /app/settings/prestart.sh

Features

Core Dependencies

  • FastAPI: touts performance on-par with NodeJS & Go + automatic Swagger + ReDoc generation.
  • GINO: built on SQLAlchemy core. Lightweight, simple, asynchronous ORM for PostgreSQL.
  • Arq: Asyncio + Redis = fast, resource-light job queuing & RPC.
  • Uvicorn: Lightning-fast, asynchronous ASGI server.
  • Optimized Dockerfile: Optimized Dockerfile for ASGI applications, from https://github.com/tiangolo/uvicorn-gunicorn-docker.

Additional Dependencies

  • PostgreSQL: Robust, fully-featured, scalable, open-source.
  • Redis: Fast, simple, broker for the Arq task queue.
  • Pydantic: Core to FastAPI. Define how data should be in pure, canonical python; validate it with pydantic.
  • Alembic: Handles database migrations. Compatible with GINO.
  • SQLAlchemy_Utils: Provides essential handles & datatypes. Compatible with GINO.
  • Sentry: Open-source, cloud-hosted error + event monitoring.
  • Pre-Commit: automatic formatting (black + isort) and linting (flake8).
  • Taskipy: Small, flexible task runner for Poetry.
Comments
  • gino.exceptions.UninitializedError: Gino engine is not initialized.

    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.
    
    opened by arnaudsj 3
  • fix: different paths for env script and migrations

    fix: different paths for env script and migrations

    With both of these on the same path alembic causes a deadlock condition trying to create the alembic_version table for the first time.

    When I inspected the call path (by pdbing _ensure_version_table), I saw the second call to create the table that happened during the same (first) transaction, originated from the get_revisions call path. Not sure how this could ever work for someone else.

    (Pdb) w
      venv/bin/alembic(8)<module>()
    -> sys.exit(main())
      venv/lib/python3.8/site-packages/alembic/config.py(577)main()
    -> CommandLine(prog=prog).main(argv=argv)
      venv/lib/python3.8/site-packages/alembic/config.py(571)main()
    -> self.run_cmd(cfg, options)
      venv/lib/python3.8/site-packages/alembic/config.py(548)run_cmd()
    -> fn(
      venv/lib/python3.8/site-packages/alembic/command.py(214)revision()
    -> script_directory.run_env()
      venv/lib/python3.8/site-packages/alembic/script/base.py(489)run_env()
    -> util.load_python_file(self.dir, "env.py")
      venv/lib/python3.8/site-packages/alembic/util/pyfiles.py(98)load_python_file()
    -> module = load_module_py(module_id, path)
      venv/lib/python3.8/site-packages/alembic/util/compat.py(184)load_module_py()
    -> spec.loader.exec_module(module)
      <frozen importlib._bootstrap_external>(783)exec_module()
      <frozen importlib._bootstrap>(219)_call_with_frames_removed()
      london-looker/app/models/orm/migrations/env.py(78)<module>()
    -> run_migrations_online()
      london-looker/app/models/orm/migrations/env.py(72)run_migrations_online()
    -> context.run_migrations()
      <string>(8)run_migrations()
      venv/lib/python3.8/site-packages/alembic/runtime/environment.py(846)run_migrations()
    -> self.get_context().run_migrations(**kw)
      venv/lib/python3.8/site-packages/alembic/runtime/migration.py(510)run_migrations()
    -> for step in self._migrations_fn(heads, self):
      venv/lib/python3.8/site-packages/alembic/command.py(190)retrieve_migrations()
    -> revision_context.run_autogenerate(rev, context)
      venv/lib/python3.8/site-packages/alembic/autogenerate/api.py(442)run_autogenerate()
    -> self._run_environment(rev, migration_context, True)
      venv/lib/python3.8/site-packages/alembic/autogenerate/api.py(454)_run_environment()
    -> self.script_directory.get_revisions("heads")
      venv/lib/python3.8/site-packages/alembic/script/base.py(227)get_revisions()
    -> return self.revision_map.get_revisions(id_)
      venv/lib/python3.8/site-packages/alembic/script/revision.py(321)get_revisions()
    -> resolved_id, branch_label = self._resolve_revision_number(id_)
      venv/lib/python3.8/site-packages/alembic/script/revision.py(501)_resolve_revision_number()
    -> self._revision_map
      venv/lib/python3.8/site-packages/alembic/util/langhelpers.py(230)__get__()
    -> obj.__dict__[self.__name__] = result = self.fget(obj)
      venv/lib/python3.8/site-packages/alembic/script/revision.py(123)_revision_map()
    -> for revision in self._generator():
      venv/lib/python3.8/site-packages/alembic/script/base.py(112)_load_revisions()
    -> script = Script._from_filename(self, vers, file_)
      venv/lib/python3.8/site-packages/alembic/script/base.py(906)_from_filename()
    -> module = util.load_python_file(dir_, filename)
      venv/lib/python3.8/site-packages/alembic/util/pyfiles.py(98)load_python_file()
    -> module = load_module_py(module_id, path)
      venv/lib/python3.8/site-packages/alembic/util/compat.py(184)load_module_py()
    -> spec.loader.exec_module(module)
      <frozen importlib._bootstrap_external>(783)exec_module()
      <frozen importlib._bootstrap>(219)_call_with_frames_removed()
      london-looker/app/models/orm/migrations/env.py(78)<module>()
    -> run_migrations_online()
      london-looker/app/models/orm/migrations/env.py(72)run_migrations_online()
    -> context.run_migrations()
      <string>(8)run_migrations()
      venv/lib/python3.8/site-packages/alembic/runtime/environment.py(846)run_migrations()
    -> self.get_context().run_migrations(**kw)
      venv/lib/python3.8/site-packages/alembic/runtime/migration.py(502)run_migrations()
    -> self._ensure_version_table()
    > venv/lib/python3.8/site-packages/alembic/runtime/migration.py(443)_ensure_version_table()
    -> self._version.create(self.connection, checkfirst=True)
    
    opened by asfaltboy 2
  • Dockerfile Build Order

    Dockerfile Build Order

    (rationale: apk update / apk add should happen before pipfile, saves build time)

    As referenced in https://github.com/leosussan/fastapi-gino-arq-uvicorn/pull/6#discussion_r340017046

    opened by leosussan 0
  • Arq Task Queue

    Arq Task Queue

    Implements @samuelcolvin's Arq task queue for robust job / RPC handling.

    PR includes:

    • Distinct Dockerfile.worker, docker-compose.worker.yml
    • Updated docker-compose.local.yml spins up Redis and worker
    • ARQ_BACKGROUND_FUNCTIONS global: a string-separated list of function references. All listed functions made available to worker at instantiation
    • New tasks folder for complicated application logic: app/tasks
    • Example background function in app/tasks/messaging/send_message
    • Example use of above background function in app/routes/users/create_user

    Documentation: https://github.com/samuelcolvin/arq

    opened by leosussan 0
  • Updates to Dependencies

    Updates to Dependencies

    updates to Pipfile.lock dept: added black to dev dependencies dept: added bandit to dev dependencies dept: added flake8 to dev dependencies dept: added rope to dev dependencies dept: email-validator to 1.0.5 dept: fastapi to 0.42.0 dept: psycopg2-binary to 2.8.4 dept: sqlalchemy-utils to 0.34.2 dept: uvicorn to 0.9.1

    formatting: docker-compose.local.yml

    opened by leosussan 0
  • 500 at the endpoints

    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'

    opened by Jonatha-Varjao 0
  • chore(deps): bump certifi from 2020.4.5.1 to 2022.12.7

    chore(deps): bump certifi from 2020.4.5.1 to 2022.12.7

    Bumps certifi from 2020.4.5.1 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • chore(deps): bump urllib3 from 1.25.9 to 1.26.5

    chore(deps): bump urllib3 from 1.25.9 to 1.26.5

    Bumps urllib3 from 1.25.9 to 1.26.5.

    Release notes

    Sourced from urllib3's releases.

    1.26.5

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Fixed deprecation warnings emitted in Python 3.10.
    • Updated vendored six library to 1.16.0.
    • Improved performance of URL parser when splitting the authority component.

    If you or your organization rely on urllib3 consider supporting us via GitHub Sponsors

    1.26.4

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Changed behavior of the default SSLContext when connecting to HTTPS proxy during HTTPS requests. The default SSLContext now sets check_hostname=True.

    If you or your organization rely on urllib3 consider supporting us via GitHub Sponsors

    1.26.3

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Fixed bytes and string comparison issue with headers (Pull #2141)

    • Changed ProxySchemeUnknown error message to be more actionable if the user supplies a proxy URL without a scheme (Pull #2107)

    If you or your organization rely on urllib3 consider supporting us via GitHub Sponsors

    1.26.2

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Fixed an issue where wrap_socket and CERT_REQUIRED wouldn't be imported properly on Python 2.7.8 and earlier (Pull #2052)

    1.26.1

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Fixed an issue where two User-Agent headers would be sent if a User-Agent header key is passed as bytes (Pull #2047)

    1.26.0

    :warning: IMPORTANT: urllib3 v2.0 will drop support for Python 2: Read more in the v2.0 Roadmap

    • Added support for HTTPS proxies contacting HTTPS servers (Pull #1923, Pull #1806)

    • Deprecated negotiating TLSv1 and TLSv1.1 by default. Users that still wish to use TLS earlier than 1.2 without a deprecation warning should opt-in explicitly by setting ssl_version=ssl.PROTOCOL_TLSv1_1 (Pull #2002) Starting in urllib3 v2.0: Connections that receive a DeprecationWarning will fail

    • Deprecated Retry options Retry.DEFAULT_METHOD_WHITELIST, Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST and Retry(method_whitelist=...) in favor of Retry.DEFAULT_ALLOWED_METHODS, Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT, and Retry(allowed_methods=...) (Pull #2000) Starting in urllib3 v2.0: Deprecated options will be removed

    ... (truncated)

    Changelog

    Sourced from urllib3's changelog.

    1.26.5 (2021-05-26)

    • Fixed deprecation warnings emitted in Python 3.10.
    • Updated vendored six library to 1.16.0.
    • Improved performance of URL parser when splitting the authority component.

    1.26.4 (2021-03-15)

    • Changed behavior of the default SSLContext when connecting to HTTPS proxy during HTTPS requests. The default SSLContext now sets check_hostname=True.

    1.26.3 (2021-01-26)

    • Fixed bytes and string comparison issue with headers (Pull #2141)

    • Changed ProxySchemeUnknown error message to be more actionable if the user supplies a proxy URL without a scheme. (Pull #2107)

    1.26.2 (2020-11-12)

    • Fixed an issue where wrap_socket and CERT_REQUIRED wouldn't be imported properly on Python 2.7.8 and earlier (Pull #2052)

    1.26.1 (2020-11-11)

    • Fixed an issue where two User-Agent headers would be sent if a User-Agent header key is passed as bytes (Pull #2047)

    1.26.0 (2020-11-10)

    • NOTE: urllib3 v2.0 will drop support for Python 2. Read more in the v2.0 Roadmap <https://urllib3.readthedocs.io/en/latest/v2-roadmap.html>_.

    • Added support for HTTPS proxies contacting HTTPS servers (Pull #1923, Pull #1806)

    • Deprecated negotiating TLSv1 and TLSv1.1 by default. Users that still wish to use TLS earlier than 1.2 without a deprecation warning

    ... (truncated)

    Commits
    • d161647 Release 1.26.5
    • 2d4a3fe Improve performance of sub-authority splitting in URL
    • 2698537 Update vendored six to 1.16.0
    • 07bed79 Fix deprecation warnings for Python 3.10 ssl module
    • d725a9b Add Python 3.10 to GitHub Actions
    • 339ad34 Use pytest==6.2.4 on Python 3.10+
    • f271c9c Apply latest Black formatting
    • 1884878 [1.26] Properly proxy EOF on the SSLTransport test suite
    • a891304 Release 1.26.4
    • 8d65ea1 Merge pull request from GHSA-5phf-pp7p-vc2r
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • chore(deps): bump mako from 1.1.2 to 1.2.2

    chore(deps): bump mako from 1.1.2 to 1.2.2

    Bumps mako from 1.1.2 to 1.2.2.

    Release notes

    Sourced from mako's releases.

    1.2.2

    Released: Mon Aug 29 2022

    bug

    • [bug] [lexer] Fixed issue in lexer where the regexp used to match tags would not correctly interpret quoted sections individually. While this parsing issue still produced the same expected tag structure later on, the mis-handling of quoted sections was also subject to a regexp crash if a tag had a large number of quotes within its quoted sections.

      References: #366

    1.2.1

    Released: Thu Jun 30 2022

    bug

    • [bug] [tests] Various fixes to the test suite in the area of exception message rendering to accommodate for variability in Python versions as well as Pygments.

      References: #360

    misc

    • [performance] Optimized some codepaths within the lexer/Python code generation process, improving performance for generation of templates prior to their being cached. Pull request courtesy Takuto Ikuta.

      References: #361

    1.2.0

    Released: Thu Mar 10 2022

    changed

    • [changed] [py3k] Corrected "universal wheel" directive in setup.cfg so that building a wheel does not target Python 2.

      References: #351

    • [changed] [py3k] The bytestring_passthrough template argument is removed, as this flag only applied to Python 2.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • sqlalchemy_utils generic_repr breaks repr for gino models

    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'>```
    opened by asfaltboy 1
Releases(v0.5.0)
  • v0.5.0(May 13, 2020)

    feature: pre-commit

    rationale: consistent linting (flake8), import & formatting standards (isort, black), enforced on every commit.

    fix: use --no-root option in Dockerfile

    rationale: from-cache building facilitated by adding --no-root to build step.

    update: dependencies

    list of added dependencies

    • isort - import sorting
    • pre-commit - application of commit hooks
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(May 12, 2020)

    feature: poetry

    rationale: fast, dependable dependency management for python

    details: pipenv has a number of quality of life issues that poetry solves outright.

    feature: python 3.8

    rationale: enough useful features (async arepl, walrus operator, typed dictionaries, assignment expressions in f-strings) to justify an upgrade.

    details: both Dockerfiles now install & launch the application on Python 3.8.

    feature: asdf support

    rationale: single package manager for project runtime dependencies

    details: clone this repository to your local, then run asdf install. that's it - no more making sure you have the right version.

    feature: taskipy

    rationale: pipenv run without pipenv's headaches

    details: add aliases for shell commands you depend on

    • poetry run task compose-up, replaces pipenv run docker-compose -f docker-compose.local.yml -f docker-compose.worker.yml -f docker-compose.yml up --build
    • poetry run task app, replaces pipenv run uvicorn app.main:app --reload
    • poetry run task worker, replaces arq app.worker.WorkerSettings --watch ./

    update: dependencies

    list of dependency updates

    • fastapi to 0.54.1
    • gino to 1.0.0
    • arq to 0.19
    • sqlalchemy-utils to `0.36.5
    • alembicto 1.4.2
    • psycopg2-binary to 2.8.5
    • uvicorn to 0.11.5
    • email_validator to 1.0.5
    • sentry-sdk to 0.14.3

    list of added dependencies

    • gino-starlette for starlette support in gino 1.0
    • taskipy for pipenv-style commands in poetry
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Oct 28, 2019)

    feature: arq task queue (via redis)

    rationale: write tasks as coroutines, once, use them in the foreground + background.

    details: arq's architecture is similar to FastAPI & natively distributes, handles, runs coroutines as background functions. Multiple jobs (potentially hundreds) can be run simultaneously using a pool of asyncio Tasks

    • New tasks folder: use app/tasks to store & expose foreground + background tasks
    • New app/workers.py file configures, launches arq worker.
    • New ARQ_BACKGROUND_FUNCTIONS global: set a list of function references (app.tasks.example.function, app.tasks.another.function) in env, app/worker.py will listen for that function in task queue.
    • New Dockerfile, docker-compose.worker.yml, updated docker-compose.local.yml for local & automated testing.
    • Updated Readme w/ new launch strings
    • New dependencies: arq, watchgod (in dev)

    feature: sentry integration

    rationale: sentry is the standard in error logging.

    dept: sentry-sdk w/ asgi, gino integration

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Oct 23, 2019)

    feature: debugger compatibility

    rationale: debuggers don't work with FastAPI unless properly configured.

    details: updated readme.md & app/main.py: you can now choose between running locally w/ auto-reload, or you can use app/main.py with a python debugger.

    update: dependencies

    list of dependency updates:

    dept: email-validator to 1.0.5 dept: fastapi to 0.42.0 dept: psycopg2-binary to 2.8.4 dept: sqlalchemy-utils to 0.34.2 dept: uvicorn to 0.9.1

    update: dev dependencies

    rationale: instill good dev hygiene by standardizing your formatting, linting, security checks

    dept: black to dev dependencies dept: bandit to dev dependencies dept: flake8 to dev dependencies dept: rope to dev dependencies

    fixes: Dockerfile

    rationale: make is needed for newer versions of the library

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jul 3, 2019)

    feature: app builds on python3.7-alpine3.8

    rationale: cuts runtime size by a third, dramatically improves image security. Google's Container Scan now detect 0 exploits, down from 600+ from vanilla python3.7.

    feature: Added 'Prestart.sh', configured to run alembic upgrade head

    rationale: 'Prestart.sh' used to run scripts before app is instantiated. currently configured to run migrations post-build, pre-server init.

    feature: docker-compose.local.yml

    rationale: Runs postgres as a docker service, connects app. for local development purposes.

    planned updates:

    1. gunicorn_conf.py - A deeper gunicorn configuration file, including customizations for serverless runtimes (Cloud Run)
    2. arq - Preferred async task queue
    3. sentry - Preferred stacktrace solution
    Source code(tar.gz)
    Source code(zip)
Owner
Leo Sussan
Leo Sussan
Socket.IO integration for Flask applications.

Flask-SocketIO Socket.IO integration for Flask applications. Installation You can install this package as usual with pip: pip install flask-socketio

Miguel Grinberg 4.9k Jan 03, 2023
REST API with FastAPI and JSON file.

FastAPI RESTAPI with a JSON py 3.10 First, to install all dependencies, in ./src/: python -m pip install -r requirements.txt Second, into the ./src/

Luis Quiñones Requelme 1 Dec 15, 2021
Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI

FastAPI Ariadne Example Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI - GitHub ###Запуск на локальном окру

ZeBrains Team 9 Nov 10, 2022
A RESTful API for creating and monitoring resource components of a hypothetical build system. Built with FastAPI and pydantic. Complete with testing and CI.

diskspace-monitor-CRUD Background The build system is part of a large environment with a multitude of different components. Many of the components hav

Nick Hopewell 67 Dec 14, 2022
Fastapi performans monitoring

Fastapi-performans-monitoring This project is a simple performance monitoring for FastAPI. License This project is licensed under the terms of the MIT

bilal alpaslan 11 Dec 31, 2022
Formatting of dates and times in Flask templates using moment.js.

Flask-Moment This extension enhances Jinja2 templates with formatting of dates and times using moment.js. Quick Start Step 1: Initialize the extension

Miguel Grinberg 358 Nov 28, 2022
Adds GraphQL support to your Flask application.

Flask-GraphQL Adds GraphQL support to your Flask application. Usage Just use the GraphQLView view from flask_graphql from flask import Flask from flas

GraphQL Python 1.3k Dec 31, 2022
✨️🐍 SPARQL endpoint built with RDFLib to serve machine learning models, or any other logic implemented in Python

✨ SPARQL endpoint for RDFLib rdflib-endpoint is a SPARQL endpoint based on a RDFLib Graph to easily serve machine learning models, or any other logic

Vincent Emonet 27 Dec 19, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 562 Jan 01, 2023
Ready-to-use and customizable users management for FastAPI

FastAPI Users Ready-to-use and customizable users management for FastAPI Documentation: https://fastapi-users.github.io/fastapi-users/ Source Code: ht

FastAPI Users 2.3k Dec 30, 2022
Opentracing support for Starlette and FastApi

Starlette-OpenTracing OpenTracing support for Starlette and FastApi. Inspired by: Flask-OpenTracing OpenTracing implementations exist for major distri

Rene Dohmen 63 Dec 30, 2022
Get MODBUS data from Sofar (K-TLX) inverter through LSW-3 or LSE module

SOFAR Inverter + LSW-3/LSE Small utility to read data from SOFAR K-TLX inverters through the Solarman (LSW-3/LSE) datalogger. Two scripts to get inver

58 Dec 29, 2022
Simple web app example serving a PyTorch model using streamlit and FastAPI

streamlit-fastapi-model-serving Simple example of usage of streamlit and FastAPI for ML model serving described on this blogpost and PyConES 2020 vide

Davide Fiocco 291 Jan 06, 2023
Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⭐

FRDP Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⛏ . Getting Started Fe

BnademOverflow 53 Dec 29, 2022
Town / City geolocations with FastAPI & Mongo

geolocations-api United Kingdom Town / City geolocations with FastAPI & Mongo Build container To build a custom image or extend the api run the follow

Joe Gasewicz 3 Jan 26, 2022
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 300 Dec 26, 2022
🐍Pywork is a Yeoman generator to scaffold a Bare-bone Python Application

Pywork python app yeoman generator Yeoman | Npm Pywork | Home PyWork is a Yeoman generator for a basic python-worker project that makes use of Pipenv,

Vu Tran 10 Dec 16, 2022
FastAPI simple cache

FastAPI Cache Implements simple lightweight cache system as dependencies in FastAPI. Installation pip install fastapi-cache Usage example from fastapi

Ivan Sushkov 188 Dec 29, 2022
스타트업 개발자 채용

스타트업 개발자 채용 大 박람회 Seed ~ Series B에 있는 스타트업을 위한 채용정보 페이지입니다. Back-end, Frontend, Mobile 등 개발자를 대상으로 진행하고 있습니다. 해당 스타트업에 종사하시는 분뿐만 아니라 채용 관련 정보를 알고 계시다면

JuHyun Lee 58 Dec 14, 2022
Keepalive - Discord Bot to keep threads from expiring

keepalive Discord Bot to keep threads from expiring Installation Create a new Di

Francesco Pierfederici 5 Mar 14, 2022