https://github.com/jackdbd/dash-fda
A Plotly Dash application to interact with the API endpoints of openFDA
https://github.com/jackdbd/dash-fda
dash dashboard fda plotly
Last synced: about 1 year ago
JSON representation
A Plotly Dash application to interact with the API endpoints of openFDA
- Host: GitHub
- URL: https://github.com/jackdbd/dash-fda
- Owner: jackdbd
- License: mit
- Created: 2017-09-01T21:16:07.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T11:19:48.000Z (over 5 years ago)
- Last Synced: 2025-02-23T17:37:22.951Z (over 1 year ago)
- Topics: dash, dashboard, fda, plotly
- Language: Python
- Homepage: https://cutt.ly/dash-fda
- Size: 2.93 MB
- Stars: 22
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dash FDA
[](https://opensource.org/licenses/MIT) [](https://travis-ci.org/jackdbd/dash-fda) [](https://codecov.io/github/jackdbd/dash-fda?branch=master) [](https://github.com/ambv/black)
A Dash app to visualize data from the openFDA elasticsearch API.

[App on CapRover](https://cutt.ly/dash-fda).
Built with:
- [Plotly Dash](https://plotly.com/dash/)
- [openFDA /device endpoint](https://open.fda.gov/device/)
Data from [openFDA](https://open.fda.gov/).
## API keys
This project requires to get some API keys from external services.
- `PLOTLY_USERNAME`, `PLOTLY_API_KEY`: get them at [chart-studio.plotly.com](https://chart-studio.plotly.com/).
- `OPEN_FDA_API_KEY`: get it at [openFDA](https://open.fda.gov/apis/authentication/)
## Installation
This project uses [pyenv](https://github.com/pyenv/pyenv) and [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) to manage the Python virtual environment, and [poetry](https://poetry.eustace.io/) to manage the project dependencies.
If you don't already have it, install python `3.8.5`.
```shell
pyenv install 3.8.5
```
Create a virtual environment and activate it.
```shell
pyenv virtualenv 3.8.5 dash_fda
pyenv activate dash_fda
```
Remember to activate the virtual environment every time you work on this project.
Install all the dependencies from the `poetry.lock` file.
```shell
poetry install
```
## Tasks
This project uses the task runner [Poe the Poet](https://github.com/nat-n/poethepoet) to run poetry scripts.
## Non-dockerized app
Run the app locally using a development server (Dash uses a Flask development server):
```shell
poetry run poe dev
# or, in alternative
python app.py
```
Run the app locally using a production server (gunicorn):
```shell
poetry run poe prod
```
Run all tests with pytest:
```shell
poetry run poe test
```
Format all code with black:
```shell
poetry run poe format
```
## Dockerized app
Build the Docker image and give it a name and a version tag:
```shell
docker build -t dash-fda:v0.1.0 .
```
Run the Docker container:
```shell
docker run --env-file ./dash_fda/.env -p 5001:5000 dash-fda:v0.1.0
```
Deploy the dockerized app on CapRover (running on my DigitalOcean Droplet):
```shell
./deploy.sh
```
## Troubleshooting
If you are on Ubuntu you might get `ModuleNotFoundError: No module named '_bz2'` and/or `UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.` These errors are caused by pandas when it tries to import these [compression libraries](https://github.com/pandas-dev/pandas/issues/27575). If you get these errors you need to install the libbz2-dev package and the liblzma-dev package, then re-compile your python interpreter.
Here is how you can do it:
```shell
# deactivate and remove the virtual environment
pyenv deactivate
pyenv virtualenv-delete dash_fda
# remove the "broken" python interpreter
pyenv uninstall 3.8.5
# install the compression libreries
sudo apt-get install libbz2-dev liblzma-dev
# download and compile the python interpreter
pyenv install 3.8.5
# re-create the virtual environment and activate it
pyenv virtualenv 3.8.5 dash_fda
pyenv activate dash_fda
# re-install all the dependencies
poetry install
```
## Disclaimer
This app is just an independent project, and it has not been evaluated by the Food and Drug Administration.
This app is not intended to diagnose, treat, cure, or prevent any disease.
Do not rely on this app to make any decision regarding medical care.