Skip to content

Commit

Permalink
cleanup notes, promote to v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ModischFabrications committed Apr 10, 2024
1 parent 06cdf82 commit 1a80a93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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%.
Expand Down Expand Up @@ -131,15 +132,15 @@ 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:

* [pipenv](https://github.com/pypa/pipenv): library management
* [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

Expand Down
4 changes: 1 addition & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1a80a93

Please sign in to comment.