{"id":20074672,"url":"https://github.com/greenelab/connectivity-search-backend","last_synced_at":"2025-05-05T21:32:03.399Z","repository":{"id":55049359,"uuid":"155433553","full_name":"greenelab/connectivity-search-backend","owner":"greenelab","description":"Django backend for hetnet connectivity search","archived":false,"fork":false,"pushed_at":"2023-03-30T14:58:17.000Z","size":1437,"stargazers_count":6,"open_issues_count":5,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-05-02T06:00:22.588Z","etag":null,"topics":["backend","database","django","hetio","hetmech","hetnet-connectivity-search","hetnets"],"latest_commit_sha":null,"homepage":"https://search-api.het.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greenelab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-30T18:06:24.000Z","updated_at":"2024-03-12T12:43:49.000Z","dependencies_parsed_at":"2022-08-14T10:10:11.723Z","dependency_job_id":null,"html_url":"https://github.com/greenelab/connectivity-search-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenelab%2Fconnectivity-search-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenelab%2Fconnectivity-search-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenelab%2Fconnectivity-search-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenelab%2Fconnectivity-search-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greenelab","download_url":"https://codeload.github.com/greenelab/connectivity-search-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224470637,"owners_count":17316704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","database","django","hetio","hetmech","hetnet-connectivity-search","hetnets"],"created_at":"2024-11-13T14:53:29.738Z","updated_at":"2024-11-13T14:53:30.342Z","avatar_url":"https://github.com/greenelab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# connectivity search backend\n\n[![CircleCI](https://img.shields.io/circleci/build/github/greenelab/connectivity-search-backend/main?label=CI%20Build\u0026logo=circleci\u0026style=for-the-badge)](https://circleci.com/gh/greenelab/connectivity-search-backend)\n\nThis django application powers the API available at \u003chttps://search-api.het.io/\u003e.\n\n## Environment\n\nThis repository uses [conda](http://conda.pydata.org/docs/) to manage its environment as specified in [`environment.yml`](environment.yml).\nInstall the environment with:\n\n```shell\nconda env create --file=environment.yml\n```\n\nThen use `conda activate hetmech-backend` and `conda deactivate` to activate or deactivate the environment.\n\n## Secrets\n\nUsers must supply `dj_hetmech/secrets.yml` with the database connection information and two optional parameters for Django settings.\nSee [`dj_hetmech/secrets-template.yml`](dj_hetmech/secrets-template.yml) for what fields should be defined.\nThese secrets will determine whether django connects to a local database or a remote database and other security settings in Django.\n\n## Notebooks\n\nUse 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:\n\n```shell\npython manage.py shell_plus --notebook\n```\n\n## Server\n\nA local development server can be started with the command:\n\n```shell\npython manage.py runserver\n```\n\nThis exposes the API at \u003chttp://localhost:8000/v1/\u003e.\n\n## Database\n\nThis project uses a PostgreSQL database.\nThe deployed version of this application uses a remote database.\nPublic read-only access is available with the following configuration:\n\n```yaml\nname: connectivity_db\nuser: read_only_user\npassword: tm8ut9uzqx7628swwkb9\nhost: search-db.het.io\nport: 5432\n```\n\nTo erect a new database locally for development, run:\n\n```shell\n# https://docs.docker.com/samples/library/postgres/\ndocker run \\\n  --name connectivity_db \\\n  --env POSTGRES_DB=connectivity_db \\\n  --env POSTGRES_USER=dj_hetmech \\\n  --env POSTGRES_PASSWORD=not_secure \\\n  --volume \"$(pwd)\"/database:/var/lib/postgresql/data \\\n  --publish 5432:5432 \\\n  --detach \\\n  postgres:12.4\n```\n\n### Populating the database\n\nTo populate the database from scratch, use the populate_database management command ([source](dj_hetmech_app/management/commands/populate_database.py)).\nHere is an example workflow:\n\n```shell\n# migrate database to the current Django models\npython manage.py makemigrations\npython manage.py migrate --run-syncdb\n# view the populate_database usage docs\npython manage.py populate_database --help\n# wipe the existing database (populate_database assumes empty tables)\npython manage.py flush --no-input\n# populate the database (will take a long time)\npython manage.py populate_database --max-metapath-length=3 --reduced-metapaths --batch-size=12000\n# output database information and table summaries\npython manage.py database_info\n```\n\nAnother option to load the database is to import it from the `connectivity-search-pg_dump.sql.gz` database dump,\nwhich will save time if you are interested in loading the full database (i.e. without `--reduced-metapaths`).\nThis 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).\n\nTo load `connectivity-search-pg_dump.sql.gz` into a new database, modify the following command:\n\n```shell\nzcat hetmech-pg_dump.sql.gz | psql --user=dj_hetmech --dbname=connectivity_db --host=HOST\n```\n\n`connectivity-search-pg_dump.sql.gz` was exported from the development Docker database with the command:\n\n```shell\ndocker exec connectivity_db \\\n  pg_dump \\\n  --host=localhost --username=dj_hetmech --dbname=connectivity_db \\\n  --create --clean \\\n  --compress=8 \\\n  \u003e connectivity-search-pg_dump.sql.gz\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenelab%2Fconnectivity-search-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreenelab%2Fconnectivity-search-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenelab%2Fconnectivity-search-backend/lists"}