Auto HTTP Exception Mapping for SQLAlchemy errors in FastAPI
Since this is just a package, and not a service, there is no real "run" action. But you can run the tests immediately.
Here are a list of available commands via make.
make install- install the required dependencies.make test- runs the tests.
make build-docker- build the docker image.make run-docker- run the docker compose services.make test-docker- run the tests in docker.make clean-docker- remove all docker containers etc.
Install uv, (if you haven't already)
https://docs.astral.sh/uv/getting-started/installation/#installation-methods
brew install uvInitialise pre-commit (validates ruff on commit.)
uv run pre-commit installInstall dependencies (including dev dependencies)
uv syncIf you are adding a new dev dependency, please run:
uv add --dev {your-new-package}Packages all share the same namespace ab_core. To import this package into
your project:
from ab_core.sqlalchemy_fastapi_http_exceptions import placeholder_funcWe encourage you to make your package available to all of ab via this
ab_core namespace. The goal is to streamline development, POCs and overall
collaboration.
The library is available on PyPI. You can install it using the following command:
Using pip:
pip install ab-sqlalchemy-fastapi-http-exceptionsUsing UV
Note: there is currently no nice way like poetry, hence we still needd to provide the full url. astral-sh/uv#10140
Add the dependency
uv add ab-sqlalchemy-fastapi-http-exceptionsUsing poetry:
Then run the following command to install the package:
poetry add ab-sqlalchemy-fastapi-http-exceptionsExample Usage
# Please update this based on your package!
from ab_core.sqlalchemy_fastapi_http_exceptions import placeholder_func
if __name__ == "__main__":
print("This is a placeholder: ", placeholdder_func())We use Ruff as the formatter and linter. The pre-commit has hooks which runs checking and applies linting automatically. The CI validates the linting, ensuring main is always looking clean.
You can manually use these commands too:
make lint- check for linting issues.make format- fix linting issues.
We publish to PyPI using Github releases. Steps are as follows:
- Manually update the version in
pyproject.tomlfile using a PR and merge to main. Useuv version --bump {patch/minor/major}to update the version. - Create a new release in Github with the tag name as the version number. This
will trigger the
publishworkflow. In the Release window, type in the version number and it will prompt to create a new tag. - Verify the release in PyPI