|
11 | 11 |
|
12 | 12 | A generic REST API server backend for DataJoint pipelines built on top of `flask`, `datajoint`, and `pyjwt`. |
13 | 13 |
|
14 | | -Requirements: |
| 14 | +Usage and API documentation currently available within method docstrings. See Python's `help(...)` utility. |
| 15 | + |
| 16 | +## Requirements for Preferred Setup |
| 17 | + |
15 | 18 | - [Docker](https://docs.docker.com/get-docker/ ) |
16 | 19 | - [Docker Compose](https://docs.docker.com/compose/install/) |
17 | 20 |
|
18 | | -## Run Locally |
| 21 | +## Run Locally w/ Docker |
19 | 22 |
|
20 | 23 | - Copy a `*-docker-compose.yaml` file corresponding to your usage to `docker-compose.yaml`. This file is untracked so feel free to modify as necessary. |
21 | 24 | - Check the first comment which will provide best instruction on how to start the service. |
22 | 25 |
|
23 | 26 | > :warning: Deployment options currently being considered are [Docker Compose](https://docs.docker.com/compose/install/) and [Kubernetes](https://kubernetes.io/docs/tutorials/kubernetes-basics/). |
24 | 27 |
|
25 | | -## Run Tests for Development |
| 28 | +## Run Locally w/ Python |
| 29 | + |
| 30 | +- Set environment variables for port assignment (`PHARUS_PORT`, defaults to 5000) and API route prefix (`PHARUS_PREFIX` e.g. `/api`, defaults to empty string). |
| 31 | +- For development, use CLI command `pharus`. This method supports hot-reloading so probably best coupled with `pip install -e ...`. |
| 32 | +- For production, use `gunicorn --bind 0.0.0.0:${PHARUS_PORT} pharus.server:app`. |
| 33 | + |
| 34 | +## Run Tests for Development w/ Docker |
26 | 35 |
|
27 | 36 | - Create a `.env` as appropriate for your setup: |
28 | | -```shell |
29 | | -PY_VER=3.8 # Python version: 3.6|3.7|3.8 |
30 | | -IMAGE=djtest # Image type: djbase|djtest|djlab|djlabhub |
31 | | -DISTRO=alpine # Distribution: alpine|debian |
32 | | -AS_SCRIPT= # If 'TRUE', will not keep container alive but run tests and exit |
33 | | -``` |
| 37 | + ```shell |
| 38 | + PY_VER=3.8 # Python version: 3.6|3.7|3.8 |
| 39 | + IMAGE=djtest # Image type: djbase|djtest|djlab|djlabhub |
| 40 | + DISTRO=alpine # Distribution: alpine|debian |
| 41 | + AS_SCRIPT= # If 'TRUE', will not keep container alive but run tests and exit |
| 42 | + ``` |
34 | 43 | - Navigate to `test-docker-compose.yaml` and check first comment which will provide best instruction on how to start the service. Yes, the command is a bit long... |
35 | 44 |
|
| 45 | +## Run Tests for Development w/ Pytest and Flake8 |
| 46 | + |
| 47 | +- Set `pharus` testing environment variables: |
| 48 | + ```shell |
| 49 | + PKG_DIR=/opt/conda/lib/python3.8/site-packages/pharus # path to pharus installation |
| 50 | + TEST_DB_SERVER=example.com:3306 # testing db server address |
| 51 | + TEST_DB_USER=root # testing db server user (needs CRUD on schemas, tables, users) |
| 52 | + TEST_DB_PASS=unsecure # testing db server password |
| 53 | + ``` |
| 54 | +- For syntax tests, run `flake8 ${PKG_DIR} --count --select=E9,F63,F7,F82 --show-source --statistics` |
| 55 | +- For pytest integration tests, run `pytest -sv --cov-report term-missing --cov=${PKG_DIR} /main/tests` |
| 56 | +- For style tests, run `flake8 ${PKG_DIR} --count --max-complexity=20 --max-line-length=95 --statistics` |
| 57 | + |
36 | 58 | ## References |
37 | 59 |
|
38 | 60 | - DataJoint LabBook (a companion frontend) |
|
0 commit comments