A web server to manage requests for meshes and routes generated using the PolarRoute and MeshiPhi libraries, implemented using Django, Celery and Django REST framework.
It currently takes vessel meshes created using MeshiPhi or PolarRoute-pipeline and serves requests for routes, which are calculated using PolarRoute.
PolarRouteServer can be installed from GitHub using pip.
- Inside a virtual environment (e.g. venv, conda, etc.) run
pip install git+https://github.com/bas-amop/PolarRoute-server- To install a specific version append the tag, e.g.
pip install git+https://github.com/bas-amop/[email protected] - Alternatively, clone this repository with git and install from source with
pip install -e .
- To install a specific version append the tag, e.g.
Use docker compose for development deployment to orchestrate celery and rabbitmq alongside the django development server.
Clone this repository and run docker compose up to build and start the services.
Note: In development, meshes are not automatically ingested into the database. Follow these steps to add a mesh to the database.
- Make a local directory structure with
mkdir -p data/mesh(if it has not been created bydocker compose). - If you have a vessel mesh file from MeshiPhi or PolarRoute-pipeline, copy it into
./data/mesh, which is bind-mounted into the app container. Alternatively, download an example mesh using
pushd data/mesh
wget http://files.bas.ac.uk/twins/polarroute/example_vehicle_meshes/amsr_southern_SDA.json.gz && \
wget http://files.bas.ac.uk/twins/polarroute/example_vehicle_meshes/amsr_central_SDA.json.gz && \
wget http://files.bas.ac.uk/twins/polarroute/example_vehicle_meshes/amsr_northern_SDA.json.gz
gunzip amsr_*_SDA.json.gz
popd
- Run
docker compose exec app /bin/bashto open a shell inside the running app container. - Run
django-admin insert_mesh /usr/src/app/data/mesh/<MESH FILENAME>to insert the mesh into the database manually.
Test that the app is working using the request_route tool (see Documentation). The URL of the service should be localhost:8000.
The django development server supports hot reloading and the source code is bind-mounted into the container, so changes should be reflected in the running app. Any changes to polarrouteserver.route_api.models.py will necessitate a migration to the database. To create and run migrations, run:
docker compose exec app django-admin makemigrations
docker compose exec app django-admin migrate
Optionally, Swagger can be used to serve an API schema. This is not started by default, but can be enabled by started docker compose with the --profile swagger option, e.g. docker compose --profile swagger up -d - the swagger UI will be served at localhost:80/swagger.