generated from owl-corp/python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
525887d
commit 71d1ea5
Showing
17 changed files
with
1,116 additions
and
1,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
services: | ||
postgres: | ||
restart: unless-stopped | ||
image: postgres:16-alpine | ||
environment: | ||
POSTGRES_DB: thallium | ||
POSTGRES_PASSWORD: thallium | ||
POSTGRES_USER: thallium | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U thallium"] | ||
interval: 2s | ||
timeout: 1s | ||
retries: 5 | ||
ports: | ||
- "15432:5432" | ||
|
||
thallium: | ||
build: . | ||
build: thallium-backend | ||
restart: unless-stopped | ||
command: ["thallium.app:app", "--host", "0.0.0.0", "--port", "80", "--reload"] | ||
volumes: | ||
- ./thallium:/thallium/thallium:ro | ||
command: ["src.app:fastapi_app", "--host", "0.0.0.0", "--port", "80", "--reload"] | ||
# volumes: | ||
# - ./thallium:/thallium/thallium:ro | ||
env_file: | ||
- .env | ||
ports: | ||
- "127.0.0.1:8000:80" | ||
- "8000:80" | ||
depends_on: | ||
postgres: | ||
condition: service_healthy |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
[tool.poetry] | ||
name = "thallium" | ||
version = "1.2.0" | ||
description = "Distribute printful prizes to winners." | ||
description = "Distribute printful prizes to users with vouchers" | ||
authors = ["Chris Lovering <[email protected]>"] | ||
license = "MIT" | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "3.12.*" | ||
python = "^3.12.0" | ||
|
||
litestar = { version = "^2.10.0", extras = ["standard"] } | ||
alembic = {version = "^1.13.2", extras = ["tz"]} | ||
fastapi = "^0.112.0" | ||
httpx = "^0.23.3" | ||
sqlalchemy = {version = "^2.0.32", extras = ["asyncio"]} | ||
psycopg = {version = "^3.2.1", extras = ["binary"]} | ||
pydantic = "^2.8.2" | ||
pydantic-settings = "^2.4.0" | ||
uvicorn = "^0.30.6" | ||
|
||
[tool.poetry.group.linting.dependencies] | ||
pre-commit = "^3.8.0" | ||
|
@@ -21,7 +26,7 @@ ruff = "^0.5.5" | |
poetry-plugin-export = "*" | ||
|
||
[tool.poetry.group.test.dependencies] | ||
pytest ="^8.3.2" | ||
pytest = "^8.3.2" | ||
pytest-asyncio = "^0.23.8" | ||
pytest-xdist = "^3.6.1" | ||
|
||
|
@@ -34,7 +39,6 @@ target-version = "py312" | |
extend-exclude = [".cache"] | ||
line-length = 120 | ||
unsafe-fixes = true | ||
preview = true | ||
output-format = "concise" | ||
|
||
[tool.ruff.lint] | ||
|
@@ -50,13 +54,13 @@ ignore = [ | |
] | ||
|
||
[tool.ruff.lint.isort] | ||
known-first-party = ["tests", "thallium"] | ||
known-first-party = ["tests", "src"] | ||
order-by-type = false | ||
case-sensitive = true | ||
combine-as-imports = true | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"tests/**" = ["D103", "S101"] | ||
"*/tests/**" = ["D103", "S101"] | ||
|
||
[tool.pytest.ini_options] | ||
# addopts = "--ignore=examples" | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
** | ||
|
||
# Except what we need | ||
!thallium | ||
!src | ||
!requirements.txt | ||
!LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import logging | ||
|
||
from fastapi import FastAPI, Request | ||
from fastapi.exceptions import RequestValidationError | ||
from fastapi.responses import JSONResponse | ||
|
||
from src.settings import CONFIG | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
fastapi_app = FastAPI(debug=CONFIG.debug) | ||
|
||
|
||
@fastapi_app.get("/heartbeat") | ||
def health_check() -> JSONResponse: | ||
"""Return basic response, for use as a health check.""" | ||
return JSONResponse({"detail": "I am alive!"}) | ||
|
||
|
||
@fastapi_app.exception_handler(RequestValidationError) | ||
def pydantic_validation_error(request: Request, error: RequestValidationError) -> JSONResponse: | ||
"""Raise a warning for pydantic validation errors, before returning.""" | ||
log.warning("Error from %s: %s", request.url, error) | ||
return JSONResponse({"error": str(error)}, status_code=422) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pydantic_settings import BaseSettings | ||
|
||
|
||
class _CONFIG(BaseSettings, env_file=".env", env_file_encoding="utf-8"): | ||
debug: bool = False | ||
git_sha: str = "development" | ||
|
||
|
||
CONFIG = _CONFIG() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from fastapi.testclient import TestClient | ||
|
||
from src.app import fastapi_app | ||
|
||
|
||
def test_heartbeat() -> None: | ||
"""Ensure the heartbeat works.""" | ||
with TestClient(app=fastapi_app) as client: | ||
assert client.get("/heartbeat").json() == {"detail": "I am alive!"} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.