Skip to content

Commit

Permalink
Fix pay-queue
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 committed Oct 8, 2024
1 parent 9a8ea2d commit 72af1ad
Show file tree
Hide file tree
Showing 35 changed files with 4,067 additions and 2,674 deletions.
18 changes: 15 additions & 3 deletions pay-queue/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,27 @@ install: clean
#################################################################################
# COMMANDS - CI #
#################################################################################
ci: lint flake8 test ## CI flow
ci: isort-ci black-ci lint flake8 test ## CI flow

isort:
poetry run isort .

isort-ci:
poetry run isort --check .

black: ## Linting with black
poetry run black .

black-ci:
poetry run black --check .

pylint: ## Linting with pylint
poetry run pylint --rcfile=setup.cfg src/$(PROJECT_NAME)
poetry run pylint src/$(PROJECT_NAME)

flake8: ## Linting with flake8
poetry run flake8 src/$(PROJECT_NAME) tests

lint: pylint flake8 ## run all lint type scripts
lint: isort black pylint flake8 ## run all lint type scripts

test: ## Unit testing
poetry run pytest
Expand Down
8 changes: 5 additions & 3 deletions pay-queue/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
"""Initialize Flask app."""

import os

from pay_queue import create_app

app = create_app()

if __name__ == '__main__':
server_port = os.environ.get('PORT', '5001')
app.run(debug=False, port=server_port, host='0.0.0.0')
if __name__ == "__main__":
server_port = os.environ.get("PORT", "5001")
app.run(debug=False, port=server_port, host="0.0.0.0")
12 changes: 6 additions & 6 deletions pay-queue/gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import os

# https://docs.gunicorn.org/en/stable/settings.html#workers
workers = int(os.environ.get('GUNICORN_PROCESSES', '1')) # gunicorn default - 1
worker_class = os.environ.get('GUNICORN_WORKER_CLASS', 'sync') # gunicorn default - sync
worker_connections = int(os.environ.get('GUNICORN_WORKER_CONNECIONS', '1000')) # gunicorn default - 1000
threads = int(os.environ.get('GUNICORN_THREADS', '4')) # gunicorn default - 1
timeout = int(os.environ.get('GUNICORN_TIMEOUT', '100')) # gunicorn default - 30
keepalive = int(os.environ.get('GUNICORN_KEEPALIVE', '2')) # gunicorn default - 2
workers = int(os.environ.get("GUNICORN_PROCESSES", "1")) # gunicorn default - 1
worker_class = os.environ.get("GUNICORN_WORKER_CLASS", "sync") # gunicorn default - sync
worker_connections = int(os.environ.get("GUNICORN_WORKER_CONNECIONS", "1000")) # gunicorn default - 1000
threads = int(os.environ.get("GUNICORN_THREADS", "4")) # gunicorn default - 1
timeout = int(os.environ.get("GUNICORN_TIMEOUT", "100")) # gunicorn default - 30
keepalive = int(os.environ.get("GUNICORN_KEEPALIVE", "2")) # gunicorn default - 2
# WHEN MIGRATING TO GCP - GUNICORN_THREADS = 8, GUNICORN_TIMEOUT = 0, GUNICORN_PROCESSES = 1
84 changes: 83 additions & 1 deletion pay-queue/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions pay-queue/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,129 @@ pydocstyle = "^6.3.0"
isort = "^5.13.2"
lovely-pytest-docker = "^0.3.1"
pytest-asyncio = "0.18.3"
black = "^24.10.0"
flake8-pyproject = "^1.2.3"

[tool.flake8]
ignore = ["F401","E402", "Q000", "E203", "W503"]
exclude = [
".venv",
"./venv",
".git",
".history",
"devops",
"*migrations*",
]
per-file-ignores = [
"__init__.py:F401",
"*.py:B902"
]
max-line-length = 120
docstring-min-length=10
count = true

[tool.zimports]
black-line-length = 120
keep-unused-type-checking = true

[tool.black]
target-version = ["py310", "py311", "py312"]
line-length = 120
include = '\.pyi?$'
extend-exclude = '''
/(
# The following are specific to Black, you probably don't want those.
migrations
| devops
| .history
)/
'''

[tool.isort]
atomic = true
profile = "black"
line_length = 120
skip_gitignore = true
skip_glob = ["migrations", "devops"]

[tool.pylint.main]
fail-under = 10
max-line-length = 120
ignore = [ "migrations", "devops", "tests"]
ignore-patterns = ["^\\.#"]
ignored-modules= ["flask_sqlalchemy", "sqlalchemy", "SQLAlchemy" , "alembic", "scoped_session"]
ignored-classes= "scoped_session"
ignore-long-lines = "^\\s*(# )?<?https?://\\S+>?$"
extension-pkg-whitelist = "pydantic"
notes = ["FIXME","XXX","TODO"]
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED"]
disable = "C0209,C0301,W0511,W0613,W0703,W1514,W1203,R0801,R0902,R0903,R0911,R0401,R1705,R1718,W3101"
argument-naming-style = "snake_case"
attr-naming-style = "snake_case"
class-attribute-naming-style = "any"
class-const-naming-style = "UPPER_CASE"
class-naming-style = "PascalCase"
const-naming-style = "UPPER_CASE"
function-naming-style = "snake_case"
inlinevar-naming-style = "any"
method-naming-style = "snake_case"
module-naming-style = "any"
variable-naming-style = "snake_case"
docstring-min-length = -1
good-names = ["i", "j", "k", "ex", "Run", "_"]
bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"]
defining-attr-methods = ["__init__", "__new__", "setUp", "asyncSetUp", "__post_init__"]
exclude-protected = ["_asdict", "_fields", "_replace", "_source", "_make", "os._exit"]
valid-classmethod-first-arg = ["cls"]
valid-metaclass-classmethod-first-arg = ["mcs"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
minversion = "2.0"
testpaths = [
"tests",
]
addopts = "--verbose --strict -p no:warnings --cov=src --cov-report html:htmlcov --cov-report xml:coverage.xml"
python_files = [
"test*.py"
]
norecursedirs = [
".git", ".tox", "venv*", "requirements*", "build",
]
log_cli = true
log_cli_level = "1"
filterwarnings = [
"ignore::UserWarning"
]
markers = [
"slow",
"serial",
]

[tool.coverage.run]
branch = true
source = [
"src/auth_api",
]
omit = [
"wsgi.py",
"gunicorn_config.py"
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"from",
"import",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
'if __name__ == "__main__":',
]

[build-system]
requires = ["poetry-core"]
Expand Down
38 changes: 21 additions & 17 deletions pay-queue/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

from setuptools import find_packages, setup

_version_re = re.compile(r"__version__\s+=\s+(.*)") # pylint: disable=invalid-name

_version_re = re.compile(r'__version__\s+=\s+(.*)') # pylint: disable=invalid-name

with open('src/pay_queue/version.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search( # pylint: disable=invalid-name
f.read().decode('utf-8')).group(1)))
with open("src/pay_queue/version.py", "rb") as f:
version = str(
ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1)) # pylint: disable=invalid-name
)


def read_requirements(filename):
Expand All @@ -34,9 +34,9 @@ def read_requirements(filename):
the requirements.txt file.
:return: Python requirements
"""
with open(filename, 'r') as req:
with open(filename, "r") as req:
requirements = req.readlines()
install_requires = [r.strip() for r in requirements if (r.find('git+') != 0 and r.find('-e git+') != 0)]
install_requires = [r.strip() for r in requirements if (r.find("git+") != 0 and r.find("-e git+") != 0)]
return install_requires


Expand All @@ -46,25 +46,29 @@ def read(filepath):
:param str filepath: path to the file to be read
:return: file contents
"""
with open(filepath, 'r') as file_handle:
with open(filepath, "r") as file_handle:
content = file_handle.read()
return content


REQUIREMENTS = read_requirements('requirements.txt')
REQUIREMENTS = read_requirements("requirements.txt")

setup(
name="pay_queue",
version=version,
author_email='',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
author_email="",
packages=find_packages("src"),
package_dir={"": "src"},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
include_package_data=True,
license=read('LICENSE'),
long_description=read('README.md'),
license=read("LICENSE"),
long_description=read("README.md"),
zip_safe=False,
install_requires=REQUIREMENTS,
setup_requires=["pytest-runner", ],
tests_require=["pytest", ],
setup_requires=[
"pytest-runner",
],
tests_require=[
"pytest",
],
)
Loading

0 comments on commit 72af1ad

Please sign in to comment.