From 1a80a93c2f07dac812349bf69455413600a8a146 Mon Sep 17 00:00:00 2001 From: ModischFabrications Date: Wed, 10 Apr 2024 19:37:25 +0200 Subject: [PATCH] cleanup notes, promote to v1.0.2 --- README.md | 9 +++++---- app/main.py | 4 +--- app/settings.py | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bcb7723..8dbabf6 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ This Solver is using integers exclusively, as there is no need for arbitrary pre Feel free to shift your numbers a few decimals if you need fractions. It has no concept of units, so you can use whatever you want. -*Nerd talk*: This is the 2D "Cutting Stock Problem", which is NP-hard. It can be reduced to the Bin-Packing-Problem ( -BPP). +*Nerd talk*: This is the 2D "Cutting Stock Problem", which is NP-hard. No algorithm exists to calculate a perfect solution in polynomial time, therefore brute force (perfect solution) is used for small jobs (usually <12 entries) and FFD (fast solution) für larger ones. Don't be surprised if you get different results, many combinations have equal trimmings and are therefore seen as @@ -82,6 +81,8 @@ Change version number in main.py:version for newer releases, git tags will be cr Remember to test your changes using `pytest`. This will happen automatically both in pre-commit and in CI/CD, but manual tests will reduce iteration times. +Make sure your changes keep app.* imports or pytest will crash and burn due to missing import settings. + Code coverage and runtimes can be checked using `pipenv run python -m pytest --durations=5 --cov=app/ --cov-report term-missing`. Make sure that all critical parts of the code are covered, at v1.0.1 it is at 94%. @@ -131,7 +132,7 @@ This project uses: * [FastAPI](https://github.com/tiangolo/fastapi): easy API (this includes much more!) * [Uvicorn](https://github.com/encode/uvicorn): async web server -* [more-itertools](https://github.com/more-itertools/more-itertools): higher performance iterations +* [more-itertools](https://github.com/more-itertools/more-itertools): higher performance permutations Also used for development is: @@ -139,7 +140,7 @@ Also used for development is: * [httpie](https://github.com/jakubroztocil/httpie): simpler `curl` for docker healthchecks * [pytest](https://pytest.org): A lot nicer unit tests * [flake8](https://flake8.pycqa.org/): Linting -* [Mypy](https://mypy-lang.org/): Static type checking +* [mypy](https://mypy-lang.org/): Static type checking * [requests](https://requests.readthedocs.io/): simple HTTP requests * [black](https://github.com/psf/black): uncompromising code formatter; currently unused diff --git a/app/main.py b/app/main.py index fbcd462..c9f89e9 100644 --- a/app/main.py +++ b/app/main.py @@ -7,8 +7,6 @@ from starlette.responses import HTMLResponse, PlainTextResponse from app.settings import version, solverSettings -# don't mark /app as a sources root or pycharm will delete the "app." prefix -# that's needed for pytest to work correctly from app.solver.data.Job import Job from app.solver.data.Result import Result from app.solver.solver import solve @@ -58,7 +56,7 @@ async def catch_exceptions_middleware(request: Request, call_next): # response model ensures correct documentation, exclude skips optional @app.post("/solve", response_model=Result, response_model_exclude_defaults=True) def post_solve(job: Job): - # pydantic guarantees type safety, no need to check manually + # pydantic guarantees type safety, no need to check inputs solved: Result = solve(job) return solved diff --git a/app/settings.py b/app/settings.py index ef6cce3..77d4884 100644 --- a/app/settings.py +++ b/app/settings.py @@ -2,7 +2,7 @@ from pydantic_settings import BaseSettings # constant; used for git tags -version = "v1.0.1" +version = "v1.0.2" class SolverSettings(BaseSettings):