Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Flask to FastAPI #64

Merged
merged 9 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
36 changes: 0 additions & 36 deletions .github/workflows/release.yml

This file was deleted.

167 changes: 25 additions & 142 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,163 +1,46 @@
---
ci:
autofix_commit_msg: "Chore: pre-commit autoupdate"
skip:
# pre-commit.ci cannot install WGET, so tomlint must be disabled
- tomllint
# pre-commit.ci throws some error related to Docker!
- shellcheck
# Redundant with pre-commit.ci
- pip-audit

exclude: |
(?x)^(
docs\/conf.py|
dco-signoffs/$
)$

repos:
- repo: local
hooks:
- id: tomllint
name: "Script: scripts/tomllint.sh"
language: script
# pass_filenames: false
files: \^*.toml
types: [file]
entry: scripts/tomllint.sh .

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-merge-conflict
- id: end-of-file-fixer
- id: name-tests-test
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
# - id: detect-aws-credentials
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: name-tests-test
# Do not allow direct push to main/master branches
- id: no-commit-to-branch
# - id: pretty-format-json
- id: requirements-txt-fixer
- id: trailing-whitespace

# Autoformat: YAML, JSON, Markdown, etc.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: prettier
args:
["--ignore-unknown", "--no-error-on-unmatched-pattern", "!chart/**"]
- id: remove-tabs
exclude: ^.*(\.(tsv)|Makefile)$

# Lint: Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: markdownlint
args: ["--fix"]
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --config=pyproject.toml]
- id: ruff-format

# - repo: https://github.com/asottile/pyupgrade
# rev: v3.15.0
# hooks:
# - id: pyupgrade
# args: ['--py37-plus']

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black-jupyter

- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint

- repo: https://github.com/openstack/bashate
rev: 2.1.1
hooks:
- id: bashate
args: ["--ignore=E006"]

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
# Optionally only show errors and warnings
# args: ["--severity=warning"]

# If you want to avoid flake8 errors due to unused vars or imports:
# - repo: https://github.com/PyCQA/autoflake
# rev: v2.0.0
# hooks:
# - id: autoflake
# args: [
# --in-place,
# --remove-all-unused-imports,
# --remove-unused-variables,
# ]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint
args: [--strict]

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.6.26.11
hooks:
- id: actionlint

# If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
# rev: v1.13.0
# hooks:
# - id: blacken-docs
# additional_dependencies: [black]

- repo: https://github.com/pycqa/flake8
rev: "6.1.0"
- repo: local
hooks:
- id: flake8

# Check for misspells in documentation files:
# - repo: https://github.com/codespell-project/codespell
# rev: v2.2.2
# hooks:
# - id: codespell
- id: mypy-cache
name: "create mypy cache"
language: system
pass_filenames: false
entry: bash -c 'if [ ! -d .mypy_cache ];
then /bin/mkdir .mypy_cache; fi; exit 0'

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.7.1"
rev: "v1.11.1"
hooks:
- id: mypy

- repo: local
hooks:
- id: pip-audit
name: "Script: scripts/pipaudit.sh"
language: script
# pass_filenames: false
entry: scripts/pipaudit.sh
verbose: true
args: ["--show-error-codes", "--install-types", "--non-interactive"]
additional_dependencies: ["pytest", "types-requests"]
35 changes: 0 additions & 35 deletions .thoth.yaml

This file was deleted.

15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal
FROM registry.access.redhat.com/ubi9/ubi-minimal

# Create working directory
RUN mkdir -p /usr/local/src/app
Expand All @@ -12,9 +12,11 @@ RUN \
# Install shadow-utils for adduser functionality
microdnf -y install shadow-utils \
# Install Python 3.9
&& microdnf -y install python38 \
&& microdnf -y install python39 pip \
# Install pdm
&& pip install -U pdm \
# Install application
&& pip3 install . \
&& pdm install --check --prod --no-editable \
# Clean up unnecessary data
&& microdnf clean all && rm -rf /var/cache/yum

Expand All @@ -25,5 +27,8 @@ USER physrisk-api
# Enable communication via port 8081
EXPOSE 8081

# Run application
CMD ["waitress-serve", "--port=8081", "--call", "src.physrisk_api.app:create_app"]
# Add venv into PATH
ENV PATH="/usr/local/src/app/.venv/bin:$PATH"

# Run FastAPI application
CMD ["fastapi", "run", "src/physrisk_api/app/main.py", "--port", "8081", "--workers", "1"]
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

23 changes: 0 additions & 23 deletions Pipfile

This file was deleted.

Loading
Loading