Giter Site home page Giter Site logo

fastapi-mvc / fastapi-mvc Goto Github PK

View Code? Open in Web Editor NEW
580.0 7.0 52.0 7.73 MB

Developer productivity tool for making high-quality FastAPI production-ready APIs.

Home Page: https://fastapi-mvc.netlify.app/

License: MIT License

Dockerfile 1.96% Makefile 2.09% Shell 2.77% Python 83.93% Nix 9.17% Jinja 0.08%
python fastapi fastapi-template fastapi-boilerplate mvc kubernetes redis-cluster redis-operator redis helm project-generator nix

fastapi-mvc's Introduction

fastapi-mvc

fastapi-mvc CI ❄️ Nix CI ❄️ codecov K8s integration Code style: black PyPI PyPI - Downloads PyPI - Python Version GitHub


Documentation: https://fastapi-mvc.netlify.app

Source Code: https://github.com/fastapi-mvc/fastapi-mvc

Project scaffold: https://github.com/fastapi-mvc/copier-project

Example generated project: https://github.com/fastapi-mvc/example


Fastapi-mvc is a developer productivity tool for FastAPI web framework. It is designed to make programming FastAPI applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more. Core features:

  • Generated project based on MVC architectural pattern
  • WSGI + ASGI production server
  • Generated project comes with Sphinx documentation and 100% tests coverage
  • Kubernetes deployment with Redis HA cluster
  • Makefile, GitHub actions and utilities
  • Helm chart for Kubernetes deployment
  • Dockerfile with K8s and cloud in mind
  • Generate pieces of code or even your own generators
  • Uses Poetry dependency management
  • Includes set of Nix expressions
  • Update already generated project with changes from the new template version
  • Virtualized reproducible development environment using Vagrant

Fastapi-mvc comes with a number of scripts called generators that are designed to make your development life easier by creating everything that’s necessary to start working on a particular task. One of these is the new application generator, which will provide you with the foundation of a fresh FastAPI application so that you don’t have to write it yourself.

Creating a new project is as easy as:

$ fastapi-mvc new /tmp/galactic-empire

This will create a fastapi-mvc project called galactic-empire in a /tmp/galactic-empire directory and install its dependencies using make install.

Once project is generated and installed lets run development uvicorn server (ASGI):

$ cd /tmp/galactic-empire
$ fastapi-mvc run

To confirm it’s actually working:

$ curl 127.0.0.1:8000/api/ready
{"status":"ok"}

Now let's add new API endpoints. For that we need to generate new controller:

$ fastapi-mvc generate controller death_star status load:post fire:delete

And then test generated controller endpoints:

$ curl 127.0.0.1:8000/api/death_star/status
{"hello":"world"}
$ curl -X POST 127.0.0.1:8000/api/death_star/load
{"hello":"world"}
$ curl -X DELETE 127.0.0.1:8000/api/death_star/fire
{"hello":"world"}

You will see it working in server logs as well:

INFO:     127.0.0.1:47284 - "GET /api/ready HTTP/1.1" 200 OK
INFO:     127.0.0.1:55648 - "GET /api/death_star/status HTTP/1.1" 200 OK
INFO:     127.0.0.1:55650 - "POST /api/death_star/load HTTP/1.1" 200 OK
INFO:     127.0.0.1:55652 - "DELETE /api/death_star/fire HTTP/1.1" 200 OK

You can get the project directly from PyPI:

pip install fastapi-mvc

Or build with Nix from flake:

# Optionally setup fastapi-mvc Nix binary cache to speed up the build process
# https://app.cachix.org/cache/fastapi-mvc#pull
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use fastapi-mvc
# Install with Nix from flake:
nix build github:fastapi-mvc/fastapi-mvc#default --profile $HOME/.nix-profile

Projects created with fastapi-mvc

If you have created a project with fastapi-mvc, feel free to open PR and add yourself to the list. Share your story and project. Your success is my success :)

Projects:

Community generators

List of community generators that can be used with fastapi-mvc:

Contributing

CONTRIBUTING

License

MIT

fastapi-mvc's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar jkearnsl avatar merinorus avatar paolodina avatar r2r-dev avatar rszamszur 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

fastapi-mvc's Issues

Implement all `fastapi-mvc.ini` parser properties

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Currently, only package_name property is implemented.

To add:

  • folder_name
  • script_name
  • redis
  • github_actions
  • aiohttp
  • vagrantfile
  • helm
  • version

Improve documentation

Hello there! 👋

The project is in the early stages of development, hence the documentation can be chaotic, incomplete, or hard to follow. Also if I'm being honest I'm not very good at explaining stuff 😅. Feel free to raise an issue or PR if something is missing, unclear, or wrong.

Current issues:

[Databases support] Implement model generator

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Add base implementation for model generator (similar to Rails):
fastapi-mvc generate model Article title:str body:str

This would create:

  • a file article.py under package_name.app.models submodule
  • a unit test file
  • probably a DB migration?

Generated model should inherit from application model base class (also needs to be implemented), which for now won't do much, but in future can have methods for database CRUD, like in Rails you would have:

  • Article.new(...)
  • Article.update(..)
  • and so on

Or any other abstract logic implementations.

This will probably be based on tiangolo/sqlmodel

At least that's the idea. This issue would still require some further research and clarification.

Restart workers when code changes in development mode

It would be useful to have reloading changes in development mode. Either as a new option --reload to template CLI serve command, or automatically based on env variable, ex: FASTAPI_ENV=development FASTAPI_ENV=production, similar to Ruby on Rails. Not yet sure which approach would be better. Moreover, just adding --reload flag to WSGI + ASGI combo doesn't work properly, at least from initial tests. It's possible that for development in order to have reloading changes app would need to run on pure uvicorn (ASGI).

TODO:

  • Research if it's possible to have working reloading changes running gunicorn with uvicorn workers
  • Decide on the way in which this feature should be implemented.
  • Implement feature + tests
  • Update template README

Allow overriding poetry version for make install target via env variable

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Currently, there is no option for overriding Poetry version to install for make install target.
NOTE! Only applicable if Poetry is not installed.

Poetry docs:

if you want to install a specific version, you can use --version or the POETRY_VERSION environment variable:

python get-poetry.py --version 0.12.0
POETRY_VERSION=0.12.0 python get-poetry.py

Debian snapshot repository is expired causing image build failure

Output:

$ make image
[image] Found podman container engine, begin building image.
[1/2] STEP 1/10: FROM python@sha256:a9cf2d58b33ba6f273e80d1f6272186d8930c062fa2a2abc65f35bdf4609a032 AS builder
[1/2] STEP 2/10: LABEL maintainer="Radosław Szamszur, [email protected]"
--> 88f662004ca
[1/2] STEP 3/10: ENV PYTHONUNBUFFERED=1     PYTHONHASHSEED=0     SOURCE_DATE_EPOCH=315532800     CFLAGS=-g0     PYTHONDONTWRITEBYTECODE=1     PIP_NO_CACHE_DIR=off     PIP_DISABLE_PIP_VERSION_CHECK=on     PIP_DEFAULT_TIMEOUT=100     POETRY_HOME="/opt/poetry"     POETRY_VIRTUALENVS_IN_PROJECT=true     POETRY_NO_INTERACTION=1     POETRY_VERSION=1.1.12     POETRY_INSTALL_OPTS="--no-interaction --no-dev --no-root"     PYSETUP_PATH="/pysetup"     VENV_PATH="/pysetup/.venv"
--> 50cb9087152
[1/2] STEP 4/10: ENV PATH="${POETRY_HOME}/bin:${VENV_PATH}/bin:${PATH}"
--> 565d7c1b886
[1/2] STEP 5/10: RUN echo "deb http://snapshot.debian.org/archive/debian/20220124 bullseye main" > /etc/apt/sources.list &&     echo "deb http://snapshot.debian.org/archive/debian-security/20220124 bullseye-security main" >> /etc/apt/sources.list &&     echo "deb http://snapshot.debian.org/archive/debian/20220124 bullseye-updates main" >> /etc/apt/sources.list
--> 6a4d07274ac
[1/2] STEP 6/10: RUN apt-get update &&     apt-get install --no-install-recommends -y curl build-essential
Get:1 http://snapshot.debian.org/archive/debian/20220124 bullseye InRelease [116 kB]
Get:2 http://snapshot.debian.org/archive/debian-security/20220124 bullseye-security InRelease [44.1 kB]
Get:3 http://snapshot.debian.org/archive/debian/20220124 bullseye-updates InRelease [39.4 kB]
Get:4 http://snapshot.debian.org/archive/debian/20220124 bullseye/main amd64 Packages [8183 kB]
Reading package lists...
E: Release file for http://snapshot.debian.org/archive/debian-security/20220124/dists/bullseye-security/InRelease is expired (invalid since 21h 26min 7s). Updates for this repository will not be applied.
E: Release file for http://snapshot.debian.org/archive/debian/20220124/dists/bullseye-updates/InRelease is expired (invalid since 22h 2min 39s). Updates for this repository will not be applied.
[2/2] STEP 1/9: FROM gcr.io/distroless/python3@sha256:a66e582f67df92987039ad8827f0773f96020661c7ae6272e5ab80e2d3abc897
Error: error building at STEP "RUN apt-get update &&     apt-get install --no-install-recommends -y curl build-essential": error while running runtime: exit status 100
make: *** [Makefile:19: image] Error 125

Implement controller generator

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Add base implementation for controller generator (similar to Rails):
fastapi-mvc generate controller Comments

This would create:

  • a file comments.py under package_name.app.models.controllers.v1 submodule
  • a unit test file
  • maybe a view file for custom JSON responses?

Similar to #45

Refactor `Invoker` class with using queue

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

There is no need for a fixed amount of Invoker commands to execute (on_start, on_finish). A better solution would be a queue which would store and execute commands.

Implementation wise use collections.deque because of the constant time O(1) for poping and appending elements at both ends of the list (https://wiki.python.org/moin/TimeComplexity).

Related to: #51

Add nix config for container image

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Add nix configuration for building container image (both for package and template).

Refactor logic from CLI commands to separate classes

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Refactor logic from CLI 'new' and 'run' commands to separate classes. It's a bad practice for interfaces to contain execution logic. Moreover, it'll be easier to develop, test, and maintain code that way.

TODO:

  • Decide on design pattern
  • Implement classes
  • Refactor CLI commands
  • Refactor and extend unit tests

CLI `fastapi-mvc new` `--license` option value is not passed to cookiecutter

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug
CLI fastapi-mvc new --license option is defined but not used.

Expected behavior
--license option value should be passed to cookiecutter.

To Reproduce
Not needed.

Environment

  • Python version: 3.9.9
  • Operating System and version: Linux 5.14.18-100.fc33.x86_64 #1 SMP Fri Nov 12 17:38:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • fastapi-mvc version: 0.7.0

Additional context
None

Installation fails on Python 3.10+

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug
I cannot use make install with Python 3.10. The installation fails because "Python version is less than 3.7".

Expected behavior
It should install correctly with Python 3.10.

To Reproduce

Environment

  • Python version: 3.10.4
  • Operating System and version: Ubuntu 20.04 LTS (WSL 2)
  • fastapi-mvc version: 0.9.0

Add support for binding gunicorn server to a UNIX socket

For now, only host and port options are implemented. However, situations may require the use of a UNIX socket instead of TCP/IP.

This change would require additional option and implementation in template CLI serve command. Also, It would be mutually excluding with --host and --port.

TODO:

  • Implement option for binding gunicorn server to a UNIX socket
  • Refactor default bind=.. env values in gunicorn.conf.py
  • Refactor run_wsgi() method in wsgi.py

Make container image reproducible

Currently, Python and poetry are installed in a non-deterministic way. Probably other packages in the builder container need to be checked as well.

Controller generator is creating duplicates entries in `config/router.py`

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug

$ fastapi-mvc generate controller demo method1 method2:post
[INFO] Running controller generator
(.venv) 
$ fastapi-mvc generate controller demo method1 method2:post
[INFO] Running controller generator
$ cat test_app/config/router.py 
"""Application routes configuration.

In this file all application endpoints are being defined.
"""
from fastapi import APIRouter
from test_app.app.controllers import demo
from test_app.app.controllers import demo
from test_app.app.controllers.api.v1 import ready

router = APIRouter(prefix="/api")

router.include_router(ready.router, tags=["ready"])
router.include_router(demo.router)
router.include_router(demo.router)

Expected behavior

Controller generator should validate if an entry already exists. If --skip flag is provided, don't override; else override.

To Reproduce

Run the same controller generator twice.

Environment

  • Python version: 3.9.6
  • Operating System: Linux-5.10.106-x86_64-with-glibc2.33
  • fastapi-mvc version: 0.10.0

Additional context

This is implemented in controller generator template post_gen_project.py hook.

Extend integration tests suite

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

The current integration tests suite for cookie-cutter is very basic. It would be beneficial to test for instance:

  • Different license contents
  • Generation with a combination of different options
  • Each generated projects make targets successful execution (maybe?)
  • ?

Improve project installation in Dockerfile

COPY . $PYSETUP_PATH
WORKDIR $PYSETUP_PATH
RUN make install && \
    poetry build && \
    $VENV_PATH/bin/pip install --no-deps dist/*.whl

Currently, the project is installed without a root package, then built and installed from the wheel. This is needed because Poetry doesn't support installing root package without editable mode. Otherwise venv with source code would need to be copied to the final image.
Applies both to package and template Dockerfiles.

Feature roadmap

Roadmap

Hello there! 👋

This is the roadmap for fastapi-mvc, which gives an overview of future features and ideas that will be implemented. If you want to contribute with new ideas, feel free to submit a feature request. You can also develop the ones that are listed. For more information please see contributing guidelines.

This roadmap is subject to change and features will be added as needed.

Checklist

  • Initial project template.
    • Implement FastAPI application core with unit tests.
    • Add Poetry for dependency management and packaging.
    • Add virtualized development environment.
    • Add Makefile.
    • Add Helm chart.
    • Add Aiohttp and Redis utilities.
    • Add Redis support.
    • Add make target for bootstrapping a local minikube cluster with High Availability Redis cluster, and deploy the application.
  • Add GitHub actions automation.
  • Documentation
  • #6
  • Improve Dockerfile for production use
  • Implement CLI fastapi-mvc run command for running uvicorn development server
  • Add initial generators implementation
  • #46
  • Add databases HA deployments to script for bootstrapping application stack in Kubernetes cluster.
    • PostgreSQL
    • Redis
  • #170
  • #25
  • #80
  • Add shell script generator
  • Python 3.11 Support
  • Improvements
  • #229

New project doesn't install correctly if created from activated virtualenv

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug
When creating a new project from an activated Poetry shell environment without option --skip-install. Executed make install in subprocess even though in the different working directory it seems Poetry is not creating a virtual env for a newly created project for some reason.

Expected behavior
Even though fastapi-mvc new was executed from an activated Poetry shell, the newly created project should install correctly.

To Reproduce

Frist activate Poetry shell, and create new project.

cd fastapi-mvc
make install
potery shell
fastapi-mvc new /tmp/foobar

Now from another terminal without activated Poetry shell.

cd /tmp/foobar/
poetry run foobar serve

Environment

  • Python version: 3.9.9
  • Operating System and version: Linux gdn-n-radoslaws 5.14.18-100.fc33.x86_64 #1 SMP Fri Nov 12 17:38:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • fastapi-mvc version: commit 5ddece6a9e65bb30f5332bb66ea9d8c8c553d181

Additional context
Example output of the problem

(.venv) $ fastapi-mvc new /tmp/foobar
[install] Begin installing project.
Updating dependencies
Resolving dependencies... (9.8s)

Writing lock file

No dependencies to install or update

Installing the current project: foobar (0.1.0)
Project successfully installed.
To activate virtualenv run: $ poetry shell
Now you should access CLI script: $ foobar --help
Alternatively you can access CLI script via poetry run: $ poetry run foobar --help
To deactivate virtualenv simply type: $ deactivate
To activate shell completion:
 - for bash: $ echo 'eval "$(_FOOBAR_COMPLETE=source_bash foobar)' >> ~/.bashrc
 - for zsh: $ echo 'eval "$(_FOOBAR_COMPLETE=source_zsh foobar)' >> ~/.zshrc
 - for fish: $ echo 'eval "$(_FOOBAR_COMPLETE=source_fish foobar)' >> ~/.config/fish/completions/foobar.fish

Now from another terminal:

$ cd /tmp/foobar/
$ poetry run foobar serve
Creating virtualenv foobar in /tmp/foobar/.venv
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/tmp/foobar/foobar/cli/cli.py", line 5, in <module>
    import click
ModuleNotFoundError: No module named 'click'

Maybe subprocess.run(["make", "install"], cwd=app_path) is executed as child process (hence inherites current virtualenv), and instead it should be fork. My guess is, that make install and Poetry looks at the current virtualenv and its dependencies.

Refactor fastapi-mvc project template into generators submodule

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Currently, project template is under the root package directory, whereas all other generators templates are under generators submodule. Moreover, it can be refactored with Generator base class. Then new_project.py command would be obsolete and could be removed.

Add documentation

TODO:

  • mkdocs config
  • Documentation contents
  • GH workflow for building and publishing docs to GH pages.

Implement global except hook, refactor current exceptions handling

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Implement a global except hook for unhandled exceptions that will log exception + debug info to make issuing defects easier.

Something like that:

$ fastapi-mvc run
[INFO] Executing shell command.
[WARNING] Activated virtual env detected.
[ERROR] Unhandled exception occurred during RunTime.
Traceback (most recent call last):
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/bin/fastapi-mvc", line 5, in <module>
    cli()
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/fastapi_mvc/cli/run.py", line 70, in run
    invoker.execute()
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/fastapi_mvc/commands/invoker.py", line 42, in execute
    command.execute()
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/fastapi_mvc/commands/run_shell.py", line 49, in execute
    ShellUtils.run_shell(
  File "/home/rszamszur/repos/gh/rszamszur/fastapi-mvc/fastapi_mvc/utils/shell.py", line 91, in run_shell
    process = subprocess.run(
  File "/nix/store/y3inmdhijqkb4qj36yphj4cbllljhqzz-python3-3.9.6/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/nix/store/y3inmdhijqkb4qj36yphj4cbllljhqzz-python3-3.9.6/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/y3inmdhijqkb4qj36yphj4cbllljhqzz-python3-3.9.6/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'poetry'
[INFO] Feel free to raise an issue here: https://github.com/rszamszur/fastapi-mvc/issues/new/choose
    Environment:
    Python version: 3.9.6
    Operating System: Linux-5.10.106-x86_64-with-glibc2.33
    fastapi-mvc version: 0.10.0

This feature might require some refactoring in project exceptions.

Implement generator generator

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Implement generator generator, for people to be able to write their own generators for fastapi-mvc.

This issue is just for creating the template and necessary logic.
The matter of how to load user generators, where to store them, etc. #69

Implement new template CLI serve command options

Implement the following options:

  • -d, --daemon (is_flag=true) run server as a Daemon.
  • -e, --environment (multiple=true) Pass additional environment variables to the execution environment.
  • -c, --config=file Uses a custom gunicorn.conf.py configuration
  • --pid Specifies the PID file.

+

  • Update template readme
  • Extend unit tests

Fix CI/metrics job for Python 3.10

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug

Run make metrics
[install] Begin installing project.
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: fastapi-mvc (0.9.0)
Project successfully installed.
To activate virtualenv run: $ poetry shell
Now you should access CLI script: $ fastapi-mvc --help
Alternatively you can access CLI script via poetry run: $ poetry run fastapi-mvc --help
To deactivate virtualenv simply type: $ deactivate
To activate shell completion:
 - for bash: $ echo 'eval "$(_FASTAPI_MVC_COMPLETE=source_bash fastapi-mvc)' >> ~/.bashrc
 - for zsh: $ echo 'eval "$(_FASTAPI_MVC_COMPLETE=source_zsh fastapi-mvc)' >> ~/.zshrc
 - for fish: $ echo 'eval "$(_FASTAPI_MVC_COMPLETE=source_fish fastapi-mvc)' >> ~/.config/fish/completions/fastapi-mvc.fish
[metrics] Run fastapi-mvc PEP 8 checks.
0
[metrics] Run fastapi-mvc PEP 25[7](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:7) checks.
0
[metrics] Run fastapi-mvc code complexity checks.
0
[metrics] Run fastapi-mvc open TODO checks.
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake[8](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:8)/checker.py", line 478, in run_ast_checks
    ast = self.processor.build_ast()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/processor.py", line 225, in build_ast
    return ast.parse("".join(self.lines))
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 7
    from {{cookiecutter.package_name}}.wsgi import run_wsgi
         ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/checker.py", line 676, in _run_checks
    return checker.run_checks()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/checker.py", line 58[9](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:9), in run_checks
    self.run_ast_checks()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.[10](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:10)/lib/python3.10/site-packages/flake8/checker.py", line 480, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/checker.py", line 465, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/main/application.py", line 363, in run
    self._run(argv)
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/main/application.py", line 351, in _run
    self.run_checks()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/main/application.py", line 264, in run_checks
    self.file_checker_manager.run()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/checker.py", line 3[21](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:21), in run
    self.run_parallel()
  File "/home/runner/.poetry/store/virtualenvs/fastapi-mvc-aA4DIUDL-py3.10/lib/python3.10/site-packages/flake8/checker.py", line [28](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:28)7, in run_parallel
    for ret in pool_map:
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/multiprocessing/pool.py", line 448, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/multiprocessing/pool.py", line 870, in next
    raise value
AttributeError: 'int' object has no attribute 'rstrip'
make: *** [Makefile:[31](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:6:31): metrics] Error 1
Error: Process completed with exit code 2.

Expected behavior

CI/metrics job to pass for Python 3.10

To Reproduce

Run CI workflow

Environment

  • Python version: 3.10.4
  • Operating System and version:
Current runner version: '[2](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:1:2).289.2'
Operating System
  Ubuntu
  20.04.4
  LTS
Virtual Environment
  Environment: ubuntu-20.04
  Version: 20220[3](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:1:3)30.0
  Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20220330.0/images/linux/Ubuntu200[4](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:1:4)-Readme.md
  Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F20220330.0
Virtual Environment Provisioner
  1.0.0.0-main-2022032[5](https://github.com/rszamszur/fastapi-mvc/runs/5850673995?check_suite_focus=true#step:1:5)-1
  • fastapi-mvc version: 0.9.0

Additional context

It seems there is a typo in the script:
https://github.com/rszamszur/fastapi-mvc/blob/acdde1d7184a200846fedd093c84d06fae4f2b56/build/metrics.sh#L20

no space between options --exclude fastapi_mvc/template--output-file=todo_occurence.txt

Also, for Python 3.10 an update of flake8 might be needed as well:
PyCQA/flake8#1372

Implement run command

fastapi-mvc run ...

This would be a wrapper for a generated project serve CLI command. Just another option to run a project.

Refactor existing documentation with Sphinx

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Refactor current documentation with Sphinx. IMHO is better for my use-case + it can generate API docs from Google docstrings.

  • Create Sphinx documentation
  • Add API reference generated from docstrings
  • Overall improve docstrings

Refactor `fastapi_mvc.commands` to be more generic

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Currently, fastapi_mvc.commands aren't fully fulfilling the commands design pattern. Moreover, some of them could be more generic, ex:
run_uvicorn and install_project do exactly the same but somehow they ended up in separate classes.

Related to: #51

Improve make target scripts

  • [install] Allow overriding Python binary from env
  • [install] Fix Poetry being installed in a non-deterministic way.
  • [all] Remove unused DIR var
  • [metrics, unit-test, integration-test] Set default poetry home var

ModuleNotFoundError: No module named 'test-app'

  • [X ] I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug

I receive the error ModuleNotFoundError: No module named 'test-app' after fresh install of fastapi-mvc

Expected behavior

:) to work

To Reproduce

Install fastapi-mvc on a mac machine with MacOS High Sierra 10.13.6 and follow the steps from documentation:
pip install fastapi-mvc
fastapi-mvc new /test-app
cd /test-app
fastapi-mvc run

Environment

Additional context

Refactor execution logic from CLI into command design pattern

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Refactor commands execution logic into the strategy design pattern.

There already was one ticket for refactoring logic from CLI: #38. However, it mainly refactored common code parts into separate classes for reusability across the entire project. But, there still are some logic leftovers inside CLI commands. Each feature/enhancement/bug_fixe might grow it, which makes testing more complex, code less readable, and more difficult to extend and maintain codebase. This is already taking its toll at the current stage of development.

Benefits:

  • Possibility to swap algorithms used inside an object at runtime
  • Isolate the implementation details of an algorithm from the code that uses it.
  • Code more oriented towards single-responsibility principle and open–closed principle
  • Ease of adding a new interface or implementing API for programmatically executing fastapi-mvc actions. (Not that this is utterly needed, but still a benefit)
  • Should be easier to unit test and maintain the codebase

Tradeoffs:

  • Refactoring effort, and the possibility of bugs introduced with this change.
  • One needs to know the strategy design pattern. This can make entry-level more complex.
  • This approach assumes one can wrap algorithms implementation in some kind of abstraction. The less similarity between implementations (method signature, needed classes/functions, etc.), the more difficult it is to implement and utilize this pattern.

Add python 3.10 in CI tests

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Currently, the project is not tested against python 3.10:
https://github.com/rszamszur/fastapi-mvc/blob/acdde1d7184a200846fedd093c84d06fae4f2b56/.github/workflows/main.yml#L24-L26

The same can be applied to the cookiecutter template CI workflow:
https://github.com/rszamszur/fastapi-mvc/blob/acdde1d7184a200846fedd093c84d06fae4f2b56/fastapi_mvc/template/%7B%7Bcookiecutter.folder_name%7D%7D/.github/workflows/main.yml#L24-L26

Related issue: #60

Migrate to Poetry 1.2.x release

The get-poetry.py script will be replaced in Poetry 1.2 by install-poetry.py.

Moreover, some additional adjustments will be needed in order to accommodate to new minor version:

  • Change default $POETRY_HOME to $HOME/.local/share/pypoetry in all relevant files (make scripts, Dockerfiles, nix shell expressions).
  • Change absolute path to poetry executable to: $POETRY_HOME/venv/bin/poetry
  • Update install scripts with install-poetry.py URL.
  • Update Poetry config in GitHub workflows

The above applies to both package (fastapi-mvc) and template.

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.