Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/greenelab/connectivity-search-backend
Django backend for hetnet connectivity search
https://github.com/greenelab/connectivity-search-backend
backend database django hetio hetmech hetnet-connectivity-search hetnets
Last synced: about 2 months ago
JSON representation
Django backend for hetnet connectivity search
- Host: GitHub
- URL: https://github.com/greenelab/connectivity-search-backend
- Owner: greenelab
- License: bsd-3-clause
- Created: 2018-10-30T18:06:24.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T14:58:17.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T06:00:22.588Z (8 months ago)
- Topics: backend, database, django, hetio, hetmech, hetnet-connectivity-search, hetnets
- Language: Python
- Homepage: https://search-api.het.io
- Size: 1.37 MB
- Stars: 6
- Watchers: 7
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# connectivity search backend
[![CircleCI](https://img.shields.io/circleci/build/github/greenelab/connectivity-search-backend/main?label=CI%20Build&logo=circleci&style=for-the-badge)](https://circleci.com/gh/greenelab/connectivity-search-backend)
This django application powers the API available at .
## Environment
This repository uses [conda](http://conda.pydata.org/docs/) to manage its environment as specified in [`environment.yml`](environment.yml).
Install the environment with:```shell
conda env create --file=environment.yml
```Then use `conda activate hetmech-backend` and `conda deactivate` to activate or deactivate the environment.
## Secrets
Users must supply `dj_hetmech/secrets.yml` with the database connection information and two optional parameters for Django settings.
See [`dj_hetmech/secrets-template.yml`](dj_hetmech/secrets-template.yml) for what fields should be defined.
These secrets will determine whether django connects to a local database or a remote database and other security settings in Django.## Notebooks
Use the [following command](https://medium.com/ayuth/how-to-use-django-in-jupyter-notebook-561ea2401852) to launch Jupyter Notebook in your browser for interactive development:
```shell
python manage.py shell_plus --notebook
```## Server
A local development server can be started with the command:
```shell
python manage.py runserver
```This exposes the API at .
## Database
This project uses a PostgreSQL database.
The deployed version of this application uses a remote database.
Public read-only access is available with the following configuration:```yaml
name: connectivity_db
user: read_only_user
password: tm8ut9uzqx7628swwkb9
host: search-db.het.io
port: 5432
```To erect a new database locally for development, run:
```shell
# https://docs.docker.com/samples/library/postgres/
docker run \
--name connectivity_db \
--env POSTGRES_DB=connectivity_db \
--env POSTGRES_USER=dj_hetmech \
--env POSTGRES_PASSWORD=not_secure \
--volume "$(pwd)"/database:/var/lib/postgresql/data \
--publish 5432:5432 \
--detach \
postgres:12.4
```### Populating the database
To populate the database from scratch, use the populate_database management command ([source](dj_hetmech_app/management/commands/populate_database.py)).
Here is an example workflow:```shell
# migrate database to the current Django models
python manage.py makemigrations
python manage.py migrate --run-syncdb
# view the populate_database usage docs
python manage.py populate_database --help
# wipe the existing database (populate_database assumes empty tables)
python manage.py flush --no-input
# populate the database (will take a long time)
python manage.py populate_database --max-metapath-length=3 --reduced-metapaths --batch-size=12000
# output database information and table summaries
python manage.py database_info
```Another option to load the database is to import it from the `connectivity-search-pg_dump.sql.gz` database dump,
which will save time if you are interested in loading the full database (i.e. without `--reduced-metapaths`).
This 5 GB file is [available on Zenodo](https://doi.org/10.5281/zenodo.3978766 "Node connectivity measurements for Hetionet v1.0 metapaths. Zenodod Version v1.1") (TODO: update [latest database dump](https://github.com/greenelab/connectivity-search-backend/pull/79) to Zenodo).To load `connectivity-search-pg_dump.sql.gz` into a new database, modify the following command:
```shell
zcat hetmech-pg_dump.sql.gz | psql --user=dj_hetmech --dbname=connectivity_db --host=HOST
````connectivity-search-pg_dump.sql.gz` was exported from the development Docker database with the command:
```shell
docker exec connectivity_db \
pg_dump \
--host=localhost --username=dj_hetmech --dbname=connectivity_db \
--create --clean \
--compress=8 \
> connectivity-search-pg_dump.sql.gz
```