canonical / paas-app-charmer

2 stars 2 forks source link

Add FastAPI support to paas-app-charmer #35

Closed javierdelapuente closed 2 months ago

javierdelapuente commented 2 months ago

Applicable spec: ISD160 - 12-Factor FastAPI Support

Overview

This PR add support for FastAPI for paas-app-charmer.

Its workings are more similar to Go than to Django/Flask, as it does not use Gunicorn. FastAPI is run with the ASGI web server Uvicorn, but without a configuration file.

The main changes of this PR are:

Logs will be implemented with Log forwarding in pebble and is not handled in this PR.

Documentation will be done outside of this PR.

Rationale

FastAPI is widely used framework for web development in Python. As so, FastAPI support is desired in the 12 factor framework.

Juju Events Changes

Module Changes

Library Changes

Checklist

github-actions[bot] commented 2 months ago

Test coverage for afc5e147d163acefbc8df733dddadf6a2794c3da

Name                                            Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------------------------------
paas_app_charmer/__init__.py                       29     14      0      0    52%   13-14, 19-20, 26-27, 33-34, 40-41, 47-48, 54-55
paas_app_charmer/_gunicorn/__init__.py              0      0      0      0   100%
paas_app_charmer/_gunicorn/charm.py                15      0      0      0   100%
paas_app_charmer/_gunicorn/webserver.py            76      4     14      1    94%   162, 174-180
paas_app_charmer/_gunicorn/workload_config.py       8      0      0      0   100%
paas_app_charmer/_gunicorn/wsgi_app.py             16      0      0      0   100%
paas_app_charmer/app.py                           123      0     50      2    99%   95->exit, 145->151
paas_app_charmer/charm.py                         212     25     46      4    88%   32-33, 40-41, 190-191, 193-194, 215->exit, 227-231, 284-286, 339-340, 345, 350, 355, 365, 370, 375, 380, 385, 410
paas_app_charmer/charm_state.py                   107      2     20      2    97%   184, 268
paas_app_charmer/charm_utils.py                    23      0      0      0   100%
paas_app_charmer/database_migration.py             35      0      2      0   100%
paas_app_charmer/databases.py                      25      2     11      1    92%   89-90
paas_app_charmer/django/__init__.py                 2      0      0      0   100%
paas_app_charmer/django/charm.py                   34      4      6      2    85%   44, 81, 96-97
paas_app_charmer/exceptions.py                      5      0      0      0   100%
paas_app_charmer/fastapi/__init__.py                2      0      0      0   100%
paas_app_charmer/fastapi/charm.py                  29      0      0      0   100%
paas_app_charmer/flask/__init__.py                  2      0      0      0   100%
paas_app_charmer/flask/charm.py                    24      0      0      0   100%
paas_app_charmer/go/__init__.py                     2      0      0      0   100%
paas_app_charmer/go/charm.py                       26      0      0      0   100%
paas_app_charmer/observability.py                  16      0      4      1    95%   40->44
paas_app_charmer/secret_storage.py                 50      3     16      5    88%   51, 55->54, 56->58, 86, 105
paas_app_charmer/utils.py                          11      2     12      2    65%   29, 31
-------------------------------------------------------------------------------------------
TOTAL                                             872     56    181     20    92%

Static code analysis report

Run started:2024-08-22 10:21:29.346808

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 1922
    Total lines skipped (#nosec): 1
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
Files skipped (0):