Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Etienne Jodry authored and Etienne Jodry committed Apr 30, 2024
1 parent 57165c6 commit 7eeff5c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**Source Code**: <a href="https://github.com/bag-cnag/biodm" target="_blank">https://github.com/bag-cnag/biodm</a>

**Documentation**: Not hosted yet, please refer to [build documentation](#build-documentation).

---

BioDM is a fast, stateless and asynchronous REST API framework with the following core features:
Expand Down Expand Up @@ -46,8 +48,9 @@ Then you may run our `example` after populating `src/example/config.py` with yo
python3 src/example/app.py
```

### Generate documentation
### Build documentation
```bash
pip3 install -r src/requirements/docs.txt
sphinx-apidoc --implicit-namespaces -fo docs/biodm/ src/biodm -H "API Reference"
python3 -m sphinx -b html docs/ docs/build/html
```
Expand Down Expand Up @@ -121,7 +124,7 @@ then
docker run --name local_keycloak -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -p 8443:8080 keycloak:22.0.5_local-certs
```

**Configuration:**
- **Configuration**:

Once keycloak is running you need to configure a realm and a client for the app to log in.
Default values are:
Expand Down
2 changes: 1 addition & 1 deletion src/biodm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from biodm.tables import History, ListGroup
from biodm import __version__ as CORE_VERSION
try:
import kubernetes as k8s
import kubernetes
HAS_K8s = True
except:
HAS_K8s = False
Expand Down
7 changes: 5 additions & 2 deletions src/biodm/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from http import HTTPStatus

from starlette.responses import Response
# from sqlalchemy.exc import DatabaseError

from .exceptions import (
RequestError,
FailedDelete,
Expand All @@ -13,6 +13,7 @@


class Error:
"""Error class."""
def __init__(self, status, detail=None):
self.status = status
self.detail = detail
Expand All @@ -32,8 +33,10 @@ def response(self):
)


# https://restfulapi.net/http-status-codes/
async def onerror(_, exc):
"""Error event handler.
Relevant documentation: https://restfulapi.net/http-status-codes/"""
status = 500
detail = None

Expand Down
7 changes: 3 additions & 4 deletions src/biodm/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ class PayloadValidationError(RuntimeError):


## Routing
class InvalidCollectionMethod(RuntimeError):
class InvalidCollectionMethod(RequestError):
"""Raised when a unit method is accesed as a collection."""
def __init__(self, _, orig=None):
detail = "Method not allowed on a collection."
super().__init__(detail=detail)
def __init__(self, *_):
super().__init__(detail="Method not allowed on a collection.")


class UnauthorizedError(RequestError):
Expand Down
1 change: 0 additions & 1 deletion src/requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-r common.txt
kubernetes==29.0.0
pytest==8.1.1
Sphinx==7.3.7
4 changes: 4 additions & 0 deletions src/requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r dev.txt
Sphinx==7.3.7
sphinx-rtd-theme==2.0.0
sphinx-pyproject==0.3.0

0 comments on commit 7eeff5c

Please sign in to comment.