Open pharma dashboard

September 19, 2022 ยท View on GitHub

The objective of openpharma is to provide a neutral home for open source software related to pharmaceutical industry that is not tied to one company or institution. http://openpharma.pharmaverse.org/

๐Ÿ“จ For any questions, feel free to reach me out at the email adress : mathieu.cayssol@gmail.com

0. General overview

i. Objectives

Screenshot 2022-09-19 at 18 03 31

ii. Global pipeline

You are in the front-end repository of openpharma. The global project include 3 repositories :

1. Techonologies and structure of the repo

We are using Python 3.9.x and Streamlit 1.11.1 to create the webapp. We also added custom HTML/CSS using Boostrap 5.2. We are also using SentenceTransformers 2.2.2 and Pytorch 1.12 The repository follows the current organisation :

.
โ”œโ”€โ”€ LM-L6-BERT  ๐Ÿ“ (folder with BERT model - used to make inference with the search bar)
โ”‚   โ””โ”€โ”€ ....... 
โ”œโ”€โ”€ apps         ๐Ÿ“ (pages of the web app)
โ”‚   โ”œโ”€โ”€ about.py
โ”‚   โ”œโ”€โ”€ activity.py
โ”‚   โ”œโ”€โ”€ leaderboard.py
โ”‚   โ”œโ”€โ”€ openissues.py
โ”‚   โ””โ”€โ”€ pharmapackages.py
โ”œโ”€โ”€ python_functions       ๐Ÿ“ (functions to handle dataframe and add custom html/css)
โ”‚   โ”œโ”€โ”€ df_activity.py
โ”‚   โ”œโ”€โ”€ df_leaderboard.py
โ”‚   โ”œโ”€โ”€ df_openissues.py
โ”‚   โ”œโ”€โ”€ df_pharmpack.py
โ”‚   โ””โ”€โ”€ search_engine.py
โ”œโ”€โ”€ style                  ๐Ÿ“ (CSS for custom html components)
โ”‚   โ”œโ”€โ”€ about.css
โ”‚   โ”œโ”€โ”€ activity.css
โ”‚   โ”œโ”€โ”€ header.css
โ”‚   โ”œโ”€โ”€ leaderboard.css
โ”‚   โ”œโ”€โ”€ openissues.css
โ”‚   โ””โ”€โ”€ pharmapackages.css
โ”œโ”€โ”€ Dockerfile     ๐Ÿณ (Dockerfile for deployment)
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ app.py    ๐Ÿ“„ (streamlit app main page -> entrypoint to naviagte through menu)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ setup.sh
โ””โ”€โ”€ utils.py  ๐Ÿ“„ (Menu definition)

The entry point of the app is the file ๐Ÿ“„ app.py at the root of the project. From this file, we are calling ๐Ÿ“„ utils.py which contains menu defintion. In the folder ๐Ÿ“ apps, we have 5 files corresponding to the 5 pages. Each of them is used to render streamlit widgets and calling corresponding functions from the folder ๐Ÿ“ python_functions. In the ๐Ÿ“ style folder, we have the css files for styling the page. The folder ๐Ÿ“ LM-L6-BERT is an hard copy of a pretrained NLP model from hugging face. It is used to make inference given a query in the search bar and gives relevant match for this query. Finally, we have ๐Ÿณ Dockerfile, ๐Ÿ“„ setup.sh and ๐Ÿ“„ requirements.txt used for the deployment.

To understand the interactions in more depth, if we are in the page "Open Issues", the server will execute the ๐Ÿ“„ app.py file. This file will then call ๐Ÿ“„ utils.py to display the menu and ๐Ÿ“„ apps/openissues.py to display the current page. ๐Ÿ“„ openissues.py will call the functions contained in ๐Ÿ“„ python_functions/df_openissues.py to read the data, render the corresponding HTML and display it given the filters applied by the user

2. Run the app locally

Prerequisites :

  • Python == 3.8
$ git clone https://github.com/openpharma/opensource_dashboard.git
$ cd <PATH_TO_THE_CLONE>

In your virtual environnement :

(vitual_env)$ pip install -r requirements.txt
(vitual_env)$ streamlit run app.py

3. Deployment on Elastic Beanstalk using ECR (Elastic Container Registry)

  • Push the docker image to ECR using Github Actions (automatic)

  • Create a Beanstalk instance this way :

    • Create a Beanstalk application
    • Create an environnement using the platform Docker
    • In Configuration, set Instances size to 12GB of SSD
    • In Configuration, set Instances types to t2.small and t2.medium
  • Go in IAM Service and set AmazonEC2ContainerRegistryReadOnly policy to aws-elasticbeanstalk-ec2-role as explained in this link https://stackoverflow.com/questions/44850578/aws-elastic-beanstalk-with-amazon-ecr-docker-image

  • Go in your environnement, click on Upload and deploy button. Upload the file called Dockerrun.aws.json on this repo. Make sure that the image name inside the JSON file corresponds to the image name in ECR. (something like 8XXXXXXXXXX8.dkr.ecr.us-east-1.amazonaws.com/openpharma-docker:latest)

  • Click on Actions and rebuild environnement.