Skip to content

Commit 8bf9288

Browse files
committed
Merge branch 'chore/dependency-upgrade-latest'
2 parents adca2ed + d4f7836 commit 8bf9288

File tree

11 files changed

+28
-1068
lines changed

11 files changed

+28
-1068
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ dmypy.json
115115
# Pyre type checker
116116
.pyre/
117117

118-
tmp/
118+
/tmp/
Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,45 @@
11
# Northwind Backend
22

3-
This backend contains two SAFRS app variants over the same Northwind model layer:
3+
This backend is the FastAPI SAFRS backend used by the demo container.
44

5-
- a Flask app using `SafrsApi`
6-
- a FastAPI app using `SafrsFastAPI`
7-
8-
They exist side by side so the same validation project can be used to compare consumer-facing behavior easily.
5+
It can also be run standalone from this directory with `run.py`.
96

107
## Current intent
118

12-
- both backends use the same SQLite database
13-
- both backends expose the same resource and relationship names as the Northwind `admin.yaml`
14-
- both backends use the same `admin.yaml`
15-
- both backends are intended to run on port `5656`
16-
17-
The main SAFRS development track is FastAPI, but Flask remains the reference behavior. This project supports switching between them quickly.
9+
- the demo container uses the FastAPI variant only
10+
- the backend uses the Northwind SQLite database
11+
- it exposes the same resource and relationship names as the shipped Northwind `admin.yaml`
12+
- it serves the same `admin.yaml` used by the frontend
13+
- the default standalone port is `5656`
1814

19-
## Quick start
15+
## Run standalone
2016

21-
Create a virtual environment, install the requirements, and run one backend variant from this directory:
17+
From this directory:
2218

2319
```bash
2420
python -m venv .venv
2521
. .venv/bin/activate
2622
pip install -r requirements.txt
27-
python run.py fastapi
28-
```
29-
30-
Or:
31-
32-
```bash
33-
python run.py flask
23+
python run.py
3424
```
3525

36-
Default URL targets for both variants:
26+
Because `requirements.txt` contains `-e ../vendor/safrs`, run `pip install -r requirements.txt` from the `backend/` directory so that relative path resolves correctly.
3727

38-
- API root: `http://127.0.0.1:5656/api`
39-
- Admin schema: `http://127.0.0.1:5656/ui/admin/admin.yaml`
40-
41-
## Switching
42-
43-
Use one process at a time on the same port:
44-
45-
- `python run.py fastapi`
46-
- `python run.py flask`
28+
`python run.py` defaults to the FastAPI app.
4729

4830
You can also override host and port:
4931

5032
```bash
5133
python run.py fastapi --host 127.0.0.1 --port 5656
52-
python run.py flask --host 127.0.0.1 --port 5656
5334
```
5435

36+
Default URL targets:
37+
38+
- API root: `http://127.0.0.1:5656/api`
39+
- docs: `http://127.0.0.1:5656/docs`
40+
- OpenAPI: `http://127.0.0.1:5656/jsonapi.json`
41+
- Admin schema: `http://127.0.0.1:5656/ui/admin/admin.yaml`
42+
5543
## Current scope
5644

5745
The backend now exposes the full resource set currently described in `reference/nw-admin.yaml`:
@@ -74,4 +62,4 @@ The backend now exposes the full resource set currently described in `reference/
7462
- `Territory`
7563
- `Union`
7664

77-
The active validation focus is no longer basic exposure. It is parity: the Flask and FastAPI apps should both honor the same documented contract and accept the same consumer-facing include paths.
65+
The active validation focus is consumer-facing parity and behavior validation against the frontend and example clients.

examples/docker_fastapi_demo/backend/run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_args() -> argparse.Namespace:
1919
"framework",
2020
nargs="?",
2121
choices=("fastapi", "flask"),
22-
help="Backend implementation to run. Defaults to NORTHWIND_BACKEND or fastapi.",
22+
help="Backend implementation to run. Defaults to fastapi.",
2323
)
2424
parser.add_argument("--host", help="Bind host override.")
2525
parser.add_argument("--port", type=int, help="Bind port override.")
@@ -29,7 +29,7 @@ def parse_args() -> argparse.Namespace:
2929
def main() -> None:
3030
args = parse_args()
3131
settings = get_settings()
32-
framework = (args.framework or settings.default_framework).lower()
32+
framework = (args.framework or "fastapi").lower()
3333
host = args.host or settings.host
3434
port = args.port or settings.port
3535

@@ -43,9 +43,9 @@ def main() -> None:
4343
from fastapi import FastAPI
4444
from fastapi.middleware.wsgi import WSGIMiddleware
4545

46-
flask_runner = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
47-
flask_runner.mount("/", WSGIMiddleware(create_flask_app()))
48-
uvicorn.run(flask_runner, host=host, port=port, log_level="info")
46+
wsgi_runner = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
47+
wsgi_runner.mount("/", WSGIMiddleware(create_flask_app()))
48+
uvicorn.run(wsgi_runner, host=host, port=port, log_level="info")
4949

5050

5151
if __name__ == "__main__":

safrs/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ def _raise_missing_flask_adapter_error(exc: ModuleNotFoundError) -> None:
3232
except ModuleNotFoundError as exc:
3333
if exc.name not in _MISSING_FLASK_ADAPTER_DEPS:
3434
raise
35+
_missing_flask_adapter_exc = exc
3536

3637
class SAFRSAPI: # type: ignore[no-redef]
3738
def __init__(self, *_args: Any, **_kwargs: Any) -> None:
38-
_raise_missing_flask_adapter_error(exc)
39+
_raise_missing_flask_adapter_error(_missing_flask_adapter_exc)
3940

4041

4142
SafrsApi = SAFRSAPI

tmp/fastapi_app.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

tmp/flask_app.py

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)