This guide assumes that the reader has a minimal experience with python and its virtualenvs.
- Install gdal
$ brew install gdalor (untested)$ apt install gdal. - Install a python version (this was tested with 3.11.3):
$ pyenv install 3.11.3. Ifpyenvis not available in your OS, you can usevirtualenv(poetrymay require different steps). - Create a virtualenv:
$ pyenv virtualenv 3.11.3 earthpulse-simple-api - If not already, now you can start using that environment:
$ pyenv activate earthpulse-simple-api - Install dependences:
$ pip install -r requirements.txt - (Optional) Install dev dependences (for linting and such):
$ pip install -r requirements-dev.txt - Fill credentials in
.envfile. Do not use double quotes or whitespaces. - Execute the cli app.
$ python app/simple_api.py(no params/argparse use yet).
As a regular python app (in the right environment):
$ python app/simple_api.pyor using makefile entrypoint:
$ make runThen you should be able to access [http://0.0.0.0:80/docs] and play around with the exposed endpoint. If you prefer, you can also check docs via [http://0.0.0.0:80/redoc] UI.
First build the image (read the file first to understand what it does):
$ docker build -t earthpulse-simple-api .Then you can run a container based on that image:
$ docker run -d --name earthpuse-test-container -p 80:80 earthpulse-simple-api- Consider the use of pylama for more complete linting.
- Add some FastAPI middlewares, such HTTPSRedirectMiddleware, TrustedHostMiddleware.
- Integrate some logs/app monitor like Sentry or Datadog.
- Using Github actions, check linters and go further (staging/deploy) only if certain threshold has been met (done).
Please ensure you have installed development dependences first: $ pip install -r requirements-dev.txt.
Very fast linter, but still does not have the same amount or rules available in pylint. It would be perfect to be used
in a pre-commit Git hook. Uses pyproject.toml as configuration file.
ruff check .It uses the configuration pylintrc settings file. No rules were disabled, AFAIK. It takes more time with larger
codebases. It can be executed locally, and tipically in CD/CI pipelines instead of ruff (because of its large amount
of rules), making the pipeline failing if a minimum threshold score is not reached.
$ pylint $(find . -name "*.py")
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)Not exactly a linter, but a useful tool anyway. It ensures some guide styling in regards of module imports.
$ isort .Ensure you install dev-requirements first. Then simply execute:
$ python -m unittest discoverYou can run (you need to be in the right virtualenv first):
make run
make tests
make lintA Github action has been added (.github/workflows/code_quality.yml) to check pylint over all py files in the
main branch. If linter score is higher than 9, it could continue to the next ci/cd step (not defined yet).